Selaa lähdekoodia

增加选项卡

样式分支
fyf 2 vuotta sitten
vanhempi
commit
763c4a099a
9 muutettua tiedostoa jossa 284 lisäystä ja 2 poistoa
  1. +8
    -0
      BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj
  2. +0
    -2
      BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs
  3. +11
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheTabControl.xaml
  4. +183
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheTabControl.xaml.cs
  5. BIN
     
  6. BIN
     
  7. +76
    -0
      BPASmartClient.SCADAControl/Themes/Generic.xaml
  8. +1
    -0
      BPASmartClient/MainWindow.xaml
  9. +5
    -0
      BeDesignerSCADA/Themes/Styles.xaml

+ 8
- 0
BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj Näytä tiedosto

@@ -30,6 +30,8 @@
<None Remove="Images\State1.png" />
<None Remove="Images\State11.png" />
<None Remove="Images\State2.png" />
<None Remove="Images\Tab4_No.png" />
<None Remove="Images\Tab4_Select.png" />
<None Remove="Images\timericon.png" />
<None Remove="Images\借出.png" />
<None Remove="Images\光柱.png" />
@@ -115,6 +117,12 @@
<Resource Include="Images\State2.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Tab4_No.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Tab4_Select.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\timericon.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>


+ 0
- 2
BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs Näytä tiedosto

@@ -314,8 +314,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls
private static readonly DependencyProperty EventSendNameListProperty =
DependencyProperty.Register("EventSendNameList",typeof(ObservableCollection<EventSendMessage>),typeof(Silos),new PropertyMetadata(new ObservableCollection<EventSendMessage>(),new PropertyChangedCallback(onEventNameListChanged)));
private static void onEventNameListChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.DataNameRefresh();


#endregion

#region 数据绑定模块


+ 11
- 0
BPASmartClient.SCADAControl/CustomerControls/TheTabControl.xaml Näytä tiedosto

@@ -0,0 +1,11 @@
<TabControl x:Class="BPASmartClient.SCADAControl.CustomerControls.TheTabControl"
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"
BorderBrush="Transparent"
d:DesignHeight="450" d:DesignWidth="800">
</TabControl>

+ 183
- 0
BPASmartClient.SCADAControl/CustomerControls/TheTabControl.xaml.cs Näytä tiedosto

@@ -0,0 +1,183 @@
using BPASmartClient.Compiler;
using BPASmartClient.SCADAControl;
using Newtonsoft.Json;
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>
/// TheTabControl.xaml 的交互逻辑
/// </summary>
public partial class TheTabControl : TabControl, IExecutable
{
public event EventHandler PropertyChange; //声明一个事件
public TheTabControl()
{
InitializeComponent();
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml", UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
Width = 150;
Height = 150;
this.Loaded += TheTabControl_Loaded;
this.SelectionChanged += TheTabControl_SelectionChanged;
}

private void TheTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
object _header = (this.SelectedItem as TabItem).Header;
TabItems?.ToList().ForEach(par =>
{
if (_header!=null && par.Header == (string)_header)
{
if(!string.IsNullOrEmpty(par.ClickStr))
Config.GetInstance().RunJsScipt(par.ClickStr);
}
});
}
catch (Exception ex)
{

throw;
}
}

private void TheTabControl_Loaded(object sender, RoutedEventArgs e)
{
TabItems.CollectionChanged += TabItems_CollectionChanged;
}

private void TabItems_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
this.Items.Clear();
if (TabItems.Count > 0)
{
try
{
TabItemsStr = JsonConvert.SerializeObject(TabItems);
TabItems?.ToList().ForEach(item => {

this.Items.Add(new TabItem { Header = item.Header, Style = (FindResource("TheTabItem") as Style) });
});
}
catch (Exception ex)
{
}
}
}

public string ControlType => "控件";

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

/// <summary>
/// 注册需要处理的事件
/// </summary>
public void Register()
{
if (!string.IsNullOrEmpty(TabItemsStr))
{
try
{
TabItems = JsonConvert.DeserializeObject<ObservableCollection<TheTabItemModel>>(TabItemsStr);
}
catch (Exception ex)
{

}
}
}

#region 属性
[Category("名称[自动生成]")]
private string TabItemsStr
{
get { return (string)GetValue(TabItemsStrProperty); }
set { SetValue(TabItemsStrProperty, value); }
}
private static readonly DependencyProperty TabItemsStrProperty =
DependencyProperty.Register("TabItemsStr", typeof(string), typeof(TheTabControl), new PropertyMetadata(string.Empty, new PropertyChangedCallback(onEventReceiveNameListStrChanged)));
private static void onEventReceiveNameListStrChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as TheTabControl)?.TabItemsStrPropertyRefresh();
[Category("集合")]
public ObservableCollection<TheTabItemModel> TabItems
{
get { return (ObservableCollection<TheTabItemModel>)GetValue(TabItemsProperty); }
set { SetValue(TabItemsProperty, value); }
}
private static readonly DependencyProperty TabItemsProperty =
DependencyProperty.Register("TabItems", typeof(ObservableCollection<TheTabItemModel>), typeof(TheTabControl), new PropertyMetadata(new ObservableCollection<TheTabItemModel>(), new PropertyChangedCallback(onEventNameListChanged)));
private static void onEventNameListChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as TheTabControl)?.TabItemsPropertyRefresh();
public void TabItemsStrPropertyRefresh()
{
if (!string.IsNullOrEmpty(TabItemsStr))
{
try
{
// TabItems = JsonConvert.DeserializeObject<ObservableCollection<TheTabItemModel>>(TabItemsStr);
}
catch (Exception ex)
{

}
}
}
public void TabItemsPropertyRefresh()
{

}
#endregion



}

public class TheTabItemModel
{
/// <summary>
/// 序号
/// </summary>
public int SortID { get; set; }
/// <summary>
/// 标题
/// </summary>
public string Header { get; set; }
/// <summary>
/// 单机事件
/// </summary>
public string ClickStr { get; set; }
public TheTabItemModel()
{
SortID = 0;
}
}
}



+ 76
- 0
BPASmartClient.SCADAControl/Themes/Generic.xaml Näytä tiedosto

@@ -1930,4 +1930,80 @@
</Setter.Value>
</Setter>
</Style>

<Style x:Key="TabItemFocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle
Margin="4,4,4,2"
SnapsToDevicePixels="true"
Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
StrokeDashArray="1 2"
StrokeThickness="1" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="TheTabItem" TargetType="{x:Type TabItem}">
<Setter Property="FocusVisualStyle" Value="{StaticResource TabItemFocusVisual}" />
<Setter Property="Foreground">
<Setter.Value>
#A5FFFFFF
</Setter.Value>
</Setter>
<Setter Property="Padding" Value="6,1,6,1" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Border
x:Name="Bd"
Height="35"
Margin="5"
Padding="{TemplateBinding Padding}"
BorderThickness="1"
CornerRadius="2">
<ContentPresenter
x:Name="Content"
HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"
VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"
ContentSource="Header"
Cursor="Hand"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Foreground" Value="{DynamicResource MeunSelectForeground}" />
<Setter TargetName="Bd" Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/Tab4_Select.png" />
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter Property="Foreground" Value="{DynamicResource MeunUnSelectForeground}" />
<Setter TargetName="Bd" Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/Tab4_No.png" />
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="#8f723c" />
<Setter TargetName="Bd" Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/Tab4_Select.png" />
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

+ 1
- 0
BPASmartClient/MainWindow.xaml Näytä tiedosto

@@ -200,6 +200,7 @@
Tag="Close" />
</MenuItem>
</Menu>
</Grid>

<StackPanel


+ 5
- 0
BeDesignerSCADA/Themes/Styles.xaml Näytä tiedosto

@@ -352,6 +352,11 @@
<Setter TargetName="txt" Property="Text" Value="MQTT" />
</DataTrigger>

<DataTrigger Binding="{Binding Name}" Value="TheTabControl">
<Setter TargetName="icon" Property="Kind" Value="PeriodicTable" />
<Setter TargetName="txt" Property="Text" Value="选项卡控件" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>



Ladataan…
Peruuta
Tallenna