修改为单屏

This commit is contained in:
2025-09-26 11:23:55 +08:00
parent aa43943f33
commit 0884292626
11 changed files with 223 additions and 420 deletions

View File

@@ -1,7 +1,8 @@
<Application x:Class="电子展板.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:电子展板" >
xmlns:local="clr-namespace:电子展板"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>

View File

@@ -13,16 +13,7 @@ namespace 电子展板
{
public App()
{
}
protected override void OnStartup(StartupEventArgs e)
{
MainWindow mainWindow = new MainWindow();
mainWindow.Show();
MainWindow2 mainWindow2 = new MainWindow2();
mainWindow2.Show();
base.OnStartup(e);
}
}
}
}

View File

@@ -146,7 +146,7 @@
</div>
<div style="width: 132px;margin-left:100px">
<div class="layui-upload-list">
<img class="layui-upload-img" id="image1" style="width: 100%; height: 92px;" />
<img class="layui-upload-img" id="image1" style="width: 100%; height: 150px;" />
<div id="upload-text1"></div>
</div>
<!--<div class="layui-progress layui-progress-big" lay-showPercent="yes" lay-filter="filter-progress1">
@@ -175,7 +175,7 @@
</div>
<div style="width: 132px;margin-left:100px">
<div class="layui-upload-list">
<img class="layui-upload-img" id="image2" style="width: 100%; height: 92px;" />
<img class="layui-upload-img" id="image2" style="width: 100%; height: 150px;" />
<div id="upload-text2"></div>
</div>
<!--<div class="layui-progress layui-progress-big" lay-showPercent="yes" lay-filter="filter-progress2">
@@ -204,7 +204,7 @@
</div>
<div style="width: 132px;margin-left:100px">
<div class="layui-upload-list">
<img class="layui-upload-img" id="image3" style="width: 100%; height: 92px;" />
<img class="layui-upload-img" id="image3" style="width: 100%; height: 150px;" />
<div id="upload-text3"></div>
</div>
<!--<div class="layui-progress layui-progress-big" lay-showPercent="yes" lay-filter="filter-progress3">
@@ -233,7 +233,7 @@
</div>
<div style="width: 132px;margin-left:100px">
<div class="layui-upload-list">
<img class="layui-upload-img" id="image4" style="width: 100%; height: 92px;" />
<img class="layui-upload-img" id="image4" style="width: 100%; height: 150px;" />
<div id="upload-text4"></div>
</div>
<!--<div class="layui-progress layui-progress-big" lay-showPercent="yes" lay-filter="filter-progress4">

View File

@@ -9,6 +9,7 @@
xmlns:vm="clr-namespace:电子展板.ViewModels"
ResizeMode="NoResize"
WindowStyle="None"
WindowState="Maximized"
mc:Ignorable="d"
x:Name="window"
Title="MainWindow" Background="#E5E5E5">
@@ -27,69 +28,82 @@
<Viewbox Stretch="Uniform" >
<Canvas Width="1920" Height="1080">
<Grid Width="1920" Height="1080">
<Grid.RowDefinitions>
<RowDefinition Height="80"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="140"/>
<RowDefinition Height="80"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="6*"/>
<ColumnDefinition Width="8*"/>
<ColumnDefinition Width="6*"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0" Grid.Column="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="180"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="时间:" Grid.Column="0" FontSize="60" Foreground="#1F7572" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,0,0,0"/>
<Border Grid.Column="1" Background="#C0E3D9" CornerRadius="20" Height="140">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="{Binding Config.TimeSize}" Foreground="Black" TextWrapping="Wrap" Text="{Binding Config.Time}"/>
</Border>
</Grid>
<TextBlock Text="时间:" FontSize="50" Foreground="#1F7572" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="95,18,0,0"/>
<Border Background="#C0E3D9" CornerRadius="20" Height="80" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="250,12,0,0" Width="277">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="{Binding Config.TimeSize}" Foreground="Black" TextWrapping="Wrap" Text="{Binding Config.Time}"/>
</Border>
<TextBlock Text="负责人:" FontSize="50" Foreground="#1F7572" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="718,18,0,0"/>
<Border Background="#C0E3D9" CornerRadius="20" Height="80" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="925,10,0,0" Width="263">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="{Binding Config.ChargerSize}" Foreground="Black" TextWrapping="Wrap" Text="{Binding Config.Charger}" />
</Border>
<TextBlock Text="风险等级:" FontSize="50" Foreground="#1F7572" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="1335,18,0,0"/>
<Border Background="#C0E3D9" CornerRadius="20" Height="85" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="1620,7,0,0" Width="240">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="{Binding Config.RiskLevelSize}" Foreground="Black" TextWrapping="Wrap" Text="{Binding Config.RiskLevel}"/>
</Border>
<TextBlock Text="工作内容" FontSize="50" Foreground="#1F7572" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="145,116,0,0"/>
<Border Background="#C0E3D9" CornerRadius="20" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="35,205,0,0" Width="485" Height="820" >
<TextBlock HorizontalAlignment="Left" Margin="10" VerticalAlignment="Top" FontSize="{Binding Config.ContentSize}" Foreground="Black" TextWrapping="Wrap" Text="{Binding Config.Content}"/>
</Border>
<TextBlock Text="危险点" FontSize="50" Foreground="#1F7572" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="636,116,0,0" Height="65" Width="164"/>
<Border Background="#C0E3D9" CornerRadius="20" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="541,205,0,0" Height="820" Width="394">
<TextBlock Margin="10" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="{Binding Config.DangerPointSize}" Foreground="Black" TextWrapping="Wrap" Text="{Binding Config.DangerPoint}"/>
</Border>
<TextBlock Text="重点管控措施" FontSize="50" Foreground="#1F7572" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="1005,130,0,0" Height="65" Width="339"/>
<Border Background="#C0E3D9" CornerRadius="20" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="960,205,0,0" Height="820" Width="455">
<TextBlock Margin="10" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="{Binding Config.MeasuresSize}" Foreground="Black" TextWrapping="Wrap" Text="{Binding Config.Measures}"/>
</Border>
<TextBlock Text="党员亮身份" FontSize="50" Foreground="#1F7572" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="1540,130,0,0" Height="65" Width="320"/>
<Border Background="#C0E3D9" CornerRadius="20" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="1452,205,0,0" Height="385" Width="223">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<Image Margin="10" Source="{Binding Image1}" Stretch="Uniform" />
<TextBlock Text="{Binding Config.CPCMember1Name}" Grid.Row="1" FontSize="{Binding Config.CPCMemberSize}" Foreground="Black" TextWrapping="Wrap" TextAlignment="Center"/>
</Grid>
<Grid Grid.Row="0" Grid.Column="2" Margin="40,0,0,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="240"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="负责人:" Grid.Column="0" FontSize="60" Foreground="#1F7572" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,0,0,0"/>
<Border Grid.Column="1" Background="#C0E3D9" CornerRadius="20" Height="140">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="{Binding Config.ChargerSize}" Foreground="Black" TextWrapping="Wrap" Text="{Binding Config.Charger}"/>
</Border>
</Grid>
</Border>
<Border Background="#C0E3D9" CornerRadius="20" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="1687,205,0,0" Height="385" Width="223">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<Image Margin="10" Source="{Binding Image2}" Stretch="Uniform" />
<TextBlock Text="{Binding Config.CPCMember2Name}" Grid.Row="1" FontSize="{Binding Config.CPCMemberSize}" Foreground="Black" TextWrapping="Wrap" TextAlignment="Center"/>
</Grid>
<Grid Grid.Row="0" Grid.Column="3" Margin="40,0,0,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="270"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="风险等级:" Grid.Column="0" FontSize="60" Foreground="#1F7572" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,0,0,0"/>
<Border Grid.Column="1" Background="#C0E3D9" CornerRadius="20" Height="140">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="{Binding Config.RiskLevelSize}" Foreground="Black" TextWrapping="Wrap" Text="{Binding Config.RiskLevel}"/>
</Border>
</Grid>
</Border>
<Border Background="#C0E3D9" CornerRadius="20" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="1452,635,0,0" Height="385" Width="223">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<Image Margin="10" Source="{Binding Image3}" Stretch="Uniform" />
<TextBlock Text="{Binding Config.CPCMember3Name}" Grid.Row="1" FontSize="{Binding Config.CPCMemberSize}" Foreground="Black" TextWrapping="Wrap" TextAlignment="Center"/>
</Grid>
<TextBlock Grid.Row="1" Grid.Column="1" Text="工作内容:" FontSize="60" Foreground="#1F7572" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,0,0,0"/>
<Border Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Background="#C0E3D9" CornerRadius="20" Margin="0,40,0,40">
<TextBlock HorizontalAlignment="Left" Margin="10" VerticalAlignment="Top" FontSize="{Binding Config.ContentSize}" Foreground="Black" TextWrapping="Wrap" Text="{Binding Config.Content}"/>
</Border>
</Grid>
</Border>
<Border Background="#C0E3D9" CornerRadius="20" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="1687,635,0,0" Height="385" Width="223">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<Image Margin="10" Source="{Binding Image4}" Stretch="Uniform" />
<TextBlock Text="{Binding Config.CPCMember4Name}" Grid.Row="1" FontSize="{Binding Config.CPCMemberSize}" Foreground="Black" TextWrapping="Wrap" TextAlignment="Center"/>
</Grid>
</Border>
</Grid>
</Canvas>
</Viewbox>
</Grid>

View File

@@ -1,110 +0,0 @@
<Window xmlns:hc="https://handyorg.github.io/handycontrol" x:Class="电子展板.MainWindow2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:local="clr-namespace:电子展板"
xmlns:vm="clr-namespace:电子展板.ViewModels"
ResizeMode="NoResize"
WindowStyle="None"
x:Name="window"
mc:Ignorable="d"
Title="MainWindow" Background="#E5E5E5">
<Window.DataContext>
<vm:MainWindow2ViewModel/>
</Window.DataContext>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction Command="{Binding LoadedCommand}" CommandParameter="{Binding ElementName=window}"/>
</i:EventTrigger>
<i:EventTrigger EventName="Closing">
<i:InvokeCommandAction Command="{Binding WindowClosingCommand}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<Grid>
<Viewbox Stretch="Uniform" >
<Canvas Width="1920" Height="1080">
<Grid Width="1920" Height="1080">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="70"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="460"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<TextBlock Text="危险点" Grid.Row="1" Grid.Column="1" FontSize="60" Foreground="#1F7572" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,0,0"/>
<TextBlock Text="重点管控措施" Grid.Row="1" Grid.Column="2" FontSize="60" Foreground="#1F7572" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,0,0"/>
<TextBlock Text="党员亮身份" Grid.Row="1" Grid.Column="3" FontSize="60" Foreground="#1F7572" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,0,0"/>
<Border Grid.Row="2" Grid.Column="1" Background="#C0E3D9" CornerRadius="20" Margin="0,20,20,50">
<TextBlock Margin="10" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="{Binding Config.DangerPointSize}" Foreground="Black" TextWrapping="Wrap" Text="{Binding Config.DangerPoint}"/>
</Border>
<Border Grid.Row="2" Grid.Column="2" Background="#C0E3D9" CornerRadius="20" Margin="25,20,20,50">
<TextBlock Margin="10" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="{Binding Config.MeasuresSize}" Foreground="Black" TextWrapping="Wrap" Text="{Binding Config.Measures}"/>
</Border>
<Grid Grid.Row="2" Grid.Column="3" Margin="20,20,0,50">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" Grid.Column="0" Background="#C0E3D9" CornerRadius="20" Margin="10,0,5,5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<Image Margin="10" Source="{Binding Image1}" Stretch="Uniform" />
<TextBlock Text="{Binding Config.CPCMember1Name}" Grid.Row="1" FontSize="{Binding Config.CPCMemberSize}" Foreground="Black" TextWrapping="Wrap" TextAlignment="Center"/>
</Grid>
</Border>
<Border Grid.Row="0" Grid.Column="1" Background="#C0E3D9" CornerRadius="20" Margin="5,0,10,5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<Image Margin="10" Source="{Binding Image2}" Stretch="Uniform" />
<TextBlock Text="{Binding Config.CPCMember2Name}" Grid.Row="1" FontSize="{Binding Config.CPCMemberSize}" Foreground="Black" TextWrapping="Wrap" TextAlignment="Center"/>
</Grid>
</Border>
<Border Grid.Row="1" Grid.Column="0" Background="#C0E3D9" CornerRadius="20" Margin="10,5,5,0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<Image Margin="10" Source="{Binding Image3}" Stretch="Uniform" />
<TextBlock Text="{Binding Config.CPCMember3Name}" Grid.Row="1" FontSize="{Binding Config.CPCMemberSize}" Foreground="Black" TextWrapping="Wrap" TextAlignment="Center"/>
</Grid>
</Border>
<Border Grid.Row="1" Grid.Column="1" Background="#C0E3D9" CornerRadius="20" Margin="5,5,10,0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<Image Margin="10" Source="{Binding Image4}" Stretch="Uniform" />
<TextBlock Text="{Binding Config.CPCMember4Name}" Grid.Row="1" FontSize="{Binding Config.CPCMemberSize}" Foreground="Black" TextWrapping="Wrap" TextAlignment="Center"/>
</Grid>
</Border>
</Grid>
</Grid>
</Canvas>
</Viewbox>
</Grid>
</Window>

View File

@@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace
{
/// <summary>
/// MainWindow2.xaml 的交互逻辑
/// </summary>
public partial class MainWindow2 : Window
{
public MainWindow2()
{
InitializeComponent();
}
}
}

View File

@@ -122,44 +122,47 @@ namespace 电子展板.Models
/// 转换成JSON字符串
/// </summary>
/// <returns></returns>
public string ToJson()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("{");
//得到所有的Property
var properties = GetType().GetProperties();
for (int i = 0; i < properties.Length; i++)
{
var property = properties[i];
string endChar = ",";
if (i == properties.Length - 1)
{
endChar = "";
}
var comment = property.GetCustomAttributes(typeof(CommentAttribute), false).FirstOrDefault() as CommentAttribute;
string commentText = "";
if (comment != null)
{
commentText = $" /* {comment.Comment} */";
}
string propertyName = property.Name;
var value = property.GetValue(this, null);
if (value != null)
{
var valueType = value.GetType();
if (valueType == typeof(string))
{
sb.AppendLine($" \"{propertyName}\":\"{value}\"{endChar}{commentText}");
}
else
{
sb.AppendLine($" \"{propertyName}\":{value}{endChar}{commentText}");
}
}
}
sb.AppendLine("}");
return sb.ToString();
}
//public string ToJson()
//{
// StringBuilder sb = new StringBuilder();
// sb.AppendLine("{");
// //得到所有的Property
// var properties = GetType().GetProperties();
// for (int i = 0; i < properties.Length; i++)
// {
// var property = properties[i];
// string endChar = ",";
// if (i == properties.Length - 1)
// {
// endChar = "";
// }
// var comment = property.GetCustomAttributes(typeof(CommentAttribute), false).FirstOrDefault() as CommentAttribute;
// string commentText = "";
// if (comment != null)
// {
// commentText = $" /* {comment.Comment} */";
// }
// string propertyName = property.Name;
// var value = property.GetValue(this, null);
// if (value != null)
// {
// var valueType = value.GetType();
// if (valueType == typeof(string))
// {
// string value1 = (string)value;
// value1 = value1.Replace("\"", "\\\"");
// value1 = value1.Replace("\r\n", "\\r\\n");
// sb.AppendLine($" \"{propertyName}\":\"{value1}\"{endChar}{commentText}");
// }
// else
// {
// sb.AppendLine($" \"{propertyName}\":{value}{endChar}{commentText}");
// }
// }
// }
// sb.AppendLine("}");
// return sb.ToString();
//}
}

View File

@@ -1,142 +0,0 @@
using System;
using System.ComponentModel;
using System.IO;
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 MainWindow2ViewModel : ViewModelBase
{
private Window window;
public DelegateCommand<Window> LoadedCommand { get; set; }
public DelegateCommand<CancelEventArgs> WindowClosingCommand { get; set; }
public ImageSource Image1 { get; set; }
public ImageSource Image2 { get; set; }
public ImageSource Image3 { get; set; }
public ImageSource Image4 { get; set; }
public MainWindow2ViewModel()
{
LoadedCommand = new DelegateCommand<Window>(Loaded);
WindowClosingCommand = new DelegateCommand<CancelEventArgs>(WindowClosing);
EventBus.Instance.Subscribe(this, "save", ReloadImage);
InitImage();
}
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;
}
}
private void Loaded(Window window)
{
this.window = window;
Screen[] screens = Screen.AllScreens;
if (screens.Length > 1)
{
int screenIndex = 1;
this.window.Left = (int)(Screen.AllScreens[screenIndex].Bounds.Left / GetDpiScaleX());
this.window.Top = (int)(Screen.AllScreens[screenIndex].Bounds.Top / GetDpiScaleX());
this.window.Width = (int)(Screen.AllScreens[screenIndex].Bounds.Width / GetDpiScaleX());
this.window.Height = (int)(Screen.AllScreens[screenIndex].Bounds.Height / GetDpiScaleX());
}
else
{
window.Close();
}
}
/// <summary>
/// 界面关闭时
/// </summary>
public void WindowClosing(CancelEventArgs args)
{
GlobalVariable.WebServer?.Stop();
GlobalVariable.WebServer?.Dispose();
GlobalVariable.WebServer = null;
Screen[] screens = Screen.AllScreens;
if (screens.Length > 1)
{
Environment.Exit(0);
}
}
public double GetDpiScaleX()
{
return VisualTreeHelper.GetDpi(this.window).DpiScaleX;
}
}
}

View File

@@ -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;
}
}
}
}

View File

@@ -15,12 +15,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<!--<PackageReference Include="Costura.Fody" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>-->
</ItemGroup>
<ItemGroup>
<Reference Include="System.Windows.Forms" />