Переглянути джерело

增加datagrid控件

样式分支
fyf 2 роки тому
джерело
коміт
4c6157a4de
8 змінених файлів з 400 додано та 0 видалено
  1. +6
    -0
      BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj
  2. +24
    -0
      BPASmartClient.SCADAControl/Converters/ItemsList.cs
  3. +10
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml
  4. +101
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml.cs
  5. BIN
     
  6. BIN
     
  7. BIN
     
  8. +259
    -0
      BPASmartClient.SCADAControl/Themes/Generic.xaml

+ 6
- 0
BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj Переглянути файл

@@ -9,6 +9,9 @@

<ItemGroup>
<None Remove="Fonts\ds-digib.ttf" />
<None Remove="Images\biogebj.png" />
<None Remove="Images\bj.png" />
<None Remove="Images\databj.png" />
<None Remove="Images\State0.png" />
<None Remove="Images\State1.png" />
<None Remove="Images\State11.png" />
@@ -42,6 +45,8 @@

<ItemGroup>
<Resource Include="Fonts\ds-digib.ttf" />
<Resource Include="Images\bj.png" />
<Resource Include="Images\databj.png" />
<Resource Include="Images\State0.png" />
<Resource Include="Images\State1.png" />
<Resource Include="Images\State11.png" />
@@ -49,6 +54,7 @@
<Resource Include="Images\timericon.png" />
<Resource Include="Images\借出.png" />
<Resource Include="Images\光柱.png" />
<Resource Include="Images\biogebj.png" />
<Resource Include="Images\退出.png" />
</ItemGroup>



+ 24
- 0
BPASmartClient.SCADAControl/Converters/ItemsList.cs Переглянути файл

@@ -34,4 +34,28 @@ namespace BPASmartClient.SCADAControl.Converters
}

}

public class ItemsListObj:ObservableCollection<object>
{
public ItemsListObj()
{
AddCommand = new RelayCommand<object>(AddItem);
DeleteCommand = new RelayCommand<object>(DeleteItem);
}

private void DeleteItem(object obj)
{
if (obj!=null)
Remove(obj);
}

public RelayCommand<object> AddCommand { get; }
public RelayCommand<object> DeleteCommand { get; }
private void AddItem(object txt)
{
if (txt != null)
Add(txt);
}

}
}

+ 10
- 0
BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml Переглянути файл

@@ -0,0 +1,10 @@
<DataGrid x:Class="BPASmartClient.SCADAControl.CustomerControls.TheDataGrid"
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"
xmlns:local="clr-namespace:BPASmartClient.SCADAControl.CustomerControls"
mc:Ignorable="d"
Background="Transparent"
d:DesignHeight="450" d:DesignWidth="800">
</DataGrid>

+ 101
- 0
BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml.cs Переглянути файл

@@ -0,0 +1,101 @@
using BPASmartClient.Compiler;
using BPASmartClient.MessageName.接收消息Model.物料仓;
using BPASmartClient.SCADAControl.Converters;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPASmartClient.SCADAControl.CustomerControls
{
/// <summary>
/// TheDataGrid.xaml 的交互逻辑
/// </summary>
public partial class TheDataGrid :DataGrid, IExecutable
{
public TheDataGrid()
{
InitializeComponent();
Style = Application.Current.Resources["DesignTheDataGrid"] as Style;

ItemsString=new ItemsListObj()
{
new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
};
}

public ItemsListObj ItemsString
{
get { return (ItemsListObj)GetValue(ItemsStringProperty); }
set { SetValue(ItemsStringProperty,value); }
}

public static readonly DependencyProperty ItemsStringProperty =
DependencyProperty.Register("ItemsString",typeof(ItemsListObj),typeof(TheDataGrid),new PropertyMetadata(null));




public string ControlType => "控件";

private bool isExecuteState;
public bool IsExecuteState
{
get { return isExecuteState; }
set
{
isExecuteState = value;
if (IsExecuteState)
{
Style = null;
Register();
}
}
}

/// <summary>
/// 注册需要处理的事件
/// </summary>
public void Register()
{
// 运行时进行项目绑定
Binding binding = new Binding();
binding.RelativeSource = new RelativeSource() { Mode = RelativeSourceMode.Self };
binding.Path = new PropertyPath("ItemsString");

SetBinding(ItemsSourceProperty,binding);
}

private void MyButton_Click(object sender,RoutedEventArgs e)
{

}
}

public class datalist
{
public string Name { get; set; }
public string Description { get; set; }
public string Messgae { get; set; }
}
}




+ 259
- 0
BPASmartClient.SCADAControl/Themes/Generic.xaml Переглянути файл

@@ -9,6 +9,18 @@
<SolidColorBrush x:Key="ControlBorderBrush" Color="LightGray"/>
<SolidColorBrush x:Key="ControlBackground" Color="White"/>
<SolidColorBrush x:Key="ControlForeground" Color="Black"/>


<SolidColorBrush x:Key="foreground" Color="#a2c2e8" />
<SolidColorBrush x:Key="borderBrush" Color="#FF074B92" />
<SolidColorBrush x:Key="Titleforeground" Color="#FF07D7FF" />
<SolidColorBrush x:Key="DataGridColumnHeaderColor" Color="#00c2f4" />
<SolidColorBrush x:Key="LabelColor" Color="#FF00EEF3" />
<SolidColorBrush x:Key="MainTitleforeground" Color="#feffff" />
<SolidColorBrush x:Key="ButtonSelectForeground" Color="#4fade8" />
<SolidColorBrush x:Key="ButtonUnSelectForeground" Color="#3afdff" />
<SolidColorBrush x:Key="MeunSelectForeground" Color="#8f723c" />
<SolidColorBrush x:Key="MeunUnSelectForeground" Color="White" />
<LinearGradientBrush x:Key="NormalBackground" StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStopCollection>
<GradientStop Color="White" />
@@ -16,7 +28,9 @@
<GradientStop Color="#E3E3E3" Offset="1"/>
</GradientStopCollection>
</LinearGradientBrush>
<con:HalfNumberConverter x:Key="HalfNumber"/>
<FontFamily x:Key="Digital">
pack://application:,,,/Fonts/#DS-Digital
</FontFamily>
@@ -376,4 +390,249 @@
</Setter.Value>
</Setter>
</Style>

<Style x:Key="DesignTheDataGrid" TargetType="{x:Type ctrl:TheDataGrid}">
<Setter Property="AutoGenerateColumns" Value="False" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="CanUserAddRows" Value="False" />
<Setter Property="CanUserDeleteRows" Value="False" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="HeadersVisibility" Value="Column" />
<Setter Property="GridLinesVisibility" Value="None" />
<Setter Property="SelectionMode" Value="Single" />
<!--<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ctrl:TheDataGrid">
<Border BorderBrush="{StaticResource ControlBorderBrush}" BorderThickness="1" Background="{StaticResource ControlBackground}">
<TextBlock Margin="4 0 0 0" Text="{TemplateBinding Text}" VerticalAlignment="Center" Foreground="BlueViolet"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>-->
</Style>

<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="Foreground" Value="#abf4ff" />
<Setter Property="BorderBrush" Value="#abf4ff" />
<Setter Property="FontSize" Value="10" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRow}">
<Border
x:Name="DGR_Border"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True">
<SelectiveScrollingGrid x:Name="selectiveScrollingGrid">
<SelectiveScrollingGrid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</SelectiveScrollingGrid.ColumnDefinitions>
<SelectiveScrollingGrid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</SelectiveScrollingGrid.RowDefinitions>
<DataGridCellsPresenter
Grid.Column="1"
ItemsPanel="{TemplateBinding ItemsPanel}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<DataGridDetailsPresenter
Grid.Row="1"
Grid.Column="1"
SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
Visibility="{TemplateBinding DetailsVisibility}" />
<DataGridRowHeader
Grid.RowSpan="2"
SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
</SelectiveScrollingGrid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border" Storyboard.TargetProperty="(Panel.Background)">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<SolidColorBrush Color="#230077BC" />
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Normal_Selected">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border" Storyboard.TargetProperty="(Panel.Background)">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<SolidColorBrush Color="#3D0077BC" />
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="ValidationStates">
<VisualState x:Name="Valid" />
<VisualState x:Name="InvalidFocused" />
<VisualState x:Name="InvalidUnfocused" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style TargetType="{x:Type GridSplitter}">
<Setter Property="Width" Value="1" />
<Setter Property="Background" Value="#175c86" />
<Setter Property="Cursor" Value="SizeWE" />
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border
Width="{TemplateBinding Width}"
Margin="{TemplateBinding Margin}"
Background="{TemplateBinding Background}"
Opacity="0.4" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="ColumnHeaderGripperStyle" TargetType="{x:Type Thumb}">
<Setter Property="Width" Value="1" />
<Setter Property="Background" Value="#175c86" />
<Setter Property="Cursor" Value="SizeWE" />
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border
Width="{TemplateBinding Width}"
Margin="{TemplateBinding Margin}"
Background="{TemplateBinding Background}"
Opacity="0.4" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Height" Value="30" />
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/biogebj.png" Opacity="0.2" />
</Setter.Value>
</Setter>
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="{DynamicResource DataGridColumnHeaderColor}" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
<Grid>
<Border
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<GridSplitter
HorizontalAlignment="Right"
Background="#FF0BAE3F"
BorderBrush="#FFBD2A2A" />
<Thumb
x:Name="PART_RightHeaderGripper"
Width="2"
HorizontalAlignment="Right"
Background="#FF1D9B9E"
Style="{StaticResource ColumnHeaderGripperStyle}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="DataGridColumnHeader" TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Height" Value="30" />
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/databj.png" />
</Setter.Value>
</Setter>
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="White" />
<Setter Property="FontSize" Value="10" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
<Grid>
<Border
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>

<Thumb
x:Name="PART_RightHeaderGripper"
HorizontalAlignment="Right"
Style="{StaticResource ColumnHeaderGripperStyle}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="#FF31879E" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True">
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<!--<Setter Property="Background" Value="#FF2281EC"/>-->
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
<!--<Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>-->
</Trigger>
<!--<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static DataGrid.FocusBorderBrushKey}}"/>
</Trigger>-->
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>
</Style.Triggers>
</Style>

</ResourceDictionary>

Завантаження…
Відмінити
Зберегти