修改为单屏
This commit is contained in:
@@ -4,25 +4,35 @@ using Nancy.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using 电子展板.Base;
|
||||
using 电子展板.Utility;
|
||||
using 电子展板.Utility.Extension;
|
||||
|
||||
namespace 电子展板.ViewModels
|
||||
{
|
||||
public class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
private Window window;
|
||||
public ImageSource Image1 { get; set; }
|
||||
public ImageSource Image2 { get; set; }
|
||||
public ImageSource Image3 { get; set; }
|
||||
public ImageSource Image4 { get; set; }
|
||||
public DelegateCommand<Window> LoadedCommand { get; set; }
|
||||
public DelegateCommand<CancelEventArgs> WindowClosingCommand { get; set; }
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
{
|
||||
LoadedCommand = new DelegateCommand<Window>(Loaded);
|
||||
WindowClosingCommand = new DelegateCommand<CancelEventArgs>(WindowClosing);
|
||||
EventBus.Instance.Subscribe(this, "save", ReloadImage);
|
||||
InitImage();
|
||||
}
|
||||
|
||||
private void Loaded(Window window)
|
||||
@@ -48,5 +58,75 @@ namespace 电子展板.ViewModels
|
||||
{
|
||||
return VisualTreeHelper.GetDpi(this.window).DpiScaleX;
|
||||
}
|
||||
|
||||
|
||||
private void ReloadImage(string obj)
|
||||
{
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
InitImage();
|
||||
});
|
||||
}
|
||||
|
||||
private void InitImage()
|
||||
{
|
||||
try
|
||||
{
|
||||
BitmapImage image1 = new BitmapImage();
|
||||
image1.BeginInit();
|
||||
image1.CacheOption = BitmapCacheOption.OnLoad;
|
||||
image1.StreamSource = new MemoryStream(File.ReadAllBytes(MyEnvironment.Root(Config.CPCMember1Path)));
|
||||
image1.EndInit();
|
||||
image1.Freeze();
|
||||
Image1 = image1;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Image1 = null;
|
||||
}
|
||||
try
|
||||
{
|
||||
BitmapImage image2 = new BitmapImage();
|
||||
image2.BeginInit();
|
||||
image2.CacheOption = BitmapCacheOption.OnLoad;
|
||||
image2.StreamSource = new MemoryStream(File.ReadAllBytes(MyEnvironment.Root(Config.CPCMember2Path)));
|
||||
image2.EndInit();
|
||||
image2.Freeze();
|
||||
Image2 = image2;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Image2 = null;
|
||||
|
||||
}
|
||||
try
|
||||
{
|
||||
BitmapImage image3 = new BitmapImage();
|
||||
image3.BeginInit();
|
||||
image3.CacheOption = BitmapCacheOption.OnLoad;
|
||||
image3.StreamSource = new MemoryStream(File.ReadAllBytes(MyEnvironment.Root(Config.CPCMember3Path)));
|
||||
image3.EndInit();
|
||||
image3.Freeze();
|
||||
Image3 = image3;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Image3 = null;
|
||||
}
|
||||
try
|
||||
{
|
||||
BitmapImage image4 = new BitmapImage();
|
||||
image4.BeginInit();
|
||||
image4.CacheOption = BitmapCacheOption.OnLoad;
|
||||
image4.StreamSource = new MemoryStream(File.ReadAllBytes(MyEnvironment.Root(Config.CPCMember4Path)));
|
||||
image4.EndInit();
|
||||
image4.Freeze();
|
||||
Image4 = image4;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Image4 = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user