WPF登录界面及程序主界面设计

本博文为WPF编写的 管理系统登录界面,及几个管理系统主界面设计   先上图看一下效果

主界面:

图一:登录界面 

图片二.登录数据准备中

现在开始上源码:

登录界面前台源码:

<Window x:Class="WPFLoginDemo.LoginWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="登录" Height="300" Width="400"
        WindowStartupLocation="CenterScreen"
        WindowStyle="None"
        FocusManager.FocusedElement="{Binding ElementName=txt_userName}"
        Loaded="Window_Loaded">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="80"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="40"/>
        </Grid.ColumnDefinitions>
        <Grid.Background>
            <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                <GradientStop Color="#5aacf6" Offset="0.0"/>
                <GradientStop Color="#0056f1" Offset="0.2"/>
                <GradientStop Color="#13ceff" Offset="0.4"/>
                <GradientStop Color="#006bff" Offset="0.6"/>
                <GradientStop Color="#19d5ff" Offset="0.8"/>
                <GradientStop Color="#5aacf6" Offset="1.0"/>
            </LinearGradientBrush>
        </Grid.Background>
        <TextBlock Grid.Row="2" Grid.ColumnSpan="3"
                   Text="XXX管理系统V1.1.001版" TextAlignment="Center"
                   VerticalAlignment="Center" FontSize="22"></TextBlock>
        <TextBlock Grid.Row="3" TextAlignment="Right"  VerticalAlignment="Center"
                   Text="用户名:"/>
        <TextBox Grid.Row="3" Grid.Column="1" Height="27" Margin="5 0 5 0"
                 Name="txt_userName"/>
        <TextBlock Grid.Row="4" TextAlignment="Right" VerticalAlignment="Center"
                   Text="密  码:"/>
        <PasswordBox Grid.Row="4" Grid.Column="1" Height="27" Margin="5 0 5 0"
                     Name="txt_Pwd"/>
        <StackPanel Grid.Row="5" Grid.Column="1" Orientation="Horizontal">
            <Button Content="登录" Width="70" Margin="30 0 0 0" Height="35"
                    Name="btn_login" Click="btn_login_Click" Foreground="White" FontSize="18" Background="Transparent"/>
            <Button Content="退出" Width="70" Margin="40 0 0 0" Height="35"
                    Name="btn_exit" Click="btn_exit_Click" Background="Transparent" Foreground="White" FontSize="18"/>
        </StackPanel>
    </Grid>
</Window>

后台源码

  private void btn_login_Click(object sender, RoutedEventArgs e)
        {
            Splasher.Show(typeof(frmSplash));
            MainWindow mainWindow = new MainWindow();
            this.Close();
            mainWindow.Show();
        }
        private void btn_exit_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
            Environment.Exit(0);
        }

这里顺便说一下。在登录到主界面时,一般程序都要加载一些配置数据信息,这个一般般比较耗时,为了提高更好的用户体验 我们加载了一个加载提示窗口
此提示窗口是修改别人。

第一步:创建一个提示窗口(如图二)(本窗口为Winform窗口),本窗口本打算改为WPF的可是,改了之后发现无法运行,如果谁修改好了 请把源码贴出来学习一下

窗口后台源码:

public partial class frmSplash : Form,ISplashForm
    {
        public frmSplash()
        {
            InitializeComponent();
        }

        #region ISplashForm

        void ISplashForm.SetStatusInfo(string NewStatusInfo)
        {
            lbStatusInfo.Text = NewStatusInfo;
        }

        #endregion
    }

用到的 接口文件:ISplashForm.cs

  public interface ISplashForm
    {
        void SetStatusInfo(string NewStatusInfo);
    }

实现辅助类:Splasher.cs

按 Ctrl+C 复制代码

按 Ctrl+C 复制代码

主界面加载耗时的数据

 public MainWindow()
        {
            InitializeComponent();

            //登录是使用
            Splasher.Status = "正在准备数据......";
            System.Threading.Thread.Sleep(1000);

            Splasher.Status = "正在添加组件......";
            //此处省略部分加载耗时的代码

            Splasher.Status = "正在获取数据库数据......";
            System.Threading.Thread.Sleep(1000);
            Splasher.Status = "初始化完毕";
            System.Threading.Thread.Sleep(300);

            Splasher.Close();
        }

主界面布局出来前台源码

<Window xmlns:my="clr-namespace:WPFLoginDemo.CustomerControl"  x:Class="WPFLoginDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        WindowStartupLocation="CenterScreen"
        Width="1024" Height="768"
        Title="XXX管理系统V1.1.001版" Loaded="Window_Loaded" SizeChanged="Window_SizeChanged">
    <Window.Resources>
        <!--Separator控件模块样式-->
        <Style x:Key="CorrectSeparatorStyle" TargetType="{x:Type Separator}">
            <Setter Property="Background">
                <Setter.Value>
                    <RadialGradientBrush>
                        <GradientStop Color="#ffffff" Offset="0"/>
                        <GradientStop Color="#ffffff" Offset="0.2"/>
                        <GradientStop Color="#ffffff" Offset="0.3"/>
                        <GradientStop Color="#ffffff" Offset="0.4"/>
                        <GradientStop Color="#0067c9" Offset="1"/>
                    </RadialGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="Margin" Value="0,2,0,2"/>
            <Setter Property="Focusable" Value="false"/>
            <Setter Property="Height" Value="1"/>
            <Setter Property="SnapsToDevicePixels" Value="True"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Separator}">
                       <Border Background="{TemplateBinding Background}">
                        <Line Stretch="Fill" X2="1" Stroke="{TemplateBinding Background}" StrokeThickness="{TemplateBinding Height}"
                              StrokeStartLineCap="Square" StrokeEndLineCap="Square"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <!--Button控件模块样式-->
        <Style x:Key="buttonStyle" TargetType="{x:Type Button}">
            <Setter Property="Foreground" Value="Black"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Height" Value="43"/>
            <Setter Property="FontSize" Value="20"/>
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <!--修改模板属性-->
            <Setter Property="Template">
                <Setter.Value>
                    <!--控件模板-->
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border x:Name="fore" BorderThickness="0" CornerRadius="3" BorderBrush="#5555" Background="{TemplateBinding Background}">
                            <ContentPresenter x:Name="content" HorizontalAlignment="Center" VerticalAlignment="Center"
                                              Content="{TemplateBinding  Content}">
                                <ContentPresenter.BitmapEffect>
                                    <DropShadowBitmapEffect Color="#000" Direction="-90" ShadowDepth="2" Softness="0.1" Opacity="0.3"/>
                                </ContentPresenter.BitmapEffect>
                            </ContentPresenter>
                        </Border>
                        <ControlTemplate.Triggers>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="60"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition  Width="150"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="10"/>
        </Grid.ColumnDefinitions>
        <!--菜单栏-->
        <Menu Grid.ColumnSpan="3">
            <MenuItem Header="【基础资料】"/>
            <MenuItem Header="【客户维修】"/>
            <MenuItem Header="【销售管理】"/>
            <MenuItem Header="【报表查询】"/>
            <MenuItem Header="【用户管理】"/>
            <MenuItem Header="【系统设置】"/>
            <MenuItem Header="【帮助】"/>
        </Menu>
        <!--logo图片 Heard 头部-->
        <TextBlock Text="XXX管理系统" Grid.Row="1" Grid.ColumnSpan="3" TextAlignment="Center"
                   Foreground="#ffffff" Padding="0 8 0 0" FontSize="30" FontWeight="Bold" HorizontalAlignment="Stretch">
            <TextBlock.Background>
                <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                    <GradientStop Color="#5aacf6" Offset="0.0"/>
                     <GradientStop Color="#0056f1" Offset="0.2"/>
                     <GradientStop Color="#13ceff" Offset="0.4"/>
                     <GradientStop Color="#006bff" Offset="0.6"/>
                     <GradientStop Color="#19d5ff" Offset="0.8"/>
                     <GradientStop Color="#5aacf6" Offset="1.0"/>
                </LinearGradientBrush>
            </TextBlock.Background>
        </TextBlock>
        <!--分割线-->
        <StackPanel Grid.Row="2" Grid.ColumnSpan="3">
            <Separator Style="{StaticResource ResourceKey=CorrectSeparatorStyle}" Height="5" Background="#c0c0c0">
            </Separator>
        </StackPanel>
        <!--主操作区域-->
        <Grid Grid.Row="3" Grid.ColumnSpan="3">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="170"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <!--左侧菜单栏-->
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="40"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <TextBlock Text="主菜单栏" Padding="0 7 0 0" TextAlignment="Center" FontSize="20" Foreground="#fafafa" FontWeight="Bold" Height="40">
                        <TextBlock.Background>
                            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                <GradientStop Color="#f9f9f9" Offset="0"/>
                                <GradientStop Color="#ababab" Offset="0.3"/>
                                <GradientStop Color="#b4b4b4" Offset="0.5"/>
                                <GradientStop Color="#d2d2d2" Offset="0.75"/>
                                <GradientStop Color="#dedee0" Offset="1"/>
                            </LinearGradientBrush>
                        </TextBlock.Background>
                 </TextBlock>
                <StackPanel Name="stackPanel1" Orientation="Vertical" Grid.Row="1" ButtonBase.Click="btn_customer_Click">
                    <StackPanel.Background>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                            <GradientStop Color="#005fc3" Offset="0"/>
                            <GradientStop Color="#0c70e5" Offset="0.5"/>
                            <GradientStop Color="#008ae5" Offset="1"/>
                        </LinearGradientBrush>
                    </StackPanel.Background>
                    <!--客户维修-->
                    <Button Name="btn_Repair" Content="客户维修" Style="{StaticResource ResourceKey=buttonStyle}" Click="btn_Repair_Click"></Button>
                    <Separator Height="4" Style="{StaticResource ResourceKey=CorrectSeparatorStyle}"></Separator>
                    <!--销售管理-->
                    <Button Content="销售管理" Style="{StaticResource ResourceKey=buttonStyle}"></Button>
                    <Separator Height="4" Style="{StaticResource ResourceKey=CorrectSeparatorStyle}"></Separator>
                    <!--报表查询-->
                    <Button Content="报表查询" Style="{StaticResource ResourceKey=buttonStyle}"></Button>
                    <Separator Height="4" Style="{StaticResource ResourceKey=CorrectSeparatorStyle}"></Separator>
                    <!--基础资料-->
                    <Button Content="基础资料" Style="{StaticResource ResourceKey=buttonStyle}"></Button>
                    <Separator Height="4" Style="{StaticResource ResourceKey=CorrectSeparatorStyle}"></Separator>
                    <!--发货处理-->
                    <Button Content="发货处理" Style="{StaticResource ResourceKey=buttonStyle}"></Button>
                    <Separator Height="4" Style="{StaticResource ResourceKey=CorrectSeparatorStyle}"></Separator>
                    <!--用户管理-->
                    <Button Content="用户管理" Style="{StaticResource ResourceKey=buttonStyle}"></Button>
                    <Separator Height="4" Style="{StaticResource ResourceKey=CorrectSeparatorStyle}"></Separator>
                    <!--系统设置-->
                    <Button Content="系统设置" Style="{StaticResource ResourceKey=buttonStyle}"></Button>
                </StackPanel>
            </Grid>
            <!--右侧功能处理-->
            <StackPanel Name="stackPanelRight" Grid.Column="1">
                <StackPanel.Background>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                        <GradientStop Color="#f3fbfa" Offset="0.0"/>
                        <GradientStop Color="#eef9fa" Offset="0.2"/>
                        <GradientStop Color="#c5e2f5" Offset="0.4"/>
                        <GradientStop Color="#91d3f5" Offset="0.6"/>
                        <GradientStop Color="#8ed4f6" Offset="0.8"/>
                        <GradientStop Color="#7ed0f6" Offset="1.0"/>
                    </LinearGradientBrush>
                </StackPanel.Background>
            </StackPanel>
        </Grid>
        <!--状态栏-->
        <StatusBar Grid.Row="4" Grid.ColumnSpan="3" VerticalAlignment="Center" Background="Beige">
            <StatusBarItem Content="数据帐套:正式帐套"/>
            <StatusBarItem Content="岗位名称:仓库管理员" Margin="25 0 0 0"/>
            <StatusBarItem Content="登录用户名:系统管理员" Margin="25 0 0 0"/>
            <StatusBarItem Content="登录时间:2013年11月20日 13:54:08 星期一" Margin="25 0 0 0"/>
        </StatusBar>
    </Grid>
</Window>

后台源码出来

public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            //登录是使用
            Splasher.Status = "正在准备数据......";
            System.Threading.Thread.Sleep(1000);

            Splasher.Status = "正在添加组件......";
            //此处省略部分加载耗时的代码

            Splasher.Status = "正在获取数据库数据......";
            System.Threading.Thread.Sleep(1000);
            Splasher.Status = "初始化完毕";
            System.Threading.Thread.Sleep(300);

            Splasher.Close();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            btn_Repair_Click(null, null);
        }
        /// <summary>
        /// 获取渐变效果
        /// </summary>
        /// <returns></returns>
        private LinearGradientBrush GetLinearGradientBrush()
        {
            LinearGradientBrush linearGradient = new LinearGradientBrush();
            linearGradient.StartPoint = new System.Windows.Point(0, 0.5);
            linearGradient.EndPoint = new System.Windows.Point(1, 0.5);
            linearGradient.GradientStops.Add(new GradientStop((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#0057bf"), 0.0));
            linearGradient.GradientStops.Add(new GradientStop((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#4b8acf"), 0.1));
            linearGradient.GradientStops.Add(new GradientStop((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#e2ecf6"), 0.3));
            linearGradient.GradientStops.Add(new GradientStop((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#ffffff"), 0.5));
            linearGradient.GradientStops.Add(new GradientStop((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#e2ecf6"), 0.8));
            linearGradient.GradientStops.Add(new GradientStop((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#4b8acf"), 0.1));
            linearGradient.GradientStops.Add(new GradientStop((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#0057bf"), 1.0));
            return linearGradient;
        }
        private void SetButtonDefaultBackgroud()
        {
            LogicTree(stackPanel1);
        }
        private void LogicTree(object obj)
        {
            if (!(obj is DependencyObject))
            {
                return;
            }
            foreach (object child in LogicalTreeHelper.GetChildren(obj as DependencyObject))
            {
                if (child is Button)
                {
                    Button btn = (Button)child;
                    btn.Background = System.Windows.Media.Brushes.Transparent;
                }
                LogicTree(child);
            }
        }
        private double originalHeight = 0.0;
        private void btn_customer_Click(object sender, RoutedEventArgs e)
        {
            originalHeight = stackPanelRight.ActualHeight;

            SetButtonDefaultBackgroud();
            Button btn = e.OriginalSource as Button;
            btn.Background = GetLinearGradientBrush();
            UserControl userControl = null;
            stackPanelRight.Children.Clear();
            if (btn.Content.ToString().Equals("客户维修"))
            {
                userControl = new CustomerRepairUserControl();
            }
            stackPanelRight.Children.Add(userControl);
        }

        //主界面窗口大小的变化
        private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            if (this.WindowState == WindowState.Maximized)
            {
                CustomerData.AddHeight = (stackPanelRight.ActualHeight - originalHeight) / 3 + 35.0;
            }
            else
            {
                CustomerData.AddHeight = 35.0;
            }

        }

        private void btn_Repair_Click(object sender, RoutedEventArgs e)
        {
            originalHeight = stackPanelRight.ActualHeight;

            SetButtonDefaultBackgroud();
            Button btn = btn_Repair;
            btn.Background = GetLinearGradientBrush();
            UserControl userControl = null;
            stackPanelRight.Children.Clear();
            if (btn.Content.ToString().Equals("客户维修"))
            {
                userControl = new CustomerRepairUserControl();
            }
            stackPanelRight.Children.Add(userControl);
        }

右侧流程功能处理 为一个布局好UserControl 控件  CustomerRepairUserControl.xaml
UserControl控件布局 图片:

<UserControl x:Class="WPFLoginDemo.CustomerControl.CustomerRepairUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             xmlns:shape="clr-namespace:WPFLoginDemo.CustomerControl"
            d:DesignHeight="600" d:DesignWidth="850" SizeChanged="UserControl_SizeChanged">
    <UserControl.Resources>
        <Style TargetType="{x:Type Button}">
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush StartPoint="0,1" EndPoint="1,1">
                        <GradientStop Color="#c7daea" Offset="0.0"/>
                        <GradientStop Color="#cadcf0" Offset="0.4"/>
                        <GradientStop Color="#d6e9ff" Offset="0.7"/>
                        <GradientStop Color="#eef6ff" Offset="1.0"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid Name="grid1">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="60"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="60"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="60"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="60"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="60"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="150"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="150"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="2*"/>
        </Grid.ColumnDefinitions>
        <!--内容填充-->
        <!--客户送修登记-->
        <TextBlock Name="txtB_row" Grid.ColumnSpan="8" Text=""></TextBlock>
        <Button Grid.Column="3" Grid.Row="1" Content="送修登记新增"/>
        <StackPanel Grid.Column="3" Grid.Row="2" Orientation="Vertical">
            <shape:Arrow X1="50" Y1="0" X2="50" Y2="60" Height="60" HeadWidth="7" HeadHeight="5" Stroke="Black" StrokeThickness="0.8" />
        </StackPanel>
        <!--送修登记查询-->
        <StackPanel Grid.Column="4" Grid.Row="1" Orientation="Horizontal">
            <shape:Arrow X1="0" Y1="20" X2="150" Y2="20" Width="150" HeadWidth="7" HeadHeight="5" Stroke="Black" StrokeThickness="0.8" />
        </StackPanel>
        <Button Grid.Column="5" Grid.Row="1" Content="送修登记查询"/>
        <!--客户检测新增-->
        <Button Grid.Row="3" Grid.Column="3" Content="客户检测新增"/>
        <StackPanel Grid.Row="4" Grid.Column="3" Orientation="Vertical">
            <shape:Arrow X1="50" Y1="0" X2="50" Y2="60" Height="60" HeadWidth="7" HeadHeight="5" Stroke="Black" StrokeThickness="0.8" />
        </StackPanel>
        <!--客户检测查询-->
        <StackPanel Grid.Column="4" Grid.Row="3" Orientation="Horizontal">
            <shape:Arrow X1="0" Y1="20" X2="150" Y2="20" Width="150" HeadWidth="7" HeadHeight="5" Stroke="Black" StrokeThickness="0.8" />
        </StackPanel>
        <Button Grid.Column="5" Grid.Row="3" Content="客户检测查询"/>

        <!--原厂配件登记-->
        <StackPanel Grid.Column="2" Grid.Row="3" Orientation="Horizontal">
            <shape:Arrow X1="150" Y1="20" X2="0" Y2="20" Width="150" HeadWidth="7" HeadHeight="5" Stroke="Black" StrokeThickness="0.8" />
        </StackPanel>
        <Button Grid.Column="1" Grid.Row="3" Content="原厂配件登记"/>
        <StackPanel Grid.Column="2" Grid.Row="2" Orientation="Horizontal">
            <shape:Arrow X1="150" Y1="60" X2="0" Y2="0" Width="150" HeadWidth="7" HeadHeight="5" Stroke="Black" StrokeThickness="0.8" />
        </StackPanel>
        <Button Grid.Column="1" Grid.Row="1" Content="异常单据查找"/>
        <!--主要报表查询-->
        <Button Grid.Column="1" Grid.Row="5" Content="汇总查询分析"/>
        <Button Grid.Column="1" Grid.Row="7" Content="故障统计分析"/>
        <Button Grid.Column="1" Grid.Row="9" Content="维修记录统计"/>
        <Button Grid.Column="1" Grid.Row="11" Content="快递单打印"/>
        <!--产品报价新增-->
        <Button Grid.Row="5" Grid.Column="3" Content="产品报价新增"/>
        <StackPanel Grid.Row="6" Grid.Column="3" Orientation="Vertical">
            <shape:Arrow X1="50" Y1="0" X2="50" Y2="60" Height="60" HeadWidth="7" HeadHeight="5" Stroke="Black" StrokeThickness="0.8" />
        </StackPanel>
        <!--产品报价查询-->
        <StackPanel Grid.Column="4" Grid.Row="5" Orientation="Horizontal">
            <shape:Arrow X1="0" Y1="20" X2="150" Y2="20" Width="150" HeadWidth="7" HeadHeight="5" Stroke="Black" StrokeThickness="0.8" />
        </StackPanel>
        <Button Grid.Column="5" Grid.Row="5" Content="产品报价查询"/>
        <!--配件领料新增-->
        <Button Grid.Row="7" Grid.Column="3" Content="配件领料新增"/>
        <StackPanel Grid.Row="8" Grid.Column="3" Orientation="Vertical">
            <shape:Arrow X1="50" Y1="0" X2="50" Y2="60" Height="60" HeadWidth="7" HeadHeight="5" Stroke="Black" StrokeThickness="0.8" />
        </StackPanel>
        <!--配件领料查询-->
        <StackPanel Grid.Column="4" Grid.Row="7" Orientation="Horizontal">
            <shape:Arrow X1="0" Y1="20" X2="150" Y2="20" Width="150" HeadWidth="7" HeadHeight="5" Stroke="Black" StrokeThickness="0.8" />
        </StackPanel>
        <Button Grid.Column="5" Grid.Row="7" Content="配件领料查询"/>
        <!--维修结案新增-->
        <Button Grid.Row="9" Grid.Column="3" Content="维修结案新增"/>
        <StackPanel Grid.Row="10" Grid.Column="3" Orientation="Vertical">
            <shape:Arrow X1="50" Y1="0" X2="50" Y2="60" Height="60" HeadWidth="7" HeadHeight="5" Stroke="Black" StrokeThickness="0.8" />
        </StackPanel>
        <!--维修结案查询-->
        <StackPanel Grid.Column="4" Grid.Row="9" Orientation="Horizontal">
            <shape:Arrow X1="0" Y1="20" X2="150" Y2="20" Width="150" HeadWidth="7" HeadHeight="5" Stroke="Black" StrokeThickness="0.8" />
        </StackPanel>
        <Button Grid.Column="5" Grid.Row="9" Content="维修结案查询"/>
        <!--维修发货新增-->
        <Button Grid.Row="11" Grid.Column="3" Content="维修发货新增"/>
        <StackPanel Grid.Column="4" Grid.Row="11" Orientation="Horizontal">
            <shape:Arrow X1="0" Y1="20" X2="150" Y2="20" Width="150" HeadWidth="7" HeadHeight="5" Stroke="Black" StrokeThickness="0.8" />
        </StackPanel>
        <Button Grid.Column="5" Grid.Row="11" Content="维修发货追踪"/>
    </Grid>
</UserControl>

下面为 画箭头使用的类

public sealed class Arrow : Shape
    {
        public static readonly DependencyProperty X1Property = DependencyProperty.Register("X1", typeof(double), typeof(Arrow), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
        public static readonly DependencyProperty Y1Property = DependencyProperty.Register("Y1", typeof(double), typeof(Arrow), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
        public static readonly DependencyProperty X2Property = DependencyProperty.Register("X2", typeof(double), typeof(Arrow), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
        public static readonly DependencyProperty Y2Property = DependencyProperty.Register("Y2", typeof(double), typeof(Arrow), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
        public static readonly DependencyProperty HeadWidthProperty = DependencyProperty.Register("HeadWidth", typeof(double), typeof(Arrow), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
        public static readonly DependencyProperty HeadHeightProperty = DependencyProperty.Register("HeadHeight", typeof(double), typeof(Arrow), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
        [TypeConverter(typeof(LengthConverter))]
        public double X1
        {
            get { return (double)base.GetValue(X1Property); }
            set { base.SetValue(X1Property, value); }
        }
        [TypeConverter(typeof(LengthConverter))]
        public double Y1
        {
            get { return (double)base.GetValue(Y1Property); }
            set { base.SetValue(Y1Property, value); }
        }
        [TypeConverter(typeof(LengthConverter))]
        public double X2
        {
            get { return (double)base.GetValue(X2Property); }
            set { base.SetValue(X2Property, value); }
        }
        [TypeConverter(typeof(LengthConverter))]
        public double Y2
        {
            get { return (double)base.GetValue(Y2Property); }
            set { base.SetValue(Y2Property, value); }
        }
        [TypeConverter(typeof(LengthConverter))]
        public double HeadWidth
        {
            get { return (double)base.GetValue(HeadWidthProperty); }
            set { base.SetValue(HeadWidthProperty, value); }
        }
        [TypeConverter(typeof(LengthConverter))]
        public double HeadHeight
        {
            get { return (double)base.GetValue(HeadHeightProperty); }
            set { base.SetValue(HeadHeightProperty, value); }
        }
        protected override Geometry DefiningGeometry
        {
            get
            {
                // Create a StreamGeometry for describing the shape
                StreamGeometry geometry = new StreamGeometry();
                geometry.FillRule = FillRule.EvenOdd;

                using (StreamGeometryContext context = geometry.Open())
                {
                    InternalDrawArrowGeometry(context);
                }

                // Freeze the geometry for performance benefits
                geometry.Freeze();

                return geometry;
            }
        }
        private void InternalDrawArrowGeometry(StreamGeometryContext context)
        {
            double theta = Math.Atan2(Y1 - Y2, X1 - X2);
            double sint = Math.Sin(theta);
            double cost = Math.Cos(theta);

            Point pt1 = new Point(X1, this.Y1);
            Point pt2 = new Point(X2, this.Y2);

            Point pt3 = new Point(
                X2 + (HeadWidth * cost - HeadHeight * sint),
                Y2 + (HeadWidth * sint + HeadHeight * cost));

            Point pt4 = new Point(
                X2 + (HeadWidth * cost + HeadHeight * sint),
                Y2 - (HeadHeight * cost - HeadWidth * sint));

            context.BeginFigure(pt1, true, false);
            context.LineTo(pt2, true, true);
            context.LineTo(pt3, true, true);
            context.LineTo(pt2, true, true);
            context.LineTo(pt4, true, true);
        }

    }

 public class CustomerData
    {
        public static double AddHeight = 35.0;
    }

本人说水平有限,请批评指正。

UserControl 在加入到 主界面是,Width 会随主界面最大化 变大而变大,而Height 侧不会。望大家提出怎么解决。

出处:https://www.cnblogs.com/xieyong_198510/p/3435870.html

原文地址:https://www.cnblogs.com/mq0036/p/12327580.html

时间: 2024-10-01 17:38:16

WPF登录界面及程序主界面设计的相关文章

【边做项目边学Android】手机安全卫士05_1:程序主界面

主界面布局(知识点:GridView) mainscreen.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height=

日积(Running)月累(ZSSURE):WCF学习之“通过事件绑定控制WinForm宿主程序主界面控件”

背景: WCF服务需要寄宿到相应的可运行进程中执行,常见的有四种寄宿,分别是控制台程序.WinForm程序.IIS和Windows服务.之前学习老A博客和<WCF全面解析>时最常用到的是控制台寄宿,近期由于项目需求,需要在WinForm程序中调用WCF服务,本博文通过一个简单的实例来演示WCF在WinForm中的寄宿.并着重介绍如何利用事件绑定控制宿主主UI界面控件. 题记: 之前一直坚守在C++阵地,对于新语言.新技术(诸如Python.J2EE.Bigdata.AI)不甚感冒.自以为&qu

WinForm 实现登录,验证成功,关闭登录界面,显示主界面

点击登录按钮时: 1 if (this.txtLoginName.Text.Trim()=="admin" && this.txtLoginPwd.Text.Trim()=="123456") 2 { 3 this.DialogResult = DialogResult.OK; 4 this.Close(); 5 } 6 else 7 { 8 MessageBox.Show("用户名或密码错误", "信息提示"

【边做项目边学Android】手机安全卫士05_2:程序主界面,为每个条目添加事件

为每个条目添加点击事件监听器 gv_main.setOnItemClickListener(this); 需要当前Activity实现OnItemClickListener接口,同时实现public void onItemClick(AdapterView<?> parent, View view, int position,long id)方法 /** * 当gridview的条目被点击的时候对应的回调 * parent : gridView * view : 当前被点击条目的 Linear

MFC打开子界面,隐藏主界面后,程序图标在任务栏消失问题

在子窗口的构造函数中,父窗口改为通过GetDesktopWindow获取. CDIALOG::CDIALOG(CWnd* pParent /*=NULL*/): CDialogEx(CDIALOG::IDD, pParent) 改为: CDIALOG::CDIALOG(CWnd* pParent /*=NULL*/): CDialogEx(CDIALOG::IDD, pParent = GetDesktopWindow()) 任务栏图标OK.                           

关于VS打包程序无法弹出主界面的问题

代码中的程序很正常,VS打包之后,无法弹出主界面的问题. 这种问题,一般是缺少程序加载所必须的东西,包括dll,配置文件等. (1)程序主界面使用的是DevExpress,DevExpress的相关类库要改成复制到本地为true (2)代码在窗体初始化的时候添加了好多程序初始参数的获取设置,而这些初始化设置的代码由于在打包时缺少配置文件, 导致打包后的程序无法读取配置文件,从而主窗体无法弹出.

Winform开发框架主界面设计展示

做了好多年Winform的程序的开发,主窗口的界面设计一般都要求做的更好一些,可以根据不同的系统功能模块进行归类整合,能使客户迅速寻找到相关功能的同时,也能感觉到整体性的美观大方,因此主窗口的界面设计总是会精益求精,力求做到更好用.更美观,这样才能吸引客户使用. 目前的主体界面设计,可以使用很多控件进行美化,这样能使得开发者能够迅速开发好美观的界面,也可以使得界面总体性有一个统一.规范的基准.一般推荐使用DevExpress或者DotNetbar这两款界面控件套件,他们都能设计出类似Office

Winform_devexpress开发框架主界面设计

做了好多年的C#开发,从.Net.Winform及第三方的 DevExpress.无论什么样的系统,主界面的设计及风格无疑非常重要.从客户的角度考虑,要求功能区清晰,整体美观大方,这样才会有可能从第一视觉或印象中吸引客户. 之前也自己做过很多.Net 和Winform的界面框架,接触DevExpress后,感觉色彩搭配及界面整体感觉不错,所以设计出如下界面. DevExpress样式主界面介绍 在WinForm 框架中,界面分多个区展现,简洁易区分,并且可根据需要,对部分功能进行隐藏,使功能界面

输入password登录到主界面,录入学生编号,排序后输出

n 题目:输入password登录到主界面,录入学生编号,排序后输出 n 1.  语言和环境 A.实现语言 C语言 B.环境要求 VC++ 6.0 n 2.  要求 请编写一个C语言程序.将若干学生编号按字母顺序(由小到大)输出. 程序的功能要求例如以下: 1)  输入password"admin",正确则进入主界面,错误则直接推出(exit(0)): 2)从键盘输入5个学生编号"BJS1001","BJS2001"."BJS1011&