diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj index 6060394d..883716d6 100644 --- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj +++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj @@ -21,6 +21,8 @@ + + @@ -229,6 +231,8 @@ + + diff --git a/BPASmartClient.CustomResource/Converters/OpacityConverter .cs b/BPASmartClient.CustomResource/Converters/OpacityConverter .cs new file mode 100644 index 00000000..83623f91 --- /dev/null +++ b/BPASmartClient.CustomResource/Converters/OpacityConverter .cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace BPASmartClient.CustomResource.Converters +{ + public class OpacityConverter: IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + double returnValue = 0.2; + if (value != null && value is bool statusValue) + { + switch (statusValue) + { + case true: + returnValue = 1; + break; + case false: + returnValue = 0.2; + break; + + } + } + return returnValue; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/BPASmartClient.CustomResource/Fonts/MT/iconfont.ttf b/BPASmartClient.CustomResource/Fonts/MT/iconfont.ttf new file mode 100644 index 00000000..8281b8a5 Binary files /dev/null and b/BPASmartClient.CustomResource/Fonts/MT/iconfont.ttf differ diff --git a/BPASmartClient.CustomResource/Fonts/naicha.ttf b/BPASmartClient.CustomResource/Fonts/naicha.ttf new file mode 100644 index 00000000..a790bcd4 Binary files /dev/null and b/BPASmartClient.CustomResource/Fonts/naicha.ttf differ diff --git a/BPASmartClient.CustomResource/Image/背景矢量/beijing.png b/BPASmartClient.CustomResource/Image/背景矢量/beijing.png new file mode 100644 index 00000000..15d57a81 Binary files /dev/null and b/BPASmartClient.CustomResource/Image/背景矢量/beijing.png differ diff --git a/BPASmartClient.CustomResource/Themes/MyStyle.xaml b/BPASmartClient.CustomResource/Themes/MyStyle.xaml index 90c53805..6dcc33ee 100644 --- a/BPASmartClient.CustomResource/Themes/MyStyle.xaml +++ b/BPASmartClient.CustomResource/Themes/MyStyle.xaml @@ -830,6 +830,16 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.MilkWithTea/App.xaml.cs b/BPASmartClient.MilkWithTea/App.xaml.cs new file mode 100644 index 00000000..42734460 --- /dev/null +++ b/BPASmartClient.MilkWithTea/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace BPASmartClient.MilkWithTea +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/BPASmartClient.MilkWithTea/AssemblyInfo.cs b/BPASmartClient.MilkWithTea/AssemblyInfo.cs new file mode 100644 index 00000000..8b5504ec --- /dev/null +++ b/BPASmartClient.MilkWithTea/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/BPASmartClient.MilkWithTea/BPASmartClient.MilkWithTea.csproj b/BPASmartClient.MilkWithTea/BPASmartClient.MilkWithTea.csproj new file mode 100644 index 00000000..b7de3156 --- /dev/null +++ b/BPASmartClient.MilkWithTea/BPASmartClient.MilkWithTea.csproj @@ -0,0 +1,27 @@ + + + + WinExe + net6.0-windows + enable + true + + + + + + + + + + + + + + + + PreserveNewest + + + + diff --git a/BPASmartClient.MilkWithTea/Control/CircularProgressBar.xaml b/BPASmartClient.MilkWithTea/Control/CircularProgressBar.xaml new file mode 100644 index 00000000..2b27ca59 --- /dev/null +++ b/BPASmartClient.MilkWithTea/Control/CircularProgressBar.xaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.MilkWithTea/Control/CircularProgressBar.xaml.cs b/BPASmartClient.MilkWithTea/Control/CircularProgressBar.xaml.cs new file mode 100644 index 00000000..953dcde6 --- /dev/null +++ b/BPASmartClient.MilkWithTea/Control/CircularProgressBar.xaml.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +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.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BPASmartClient.MilkWithTea.Control +{ + /// + /// CircularProgressBar.xaml 的交互逻辑 + /// + public partial class CircularProgressBar : UserControl + { + public CircularProgressBar() + { + InitializeComponent(); + UpdateValue(Percent * 3.6); + } + public double Percent + { + get { return (double)GetValue(PercentProperty); } + set + { + SetValue(PercentProperty, value); + UpdateValue(Percent * 3.6); + } + + } + + //public static DependencyProperty PercentProperty => percentProperty; + + // Using a DependencyProperty as the backing store for Percent. This enables animation, styling, binding, etc... + private static readonly DependencyProperty PercentProperty = + DependencyProperty.Register("Percent", typeof(double), typeof(CircularProgressBar), new PropertyMetadata(default(double), new PropertyChangedCallback(OnPropertyChanged))); + + + private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + CircularProgressBar _cycleProgess = d as CircularProgressBar; + _cycleProgess.UpdateValue(_cycleProgess.Percent * 3.6); + } + private void UpdateValue(double angle) + { + + if (angle > 360) return; + if (angle <= 0) return; + + int offset = 5; + if (angle > 359) angle = 359.8; + double radius = this.Width / 2 - offset; + if (radius < 0) return; + double b = radius * Math.Sin(angle * Math.PI / 180); + double x = radius + b; + double y = radius - radius * Math.Cos(angle * Math.PI / 180); + double startPositionX = radius + offset; + double startPositionY = offset; + + if (angle > 180) + { + + //string Data = string.Format("M {0} 0 A {0} {0} 0 1 1 {1} {2}", radius, Math.Round(x, 2), Math.Round(y, 2)); + string Data = string.Format("M {0} {1} A {2} {2} 0 1 1 {3} {4}", startPositionX, startPositionY, radius, Math.Round(x, 2) + offset, Math.Round(y, 2) + offset); + this.cyclePath.Data = Geometry.Parse(Data); + } + else + { + + //string Data = string.Format("M {0} 0 A {0} {0} 0 0 1 {1} {2}", radius, Math.Round(x,2), Math.Round(y, 2)); + + string Data = string.Format("M {0} {1} A {2} {2} 0 0 1 {3} {4}", startPositionX, startPositionY, radius, Math.Round(x, 2) + offset, Math.Round(y, 2) + offset); + + this.cyclePath.Data = Geometry.Parse(Data); + } + } + + } +} + diff --git a/BPASmartClient.MilkWithTea/DeviceInfo.xml b/BPASmartClient.MilkWithTea/DeviceInfo.xml new file mode 100644 index 00000000..5074e0f0 --- /dev/null +++ b/BPASmartClient.MilkWithTea/DeviceInfo.xml @@ -0,0 +1,86 @@ + + + + + + + + --> + + + + + 192.168.6.1 + 502 + M,M0.1,1;M,M1.0,8;M,M2.0,9;M,M8.0,4;M,M13.5,1;M,M16.0,7; + + + + + -->--> + + diff --git a/BPASmartClient.MilkWithTea/GLobal.cs b/BPASmartClient.MilkWithTea/GLobal.cs new file mode 100644 index 00000000..ac24bfe9 --- /dev/null +++ b/BPASmartClient.MilkWithTea/GLobal.cs @@ -0,0 +1,57 @@ +using Model; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MilkWithTea +{ + public class GLobal + { + //路径 + public static string recipePath = string.Empty; + public static string posionPath = string.Empty; + + public static bool makeEnable = false; + + public static ObservableCollection MaterialRecipes { get; set; } = new ObservableCollection(); + + + /// + /// 获取Json文件内容,转换成ObservableCollection + /// + /// + /// + /// + public static ObservableCollection GetJsonToT(string path) + { + if (!File.Exists(path)) + { + //创建该文件 + File.Create(path); + return default; + } + else + { + using (StreamReader recipeReader = new StreamReader(path))//读取json文件 + { + string datacache = ""; + string line; + while ((line = recipeReader.ReadLine()) != null) //循环将每一行数据拼接为一个完整的字符串 + { + datacache = datacache + line; + } + + var res = JsonConvert.DeserializeObject>(datacache); //将string转换为class类,从而达到json文件转换的目的 + if (res != null) + return res; + else return new ObservableCollection { }; + } + } + } + } +} diff --git a/BPASmartClient.MilkWithTea/MainWindow.xaml b/BPASmartClient.MilkWithTea/MainWindow.xaml new file mode 100644 index 00000000..174834ae --- /dev/null +++ b/BPASmartClient.MilkWithTea/MainWindow.xaml @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.MilkWithTea/MainWindow.xaml.cs b/BPASmartClient.MilkWithTea/MainWindow.xaml.cs new file mode 100644 index 00000000..091c776d --- /dev/null +++ b/BPASmartClient.MilkWithTea/MainWindow.xaml.cs @@ -0,0 +1,214 @@ +using BPASmartClient.Business; +using BPASmartClient.CustomResource.UserControls; +using BPASmartClient.CustomResource.UserControls.MessageShow; +using BPASmartClient.Device; +using BPASmartClient.Helper; +using BPASmartClient.IoT; +using BPASmartClient.Message; +using BPASmartClient.Peripheral; +using BPASmartClient.ViewModel; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +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.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BPASmartClient.MilkWithTea +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainConsole mainConsole; + public MainWindow() + { + InitializeComponent(); + + Initialize(); + + } + + + private void Initialize() + { + + ThreadManage.GetInstance().Start(new Action(() => + { + GetDevices(); + mainConsole = new MainConsole(); + mainConsole.Start(); + }), "启动主控制台", false); + + ActionManage.GetInstance.Register(new Action(() => + { + ThreadManage.GetInstance().Start(new Action(() => + { + try + { + DataVClient.GetInstance().Initialize(); + DataVClient.GetInstance().Start(); + } + catch (Exception ex) + { + MessageLog.GetInstance.ShowEx(ex.ToString()); + } + }), "启动主IoT", false); + }), "配置初始化完成Iot启动"); + + ActionManage.GetInstance.Register(new Action((o) => + { + App.Current.Dispatcher.Invoke(new Action(() => + { + if (o is IOTCommandModel iot) + { + switch (iot.CommandName) + { + case 0://控制类 + if (iot.CommandValue != null && iot.CommandValue.Count > 0) + { + switch (iot.CommandValue.Keys.ToList()[0]) + { + case "程序启动": + //mainConsole.Start(); + break; + //mainConsole.Stop(); + case "程序停止": + break; + case "程序复位": + //mainConsole.Stop(); + //mainConsole.Start(); + break; + default: + break; + } + NoticeDemoViewModel.OpenMsg(EnumPromptType.Info, MainViewModel.GetInstance().window, "大屏控制", iot.CommandValue.Keys.ToList()[0]); + } + break; + case 1://设置类 + break; + case 2://通知类 + if (iot.CommandValue != null && iot.CommandValue.ContainsKey("text")) + { + NoticeDemoViewModel.OpenMsg(EnumPromptType.Info, MainViewModel.GetInstance().window, "大屏通知", iot.CommandValue["text"]); + } + break; + default: + break; + } + } + })); + }), "IotBroadcast"); + NavButton_Click(new Button() { Tag = "MainControlView" },null); + + } + + /// + /// 获取设备集合 + /// + private void GetDevices() + { + //List IDevices = new List(); + //List IPeripherals = new List(); + + DirectoryInfo directoryInfo = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); + var files = directoryInfo.GetFiles().Where(p => p.FullName.Contains("BPASmartClient.") && p.FullName.Contains("dll")).ToList(); + List fileList = new List(); + + var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + var dlls = assemblies?.Where(p => p.FullName.Contains("BPASmartClient.")).ToList(); + List dllList = new List(); + + if (files != null) + { + foreach (var item in files) + { + var res = System.IO.Path.GetFileNameWithoutExtension(item.FullName); + if (res != null && res.Length > 0 && res.Contains(".") && !res.Contains("dll")) fileList.Add(res); + } + } + + if (dlls != null) + { + dlls.ForEach((item) => + { + item.GetTypes().ToList().ForEach((type) => + { + if (type.GetInterfaces().Contains(typeof(IDevice))) + { + if (!type.FullName.Contains("BaseDevice")) ShopDeviceConfigViewModel.IDevices.Add(type.FullName); + } + else if (type.GetInterfaces().Contains(typeof(IPeripheral))) + { + if (!type.FullName.Contains("BasePeripheral")) ShopDeviceConfigViewModel.IPeripherals.Add(type.FullName); + } + }); + + dllList.Add(System.IO.Path.GetFileNameWithoutExtension(item.EscapedCodeBase)); + }); + } + + dllList.ForEach((item) => { if (fileList.Contains(item)) fileList.Remove(item); }); + + fileList.ForEach((item) => + { + Assembly.Load(item).GetTypes().ToList().ForEach((type) => + { + if (type.GetInterfaces().Contains(typeof(IDevice))) + { + if (!type.FullName.Contains("BaseDevice")) ShopDeviceConfigViewModel.IDevices.Add(type.FullName); + } + else if (type.GetInterfaces().Contains(typeof(IPeripheral))) + { + if (!type.FullName.Contains("BasePeripheral")) ShopDeviceConfigViewModel.IPeripherals.Add(type.FullName); + } + }); + }); + + + } + + + + private void Grid_MouseDown(object sender, MouseButtonEventArgs e) + { + this.DragMove(); + } + + + + private void CloseButton_Click(object sender, RoutedEventArgs e) + { + this.Close(); + } + + + private void NavButton_Click(object sender, RoutedEventArgs e) + { + try + { + if (sender is Button bt ) + { + Type type = Type.GetType($"BPASmartClient.MilkWithTea.View.{bt.Tag?.ToString()}"); + ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes); + contentRegion.Content = (FrameworkElement)cti.Invoke(null); + } + } + catch (Exception ex) + { + MessageLog.GetInstance.ShowEx($"BPASmartClient 中引发错误,MainWindow.xaml.cs 类MenuItem_Click(),描述:[{ex.Message}]"); + } + } + } +} diff --git a/BPASmartClient.MilkWithTea/View/LocalConfigureView.xaml b/BPASmartClient.MilkWithTea/View/LocalConfigureView.xaml new file mode 100644 index 00000000..a8fbca5d --- /dev/null +++ b/BPASmartClient.MilkWithTea/View/LocalConfigureView.xaml @@ -0,0 +1,299 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.MilkWithTea/View/MainControlView.xaml.cs b/BPASmartClient.MilkWithTea/View/MainControlView.xaml.cs new file mode 100644 index 00000000..8593362a --- /dev/null +++ b/BPASmartClient.MilkWithTea/View/MainControlView.xaml.cs @@ -0,0 +1,38 @@ +using BPASmartClient.MilkWithTea.ViewModel; +using Model; +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.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BPASmartClient.MilkWithTea.View +{ + /// + /// MainControlView.xaml 的交互逻辑 + /// + public partial class MainControlView : UserControl + { + public MainControlView() + { + InitializeComponent(); + } + + private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if((sender as ListBox).SelectedItem is LocalTeaWithMilkConfig config) + { + recipeList.ItemsSource = config.materialRecipes; + } + } + } +} diff --git a/BPASmartClient.MilkWithTea/View/MessageLogInfo.xaml b/BPASmartClient.MilkWithTea/View/MessageLogInfo.xaml new file mode 100644 index 00000000..ca14d7d9 --- /dev/null +++ b/BPASmartClient.MilkWithTea/View/MessageLogInfo.xaml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.MilkWithTea/View/MessageLogInfo.xaml.cs b/BPASmartClient.MilkWithTea/View/MessageLogInfo.xaml.cs new file mode 100644 index 00000000..771aac6a --- /dev/null +++ b/BPASmartClient.MilkWithTea/View/MessageLogInfo.xaml.cs @@ -0,0 +1,30 @@ +using BPASmartClient.ViewModel; +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.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BPASmartClient.MilkWithTea.View +{ + /// + /// MessageLogInfo.xaml 的交互逻辑 + /// + public partial class MessageLogInfo : UserControl + { + public MessageLogInfo() + { + InitializeComponent(); + this.DataContext = LogViewModel.GetInstance(); + } + } +} diff --git a/BPASmartClient.MilkWithTea/View/ParameterSetting.xaml b/BPASmartClient.MilkWithTea/View/ParameterSetting.xaml new file mode 100644 index 00000000..b3eb4be9 --- /dev/null +++ b/BPASmartClient.MilkWithTea/View/ParameterSetting.xaml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +