Browse Source

1

样式分支
fyf 2 years ago
parent
commit
84635a1427
2 changed files with 57 additions and 32 deletions
  1. +1
    -0
      BPASmartClient/MainWindow.xaml
  2. +56
    -32
      BPASmartClient/MainWindow.xaml.cs

+ 1
- 0
BPASmartClient/MainWindow.xaml View File

@@ -96,6 +96,7 @@
<control:DateTimeUI Margin="10,0,10,0" VerticalAlignment="Center"></control:DateTimeUI> <control:DateTimeUI Margin="10,0,10,0" VerticalAlignment="Center"></control:DateTimeUI>
<Border Style="{DynamicResource border竖线}" /> <Border Style="{DynamicResource border竖线}" />
<Button x:Name="ButClose" Grid.Column="4" Margin="10,0,20,0" Style="{DynamicResource CommonBtn_返回}" VerticalAlignment="Center" ToolTip="退出程序" Cursor="Hand" Content="退出"/> <Button x:Name="ButClose" Grid.Column="4" Margin="10,0,20,0" Style="{DynamicResource CommonBtn_返回}" VerticalAlignment="Center" ToolTip="退出程序" Cursor="Hand" Content="退出"/>

</StackPanel> </StackPanel>
</Grid> </Grid>




+ 56
- 32
BPASmartClient/MainWindow.xaml.cs View File

@@ -35,14 +35,13 @@ namespace BPASmartClient
{ {
InitializeComponent(); InitializeComponent();
Initialize(); Initialize();
ThreadManage.GetInstance().Start(new Action(() =>
{
new MainConsole().Start();
}), "启动主控制台");

} }


public void Initialize()
#region 私有
/// <summary>
/// 初始化
/// </summary>
private void Initialize()
{ {
this.ButClose.Click += (o,e) => { this.Close(); }; this.ButClose.Click += (o,e) => { this.Close(); };
this.br.MouseLeftButtonDown += (o,e) => this.br.MouseLeftButtonDown += (o,e) =>
@@ -56,20 +55,16 @@ namespace BPASmartClient
} }
this.DragMove(); this.DragMove();
}; };
MenuItem_Click(new MenuItem() {Tag= "LogView",Header="日志监视" },null);
}

private void Button_Click(object sender, RoutedEventArgs e)
{
//new Demo_MakeCoffeeEvent() { Id = 1 }.Publish();
//new DRCoffee_MakeCoffeeEvent() { Id = 1, DrinkCode= DrCoffeeDrinksCode.两杯意式浓缩 }.Publish();
//new DRCoffee_CoffeeCommCmdEvent() { Id = 1,CommCmd = DrCoffeeCommCmd.冲煮系统快速冲洗指令}.Publish();
MenuItem_Click(new MenuItem() { Tag = "LogView",Header = "日志监视" },null);


MorkOrderPush morkOrderPush = new MorkOrderPush() { DeviceId=2};
var temp=BPAPackage.Make(morkOrderPush, 12, BPA.Message.Enum.DeviceClientType.MORKS);
Plugin.GetInstance().GetPlugin<MQTTMgr>().Publish("DOWN/MORKS/ORDER/12", temp.Serialize());
ThreadManage.GetInstance().Start(new Action(() =>
{
new MainConsole().Start();
}),"启动主控制台");
} }
#endregion


#region Click
/// <summary> /// <summary>
/// 菜单切换栏 /// 菜单切换栏
/// </summary> /// </summary>
@@ -80,31 +75,57 @@ namespace BPASmartClient
if (sender is MenuItem) if (sender is MenuItem)
{ {
Type type = Type.GetType($"BPASmartClient.Control.{(sender as MenuItem).Tag?.ToString()}"); Type type = Type.GetType($"BPASmartClient.Control.{(sender as MenuItem).Tag?.ToString()}");
if (type == null)
{
switch ((sender as MenuItem).Tag?.ToString())
{
case "Close":
this.Close();
break;
case "IOT":
BrowserHelper.OpenDefaultBrowserUrl("http://iot.black-pa.com");
break;
}
return;
}
if (type == null){MenuClick((sender as MenuItem).Tag?.ToString());return; }
ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes); ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes);
contentRegion.Content = (FrameworkElement)cti.Invoke(null); contentRegion.Content = (FrameworkElement)cti.Invoke(null);
Title.Text = (sender as MenuItem).Header?.ToString()+"界面";
Title.Text = (sender as MenuItem).Header?.ToString() + "界面";
}
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx($"BPASmartClient 中引发错误,MainWindow.xaml.cs 类MenuItem_Click(),描述:[{ex.Message}]");
}
}
#endregion

#region 公用
/// <summary>
/// 菜单点击
/// </summary>
/// <param name="name"></param>
public void MenuClick(string name)
{
try
{
switch (name)
{
case "Close":
this.Close();
break;
case "IOT":
BrowserHelper.OpenDefaultBrowserUrl("http://iot.black-pa.com");
break;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageLog.GetInstance.ShowEx($"BPASmartClient 中引发错误,MainWindow.xaml.cs 类,描述:[{ex.Message}]");
MessageLog.GetInstance.ShowEx($"BPASmartClient 中引发错误,MainWindow.xaml.cs 类MenuClick(),描述:[{ex.Message}]");
} }
} }
#endregion




#region 临时测试代码
private void Button_Click(object sender,RoutedEventArgs e)
{
//new Demo_MakeCoffeeEvent() { Id = 1 }.Publish();
//new DRCoffee_MakeCoffeeEvent() { Id = 1, DrinkCode= DrCoffeeDrinksCode.两杯意式浓缩 }.Publish();
//new DRCoffee_CoffeeCommCmdEvent() { Id = 1,CommCmd = DrCoffeeCommCmd.冲煮系统快速冲洗指令}.Publish();

MorkOrderPush morkOrderPush = new MorkOrderPush() { DeviceId = 2 };
var temp = BPAPackage.Make(morkOrderPush,12,BPA.Message.Enum.DeviceClientType.MORKS);
Plugin.GetInstance().GetPlugin<MQTTMgr>().Publish("DOWN/MORKS/ORDER/12",temp.Serialize());
}


private void Button_Click_1(object sender,RoutedEventArgs e) private void Button_Click_1(object sender,RoutedEventArgs e)
{ {
@@ -113,5 +134,8 @@ namespace BPASmartClient
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn,this,"我是标题","我是消息内容!我是消息内容!我是消息内容!我是消息内容!"); NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn,this,"我是标题","我是消息内容!我是消息内容!我是消息内容!我是消息内容!");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success,this,"我是标题","我是消息内容!我是消息内容!我是消息内容!我是消息内容!"); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success,this,"我是标题","我是消息内容!我是消息内容!我是消息内容!我是消息内容!");
} }
#endregion


} }
} }

Loading…
Cancel
Save