Browse Source

11

样式分支
fyf 2 years ago
parent
commit
eb8397fd9c
3 changed files with 95 additions and 0 deletions
  1. +9
    -0
      BPASmartClient.SCADAControl/TheButton.xaml
  2. +73
    -0
      BPASmartClient.SCADAControl/TheButton.xaml.cs
  3. +13
    -0
      BPASmartClient.SCADAControl/Themes/Generic.xaml

+ 9
- 0
BPASmartClient.SCADAControl/TheButton.xaml View File

@@ -0,0 +1,9 @@
<Button x:Class="BPASmartClient.SCADAControl.TheButton"
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"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
</Button>

+ 73
- 0
BPASmartClient.SCADAControl/TheButton.xaml.cs View File

@@ -0,0 +1,73 @@
using BPASmartClient.Compiler;
using System;
using System.Collections.Generic;
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
{
/// <summary>
/// TheButton.xaml 的交互逻辑
/// </summary>
public partial class TheButton : Button, IExecutable
{
public TheButton()
{
InitializeComponent();
Content = "按钮";
Width = 80;
Height = 30;
Style = Application.Current.Resources["DesignButton"] as Style;//FindResource("DesignButton") as Style;
}

public string ControlType => "控件";

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

[Category("事件")]
public string ClickExec
{
get { return (string)GetValue(ClickExecProperty); }
set { SetValue(ClickExecProperty, value); }
}
public static readonly DependencyProperty ClickExecProperty =
DependencyProperty.Register("ClickExec", typeof(string), typeof(TheButton), new PropertyMetadata(string.Empty));

/// <summary>
/// 注册需要处理的事件
/// </summary>
public void Register()
{
this.Click += MyButton_Click;
}

private void MyButton_Click(object sender, RoutedEventArgs e)
{
Config.GetInstance().RunJsScipt(ClickExec);
}
}
}

+ 13
- 0
BPASmartClient.SCADAControl/Themes/Generic.xaml View File

@@ -132,4 +132,17 @@
</Setter>
</Style>

<Style TargetType="Button" x:Key="DesignButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border BorderThickness="1" BorderBrush="{StaticResource ControlBorderBrush}" Background="{StaticResource ControlBackground}">
<TextBlock Text="{TemplateBinding Content}" FontSize="{TemplateBinding FontSize}"
FontWeight="{TemplateBinding FontWeight}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

</ResourceDictionary>

Loading…
Cancel
Save