forked from Edge-Sweets/APC-Smart-UPS-Manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml
196 lines (190 loc) · 10 KB
/
MainWindow.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<Window x:Class="APCUPS.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:local="clr-namespace:APCUPS"
Title="UPS Manager" Height="825" Width="500" Foreground="#FFECAD25" Icon="Images/battery.png">
<Window.Resources>
<Style TargetType="Label">
<Setter Property="FontSize" Value="18" />
<Setter Property="Width" Value="200" />
<Setter Property="Foreground" Value="#FFECAD25" />
</Style>
<Style TargetType="Button">
<Setter Property="FontSize" Value="18" />
<Setter Property="Width" Value="200" />
<Setter Property="Foreground" Value="#FFECAD25" />
<Setter Property="Background" Value="#666666" />
<Setter Property="BorderThickness" Value="2" />
<Setter Property="BorderBrush" Value="#999999" />
</Style>
</Window.Resources>
<Window.Background>
<LinearGradientBrush EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop Color="#FF4B4B4B"
Offset="0" />
<GradientStop Color="#FF484848"
Offset="1.5" />
</LinearGradientBrush>
</Window.Background>
<Grid>
<Grid.Resources>
<local:OpenWindowCommand
x:Key="WindowCommand" />
</Grid.Resources>
<Border HorizontalAlignment="Stretch"
Margin="5,5,5,5"
BorderThickness="1,1,1,1"
BorderBrush="#FF997137">
<Border.Effect>
<DropShadowEffect Color="#FF747474" />
</Border.Effect>
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop Color="#FF4B4B4B"
Offset="0" />
<GradientStop Color="#FF484848"
Offset="1.5" />
</LinearGradientBrush>
</Border.Background>
</Border>
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
ToolTipText="UPS Manager"
IconSource="/Images/battery.ico"
DoubleClickCommand="{StaticResource WindowCommand}"
DoubleClickCommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
Visibility="Visible">
<tb:TaskbarIcon.ContextMenu>
<ContextMenu>
<MenuItem Header="Show UPS Manager"
Command="{local:ShowUPSWindow}"
CommandParameter="{Binding}">
<MenuItem.Icon>
<Image Width="16"
Height="16"
Source="/Images/Add.png" />
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Header=" Hide UPS Maanager"
Command="{local:HideUPSWindow}"
CommandParameter="{Binding}">
<MenuItem.Icon>
<Image Width="16"
Height="16"
Source="/Images/Remove.png" />
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Header=" Exit UPS Manager"
Command="{local:CloseUPSManager}"
CommandParameter="{Binding}">
<MenuItem.Icon>
<Image Width="16"
Height="16"
Source="/Images/Close.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</tb:TaskbarIcon.ContextMenu>
</tb:TaskbarIcon>
<StackPanel>
<GroupBox Header="Status" Foreground="#FFECAD25" Name="gbStatus" FontSize="24" Margin="10">
<StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="Model" />
<Label Name="txtModel" Content="{Binding Model}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="Power Type" />
<Label Name="txtPowerType" Content="{Binding PowerType}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="Battery Level" />
<Label Name="txtBatteryLevel" Content="{Binding BatteryLevel}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="Battery Alarm" />
<Label Name="txtBatteryAlarm" Content="{Binding AlarmDelay}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="Battery Voltage" />
<Label Name="txtBatteryVoltage" Content="{Binding BatteryVoltage}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="Input Voltage" />
<Label Name="txtInputVoltage" Content="{Binding InputVoltage}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="Output Voltage" />
<Label Name="txtOutputVoltage" Content="{Binding OutputVoltage}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="UPS Shutdown Delay" />
<Label Name="txtShutdownDelay" Content="{Binding ShutdownDelay}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0" x:Name="stackSettings">
<StackPanel>
<Label Content="Computer Shutdown" />
<Label Content="Delay (seconds)" HorizontalAlignment="Center" Padding="5,0,0,0" Margin="0,-5,0,0" />
</StackPanel>
<Label Name="ComputerShutdownDelay" Content="{Binding ComputerShutdownDelay}" />
</StackPanel>
</StackPanel>
</GroupBox>
<StackPanel Orientation="Horizontal" Margin="10,20,0,0">
<StackPanel>
<Label Content="Change Shutdown Delay" Width="210" />
<ComboBox x:Name="cbShutdownDelay" Width="200">
<ComboBoxItem>060</ComboBoxItem>
<ComboBoxItem>180</ComboBoxItem>
<ComboBoxItem>300</ComboBoxItem>
<ComboBoxItem>600</ComboBoxItem>
</ComboBox>
</StackPanel>
<Button Content="Change Delay" Width="200" Height="35" FontSize="20" Margin="50,10,0,0" Click="Button_Click" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10,0,0,0">
<StackPanel>
<Label Content="Change Battery Alarm" Width="210" />
<ComboBox x:Name="cbBatteryAlarm" Width="200">
<ComboBoxItem>5 seconds</ComboBoxItem>
<ComboBoxItem>30 seconds</ComboBoxItem>
<ComboBoxItem>low battery only</ComboBoxItem>
<ComboBoxItem>disabled</ComboBoxItem>
</ComboBox>
</StackPanel>
<Button Content="Change Alarm" Width="200" Height="35" FontSize="20" Margin="50,10,0,0" Click="Button_Click_1" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10,0,0,0">
<StackPanel>
<Label Content="Change Serial Port" Width="210" />
<ComboBox x:Name="cbCOMPorts" Width="200">
</ComboBox>
</StackPanel>
<Button Content="Change Port" Width="200" Height="35" FontSize="20" Margin="50,10,0,0" x:Name="btnCOMPort" Click="btnCOMPort_Click" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10,10,0,0">
<StackPanel>
<Label Content="Change Computer Shutdown Delay (seconds)" Width="375" />
<TextBox x:Name="txtComputerShutdownDelay" Height="35" Width="275" HorizontalAlignment="Left" Margin="10,0,0,0" />
<Button Content="Change Delay" Width="200" Height="35" FontSize="20" Margin="10,10,0,0" Click="Button_Click_2" HorizontalAlignment="Left" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10,10,0,0">
<StackPanel>
<Label Content="Send Command" Width="375" />
<TextBox x:Name="txtCommand" Height="35" Width="275" HorizontalAlignment="Left" Margin="10,0,0,0" />
<Button x:Name="btnSendCommand" Content="Send Command" Width="200" Height="35" FontSize="20" Margin="10,10,0,0" Click="btnSendCommand_Click" HorizontalAlignment="Left" />
<StackPanel Orientation="Horizontal">
<Label Content="Command Result: " ></Label>
<Label x:Name="txtCommandResult"></Label>
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
</Window>