Chr
2024-08-23 12acdf14fcddae8d16e00b7b981559da67ce60ea
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
197
198
199
<Window x:Class="PdmAlert.MainWindow"
        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:local="clr-namespace:PdmAlert"
        mc:Ignorable="d"
        WindowStyle="None"
        Topmost="True"
        ResizeMode="NoResize"
        WindowStartupLocation="Manual"
        Loaded="Window_Loaded"
        Deactivated="Window_Deactivated"
        ShowInTaskbar="False"
        Title="MainWindow" Height="600" Width="400">
    <Window.Resources>
        <ResourceDictionary>
            <FontFamily x:Key="iconfont">
                /PdmAlert;component/Icon/#iconfont
            </FontFamily>
            <Brush x:Key="MainBorder">#0d4d84</Brush>
            <Brush x:Key="MainMenu">#1d6eb2</Brush>
            <Brush x:Key="ChildBorder">#3692e1</Brush>
            <Brush x:Key="MainStatusBar">#1d6eb2</Brush>
 
            <Brush x:Key="SecondaryImportant">Orange</Brush>
            <Brush x:Key="Important">#e17933</Brush>
            <Brush x:Key="ImportantFont">#FFF</Brush>
 
 
            <Brush x:Key="ButtonColor">#103156</Brush>
            <Brush x:Key="ButtonSelected">#02579E</Brush>
            <Brush x:Key="ButtonFont">White</Brush>
            <Brush x:Key="ButtonFontSelected">White</Brush>
 
            <Style x:Key="WindowButton" TargetType="Button">
                <Setter Property="FontFamily" Value="{StaticResource iconfont}"/>
                <Setter Property="Background" Value="Transparent"/>
                <Setter Property="FontWeight" Value="SemiBold"/>
                <Setter Property="Foreground" Value="Black"/>
                <Setter Property="Width" Value="50"/>
                <Setter Property="FontSize" Value="30"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="BorderBrush" Value="Transparent"/>
 
 
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Border x:Name="border" Width="{TemplateBinding Width}" Background="{TemplateBinding Background}" 
                        BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0">
                                <Label x:Name="label" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                           HorizontalContentAlignment="Center" VerticalContentAlignment="Center" 
                           Foreground="{TemplateBinding Foreground}"
                                   Content="{TemplateBinding Content}"/>
                            </Border>
 
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="border" Property="Background" Value="Gray"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
 
            <Style x:Key="WindowCloseButton" BasedOn="{StaticResource WindowButton}" TargetType="Button">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Border x:Name="border" Width="{TemplateBinding Width}" Background="{TemplateBinding Background}" 
            BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0">
                                <Label x:Name="label" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
               HorizontalContentAlignment="Center" VerticalContentAlignment="Center" 
               Foreground="{TemplateBinding Foreground}"
                       Content="{TemplateBinding Content}"/>
                            </Border>
 
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="border" Property="Background" Value="Red"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
 
            <Style x:Key="ChildWindowButton" BasedOn="{StaticResource WindowButton}" TargetType="Button">
                <Setter Property="FontSize" Value="15"/>
                <Setter Property="Width" Value="30"/>
                <Setter Property="Background" Value="{StaticResource ChildBorder}"/>
            </Style>
 
            <Style x:Key="ChildWindowCloseButton" BasedOn="{StaticResource ChildWindowButton}" TargetType="Button">
 
            </Style>
 
            <Style x:Key="LinkButton" TargetType="{x:Type Button}" >
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ButtonBase}">
                            <ContentPresenter x:Name="buttonContent" TextBlock.FontSize="{TemplateBinding FontSize}" 
                        TextBlock.FontFamily="{StaticResource iconfont}" 
                        TextBlock.Foreground="{StaticResource ChildBorder}" 
                        Margin="0,0,5,0"
                        VerticalAlignment="Center" 
                        HorizontalAlignment="Center"
                        Content="{TemplateBinding Content}"/>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="buttonContent" Property="TextBlock.Foreground" Value="Purple"/>
                                    <Setter TargetName="buttonContent" Property="Cursor" Value="Hand"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </Window.Resources>
    <Border BorderBrush="Black" BorderThickness="1">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Border Grid.Row="0" Background="LightGray">
                <DockPanel LastChildFill="True">
                    <Button DockPanel.Dock="Right" Style="{StaticResource WindowCloseButton}" Click="Hide_Click" ToolTip="最小化">&#xe67a;</Button>
                    <Button DockPanel.Dock="Right" Style="{StaticResource WindowButton}" Click="SwitchUser_Click" ToolTip="切换用户">&#xe6ed;</Button>
                    <Button DockPanel.Dock="Right" Style="{StaticResource WindowButton}" Click="Refresh_Click" BorderBrush="Black" ToolTip="刷新">&#xe600;</Button>
                    <Label Content="{Binding userInfo}" FontSize="20" VerticalContentAlignment="Center"/>
                </DockPanel>
            </Border>
 
            <AdornerDecorator Grid.Row="1">
                <Grid x:Name="mainContent" >
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <DockPanel Grid.Row="0" LastChildFill="True" HorizontalAlignment="Stretch" >
                        <Button DockPanel.Dock="Right" Margin="0,0,20,0" FontSize="16" Style="{StaticResource LinkButton}" Click="ReadAll_Click">全部已读</Button>
                        <Label DockPanel.Dock="Left" FontSize="16" Content="{Binding messageTitle}"/>
                    </DockPanel>
 
                    <ListView BorderThickness="0,1,0,1" Grid.Row="1" ItemsSource="{Binding messages}">
                        <ListView.ItemContainerStyle>
                            <Style TargetType="{x:Type ListViewItem}">
                                <Setter Property="Focusable" Value="False"/>
                                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                            </Style>
                        </ListView.ItemContainerStyle>
 
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <DockPanel LastChildFill="True">
                                    <Button DockPanel.Dock="Right" FontSize="16" Margin="0,0,15,0" 
                                        DataContext="{Binding}"
                                        Click="SingleRead_Click"
                                        Style="{StaticResource LinkButton}">已读</Button>
                                    <StackPanel DockPanel.Dock="Right">
                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
                                            <Label FontSize="18" FontWeight="Bold" Content="{Binding titile}"/>
                                            <Label FontSize="18" FontWeight="Bold" Content="{Binding sendTime}"/>
                                        </StackPanel>
                                        <Label FontSize="16" Content="{Binding msgContent}"/>
                                    </StackPanel>
                                </DockPanel>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                    <StatusBar Grid.Row="2" VerticalAlignment="Center">
                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                            <Ellipse Width="12" Height="12"  VerticalAlignment="Center">
                                <Ellipse.Style>
                                    <Style TargetType="Ellipse">
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding socketStatus}" Value="Error">
                                                <Setter Property="Shape.Fill" Value="Red"/>
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding socketStatus}" Value="Success">
                                                <Setter Property="Shape.Fill" Value="Green"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Ellipse.Style>
                            </Ellipse>
                            <Label FontSize="12" Content="{Binding statusMessage}"/>
                        </StackPanel>
                    </StatusBar>
                </Grid>
            </AdornerDecorator>
        </Grid>
    </Border>
</Window>