欢迎莅临 SUN WU GANG 的园子!!!

世上无难事,只畏有心人。有心之人,即立志之坚午也,志坚则不畏事之不成。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  470 随笔 :: 0 文章 :: 22 评论 :: 30万 阅读
< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5

XAML==>

复制代码
<Window x:Class="QueueSystem.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="MainWindow" Height="450" Width="950"
         WindowStyle="None" Background="{x:Null}"  AllowsTransparency="True"
         MouseLeftButtonDown="DragWindow" WindowStartupLocation="CenterScreen" WindowState="Maximized" Loaded="Window_Loaded">
    <Window.Resources>
        <Style TargetType="{x:Type  TextBlock }">
            <Setter Property="FontSize" Value="55"/>
            <Setter Property="FontWeight" Value="Bold"/>
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="FontFamily" Value="SimHei"/>
            <Setter Property="Margin" Value="0,10,0,0"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>
        <Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}">
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>
    </Window.Resources>

    <Grid>
        <Image Source="Images/logonBg.jpg" Stretch="Fill"/>
        <StackPanel Margin="10">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <TextBlock x:Name="tbHospital"  Grid.Column="0" HorizontalAlignment="Left" />
                <TextBlock Name="tBlockTime" FontSize="40"  Grid.Column="1" HorizontalAlignment="Right" Foreground="Green"/>
            </Grid>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <DataGrid Grid.Row="0"  RowHeaderWidth="0"  x:Name="dgvList" AlternationCount="2"  AutoGenerateColumns="False" FontSize="50" CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="True" HorizontalScrollBarVisibility="Hidden" EnableRowVirtualization="False" IsEnabled="True" EnableColumnVirtualization="False" VerticalGridLinesBrush="#FFBCC1BC" HorizontalGridLinesBrush="#FFBCC1BC">
                    <DataGrid.ColumnHeaderStyle>
                        <Style TargetType="DataGridColumnHeader">
                            <Setter Property="FontFamily" Value="SimHei"/>
                            <Setter Property="Foreground" Value="#104E8B"/>
                            <Setter Property="FontSize" Value="50" />
                            <Setter Property="Height" Value="Auto" />
                            <Setter Property="BorderThickness" Value="1" />
                            <Setter Property="HorizontalContentAlignment" Value="Center"/>
                        </Style>
                    </DataGrid.ColumnHeaderStyle>
                    <DataGrid.RowStyle>
                        <Style TargetType="{x:Type DataGridRow}">
                            <Style.Triggers>
                                <Trigger Property="ItemsControl.AlternationIndex"  Value="0">
                                    <Setter Property="Background" Value="#1874CD" />
                                </Trigger>
                                <Trigger Property="ItemsControl.AlternationIndex"  Value="1">
                                    <Setter Property="Background" Value="#1C86EE" />
                                </Trigger>
                            </Style.Triggers>
                            <Setter Property="Foreground" Value="Yellow"/>
                            <Setter Property="FontFamily" Value="SimHei"/>
                        </Style>
                    </DataGrid.RowStyle>

                    <DataGrid.Columns>
                        <DataGridTextColumn ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" Header="检查室"  Binding="{Binding QUEUENAME, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="*"/>
                        <DataGridTextColumn ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" Header="检查部位" Binding="{Binding PARTOFCHECK, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="*"/>
                        <DataGridTextColumn ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" Header="当前就诊" Binding="{Binding NAME, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="*"/>
                        <DataGridTextColumn ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" Header="准备就诊 " Binding="{Binding NAME2, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="*"/>
                    </DataGrid.Columns>
                </DataGrid>
            </Grid>
        </StackPanel>
        <StackPanel>
        </StackPanel>
        <TextBlock x:Name="tbCurrentContent" Margin="20" Text="XX人正在就诊......" Grid.Row="2" HorizontalAlignment="Left"  VerticalAlignment="Bottom"/>
    </Grid>
</Window>
复制代码

CS==>

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
using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Threading;
using QueueSystem.database;
using QueueSystem.Helper;
 
namespace QueueSystem
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        private DispatcherTimer DispatcherTimer;
 
        public MainWindow()
        {
 
            InitializeComponent();
 
            DispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            // 当间隔时间过去时发生的事件
            DispatcherTimer.Tick += new EventHandler(ShowCurrentTime);
            DispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1);
            DispatcherTimer.Start();
        }
 
        public void ShowCurrentTime(object sender, EventArgs e)
        {
            //获得星期
            //this.tBlockTime.Text = DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("zh-cn"));
            //this.tBlockTime.Text += "\n";
 
            //获得年月日
            //this.tBlockTime.Text = DateTime.Now.ToString("yyyy:MM:dd");   //yyyy年MM月dd日
            //this.tBlockTime.Text += "\n";
 
            //获得时分秒
            this.tBlockTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss dddd");
            this.tbCurrentContent.Text = Socket.SocketMSG;
        }
 
        private void DragWindow(object sender, MouseButtonEventArgs e)
        {
            this.DragMove();
        }
 
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            InitData();
            InitSetting();
        }
 
        /// <summary>
        /// 初始化配置
        /// </summary>
        private void InitSetting()
        {
            string path = AppDomain.CurrentDomain.BaseDirectory + "\\config.xml";
            string hospitalName = XmlHelper.Instance.GetAttributeValueByXmlNode(path, "root//hospital", "value");
            string hospitalFontSize = XmlHelper.Instance.GetAttributeValueByXmlNode(path, "root//hospital", "fontSize");
            string timeFontSize = XmlHelper.Instance.GetAttributeValueByXmlNode(path, "root//time", "fontSize");
            string dgFontSize = XmlHelper.Instance.GetAttributeValueByXmlNode(path, "root//dataGrid", "fontSize");
            string currentContentF = XmlHelper.Instance.GetAttributeValueByXmlNode(path, "root//currentContent", "fontSize");
            //string serverIp = XmlHelper.Instance.GetAttributeValueByXmlNode(path, "root//server", "ip");
            // string hospitalFont = XmlHelper.Instance.GetAttributeValueByXmlNode(path, "root//server", "port");
 
            this.tbHospital.Text = hospitalName;
            this.tbHospital.FontSize = double.Parse(hospitalFontSize);
            this.tBlockTime.FontSize = double.Parse(timeFontSize);
            this.dgvList.FontSize = double.Parse(dgFontSize);
            this.tbCurrentContent.FontSize = double.Parse(currentContentF);
        }
 
        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitData()
        {
            List<QueueSystem.database.Query> list = QUEUEBUSINESS.GetVRqueueList(string.Empty, string.Empty);
            this.dgvList.ItemsSource = list;
        }
    }
}
 
 
 public string GetAttributeValueByXmlNode(string path, string nodeName, string attributeName)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(path);
 
            XmlNode node = doc.SelectSingleNode(nodeName);
            return node.Attributes[attributeName].Value;
        }

配置文件:

<?xml version="1.0" encoding="utf-8" ?>
<root>
  <hospital value="XX省人民医院" fontSize="50"/>
  <time fontSize="45"/>
  <dataGrid fontSize="50"/>
  <currentContent fontSize="50"/>
</root>

运行效果:

复制代码
动态设置DataGrid样式==this.dgvList.Foreground = new SolidColorBrush(color);

            Style style = new System.Windows.Style();
            style.TargetType = typeof(DataGridColumnHeader);
            //foreground
            Setter hForeGround = new Setter();
            hForeGround.Property = ForegroundProperty;
            Foreground = new SolidColorBrush(headers);
            hForeGround.Value = Foreground;
            style.Setters.Add(hForeGround);
            //HorizontalContentAlignment
            Setter align = new Setter();
            align.Property = HorizontalContentAlignmentProperty;
            HorizontalAlignment = HorizontalAlignment.Center;
            HorizontalContentAlignment = HorizontalAlignment;
            style.Setters.Add(align);        
复制代码

 

posted on   sunwugang  阅读(10479)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示