底部添加系统状态栏信息
This commit is contained in:
parent
6821ac37df
commit
83fbf15916
35
MonitoringTechnology/Base/StateBackConvert.cs
Normal file
35
MonitoringTechnology/Base/StateBackConvert.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace MonitoringTechnology.Base
|
||||
{
|
||||
public class StateBackConvert : IValueConverter
|
||||
{
|
||||
public static object ConvertObject;
|
||||
|
||||
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
Brush background = null;
|
||||
if ((bool)value == true)
|
||||
{
|
||||
background = new SolidColorBrush(Color.FromRgb(0, 255, 127));
|
||||
}
|
||||
else if ((bool)value == false)
|
||||
{
|
||||
background = new SolidColorBrush(Color.FromRgb(255, 0, 0));
|
||||
}
|
||||
return background;
|
||||
}
|
||||
|
||||
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -48,9 +48,10 @@
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
@ -63,6 +64,7 @@
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid MouseLeftButtonDown="Border_MouseLeftButtonDown">
|
||||
<Border Width="55" Height="50" Margin="10,0,20,0" HorizontalAlignment="Left" >
|
||||
@ -101,6 +103,14 @@
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!--通信状态-->
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20,0" >
|
||||
<TextBlock Text="通信状态:" FontSize="15" Foreground="#48D1CC"/>
|
||||
<TextBlock Text="{Binding IsConnection}" Margin="20,2,6,0" FontSize="13" Foreground="#48D1CC"/>
|
||||
<Border Background="{Binding Brush}" Width="10" Height="10" CornerRadius="10" Margin="6,0"/>
|
||||
<TextBlock Text="{Binding LYDevice}" FontSize="15" Foreground="#48D1CC" Margin="6,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<ContentControl Grid.Row="1" Content="{Binding MainContent}"/>
|
||||
|
||||
</Grid>
|
||||
|
||||
@ -154,6 +154,7 @@
|
||||
<Compile Include="Base\Bool2VisibilityConverter.cs" />
|
||||
<Compile Include="Base\CommandBase.cs" />
|
||||
<Compile Include="Base\NotifyPropertyBase.cs" />
|
||||
<Compile Include="Base\StateBackConvert.cs" />
|
||||
<Compile Include="Ble\BleDevice.cs" />
|
||||
<Compile Include="Ble\BleExtensions.cs" />
|
||||
<Compile Include="Ble\BleManager.cs" />
|
||||
|
||||
@ -7,11 +7,44 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace MonitoringTechnology.ViewModels
|
||||
{
|
||||
public class MainViewModel : NotifyPropertyBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前蓝牙设备是否已连接
|
||||
/// </summary>
|
||||
private string _isConnection;
|
||||
|
||||
public string IsConnection
|
||||
{
|
||||
get { return _isConnection; }
|
||||
set { _isConnection = value; this.RaisePropertyChanged(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 连接标志 -绿色(已连接) / 红色(未连接)
|
||||
/// </summary>
|
||||
private SolidColorBrush brush;
|
||||
|
||||
public SolidColorBrush Brush
|
||||
{
|
||||
get { return brush; }
|
||||
set { brush = value;this.RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 蓝牙名称
|
||||
/// </summary>
|
||||
private string _lYDevice;
|
||||
|
||||
public string LYDevice
|
||||
{
|
||||
get { return _lYDevice; }
|
||||
set { _lYDevice = value;this.RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private UIElement _mainContent;
|
||||
|
||||
@ -29,8 +62,20 @@ namespace MonitoringTechnology.ViewModels
|
||||
public MainViewModel()
|
||||
{
|
||||
TabChangedCommand = new CommandBase(OnTabChanged);
|
||||
|
||||
OnTabChanged("MonitoringTechnology.Views.FirstPageView");
|
||||
|
||||
///初始化底部系统状态信息
|
||||
if (SystemOperationView.isConnection)
|
||||
{
|
||||
this._isConnection = "已连接";
|
||||
this.brush = new SolidColorBrush(Color.FromRgb(0, 255, 127));
|
||||
}
|
||||
else
|
||||
{
|
||||
this._isConnection = "未连接";
|
||||
this.brush = new SolidColorBrush(Color.FromRgb(255, 0, 0));
|
||||
this._lYDevice = "";
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTabChanged(object obj)
|
||||
|
||||
@ -64,11 +64,11 @@
|
||||
<ScrollViewer VerticalScrollBarVisibility="Hidden">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="500"/>
|
||||
<RowDefinition Height="475"/>
|
||||
<RowDefinition Height="200"/>
|
||||
</Grid.RowDefinitions>
|
||||
<GroupBox Header="蓝牙搜索与连接" FontSize="15" Grid.Row="0" Margin="10,5,10,5">
|
||||
<Grid Margin="10,40,10,0" Height="440" VerticalAlignment="Top">
|
||||
<Grid Margin="10,35,10,0" Height="420" VerticalAlignment="Top">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
@ -182,14 +182,15 @@ namespace MonitoringTechnology.Views
|
||||
if (connected)
|
||||
{
|
||||
systemOperationViewModel.connectDevice = "断开连接";
|
||||
buttonConnect.Background = new SolidColorBrush(Color.FromRgb(199, 0, 6));
|
||||
buttonConnect.Foreground = new SolidColorBrush(Colors.White);
|
||||
MainWindow.mainViewModel.IsConnection = "已连接";
|
||||
MainWindow.mainViewModel.Brush = new SolidColorBrush(Color.FromRgb(0, 255, 127));//设置连接状态颜色-绿色
|
||||
MainWindow.mainViewModel.LYDevice = LYScanPage._bleDevice.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
systemOperationViewModel.connectDevice = "连接设备";
|
||||
buttonConnect.Background = new SolidColorBrush(Colors.LightGray);
|
||||
buttonConnect.Foreground = new SolidColorBrush(Colors.Black);
|
||||
MainWindow.mainViewModel.IsConnection = "未连接";
|
||||
MainWindow.mainViewModel.Brush = new SolidColorBrush(Color.FromRgb(255, 0, 0));//设置连接状态颜色-红色
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -429,8 +430,9 @@ namespace MonitoringTechnology.Views
|
||||
if (device.IsConnected == true)
|
||||
{
|
||||
systemOperationViewModel.connectDevice = "断开连接";
|
||||
buttonConnect.Background = new SolidColorBrush(Color.FromRgb(199, 0, 6));
|
||||
buttonConnect.Foreground = new SolidColorBrush(Colors.White);
|
||||
MainWindow.mainViewModel.IsConnection = "已连接";
|
||||
MainWindow.mainViewModel.Brush = new SolidColorBrush(Color.FromRgb(0, 255, 127));//设置连接状态颜色-绿色
|
||||
MainWindow.mainViewModel.LYDevice = device.Name;
|
||||
|
||||
if (isSending == true)//如果处于循环发送状态
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user