Browse Source

更新可视化控件菜单

样式分支
fyf 2 years ago
parent
commit
a0ed955f16
15 changed files with 279 additions and 12 deletions
  1. +32
    -0
      BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj
  2. BIN
     
  3. BIN
     
  4. BIN
     
  5. BIN
     
  6. BIN
     
  7. BIN
     
  8. BIN
     
  9. BIN
     
  10. BIN
     
  11. BIN
     
  12. BIN
     
  13. +79
    -2
      BPASmartClient.SCADAControl/Themes/Generic.xaml
  14. +10
    -5
      BeDesignerSCADA/Controls/MenuRunCanvas.xaml
  15. +158
    -5
      BeDesignerSCADA/Controls/MenuRunCanvas.xaml.cs

+ 32
- 0
BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj View File

@@ -42,7 +42,15 @@
<None Remove="Images\上箭头.png" />
<None Remove="Images\借出.png" />
<None Remove="Images\光柱.png" />
<None Remove="Images\右1.png" />
<None Remove="Images\右2.png" />
<None Remove="Images\左1.png" />
<None Remove="Images\左2.png" />
<None Remove="Images\拉出.png" />
<None Remove="Images\收缩.png" />
<None Remove="Images\矩形边框.png" />
<None Remove="Images\矩形边框1.png" />
<None Remove="Images\系统名称.png" />
<None Remove="Images\退出.png" />
<None Remove="Images\顶部线条.png" />
</ItemGroup>
@@ -174,9 +182,33 @@
<Resource Include="Images\button2.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\右1.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\右2.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\左1.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\左2.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\拉出.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\收缩.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\矩形边框.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\矩形边框1.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\系统名称.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\退出.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


+ 79
- 2
BPASmartClient.SCADAControl/Themes/Generic.xaml View File

@@ -3064,7 +3064,7 @@
</Style>

<DataTemplate x:Key="X_PageBoxStyle">
<Button x:Name="dsd" Background="Transparent" BorderBrush="Transparent" BorderThickness="0" CommandParameter="{Binding .}" Command="{Binding DataContext.MenSelectPageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}">
<Button x:Name="dsd" HorizontalAlignment="Center" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" VerticalAlignment="Center" Background="Transparent" BorderBrush="Transparent" BorderThickness="0" CommandParameter="{Binding .}" Command="{Binding DataContext.MenSelectPageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}">
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
@@ -3087,6 +3087,12 @@
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Text="{Binding Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />

<TextBlock FontWeight="Bold" Margin="5,0,5,0" FontSize="14" Foreground="#FFFFA500"
Grid.Row="2"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Text="{Binding Sort,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</Grid>
</Button>
@@ -3107,15 +3113,86 @@
</Style.Setters>
</Style>

<Style x:Key="image系统名称" TargetType="Image">
<Style.Setters>
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Source" Value="../Images/系统名称.png" />
</Style.Setters>
</Style>


<Style x:Key="image矩阵框1" TargetType="WrapPanel">
<Style.Setters>
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/矩形边框.png" Stretch="UniformToFill" ></ImageBrush>
<ImageBrush ImageSource="../Images/矩形边框1.png" Stretch="UniformToFill" ></ImageBrush>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>

<Style x:Key="imageTextBlock" TargetType="TextBlock">
<Style.Setters>
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/系统名称.png" Stretch="Fill" ></ImageBrush>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>

<Style x:Key="image拉出" TargetType="Grid">
<Style.Setters>
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/拉出.png" Stretch="Fill" ></ImageBrush>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>

<Style x:Key="image收缩" TargetType="Grid">
<Style.Setters>
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/收缩.png" Stretch="Fill" ></ImageBrush>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>


<Style x:Key="image右1" TargetType="Image">
<Style.Setters>
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Source" Value="../Images/右1.png" />
</Style.Setters>
</Style>

<Style x:Key="image右2" TargetType="Image">
<Style.Setters>
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Source" Value="../Images/右2.png" />
</Style.Setters>
</Style>

<Style x:Key="image左1" TargetType="Image">
<Style.Setters>
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Source" Value="../Images/左1.png" />
</Style.Setters>
</Style>

<Style x:Key="image左2" TargetType="Image">
<Style.Setters>
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Source" Value="../Images/左2.png" />
</Style.Setters>
</Style>

</ResourceDictionary>

+ 10
- 5
BeDesignerSCADA/Controls/MenuRunCanvas.xaml View File

@@ -19,16 +19,21 @@
</Border>

<WrapPanel x:Name="wrapanl_main" Orientation="Vertical" Style="{DynamicResource image矩阵框1}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="0,5,0,25">
<TextBlock x:Name="TitleName" Foreground="#FFFFA500" FontSize="18" Width="100" TextWrapping="Wrap" MaxHeight="20" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding MenuModel.Name}" FontFamily="{DynamicResource Digital}"></TextBlock>
<ListBox x:Name="PageList" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Bottom"
<StackPanel x:Name="waibustack" Orientation="Horizontal" MouseMove="wrapanl_main_MouseMove" MouseLeave="wrapanl_main_MouseLeave" >
<WrapPanel Style="{DynamicResource image矩阵框1}" Margin="0,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Stretch" x:Name="wrapanl_main" Orientation="Vertical">
<TextBlock x:Name="TitleName" Style="{DynamicResource imageTextBlock}" Padding="10" Foreground="#FFFFA500" FontSize="18" TextWrapping="Wrap" MaxWidth="118" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding MenuModel.Name}" FontFamily="{DynamicResource Digital}"></TextBlock>
<ListBox x:Name="PageList" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Bottom"
SelectedItem="{Binding MenuModel.SelectPageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding MenuModel.pageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
Background="Transparent"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ItemTemplate="{DynamicResource X_PageBoxStyle}" FontSize="14" BorderThickness="0" >
</ListBox>
</WrapPanel>
</ListBox>
</WrapPanel>
<Border x:Name="lachu" Background="Transparent" Width="30" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0,0,0,25" BorderBrush="Aqua" BorderThickness="0,0,1,0">
<Image x:Name="lachuStyle" Style="{DynamicResource image右1}" Width="70" Height="30"></Image>
</Border>
</StackPanel>
</Grid>
</UserControl>

+ 158
- 5
BeDesignerSCADA/Controls/MenuRunCanvas.xaml.cs View File

@@ -16,9 +16,11 @@ using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace BeDesignerSCADA.Controls
{
@@ -28,12 +30,52 @@ namespace BeDesignerSCADA.Controls
public partial class MenuRunCanvas : UserControl
{
MenuRunCanvasModel menuRunCanvasModel = null;
ResourceDictionary languageResDic = new ResourceDictionary();
DispatcherTimer timer1;//控制菜单显示隐藏功能
public MenuRunCanvas()
{
InitializeComponent();
menuRunCanvasModel=new MenuRunCanvasModel();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml", UriKind.RelativeOrAbsolute);
menuRunCanvasModel =new MenuRunCanvasModel();
this.DataContext=menuRunCanvasModel;
timer1 = new DispatcherTimer();
timer1.Tick += new System.EventHandler(timer1_Tick);
timer1.Interval = new TimeSpan(0, 0, 0, 0, 1000);
timer1.Start();
this.Loaded += MenuRunCanvas_Loaded;
}

private void MenuRunCanvas_Loaded(object sender, RoutedEventArgs e)
{
if (menuRunCanvasModel.MenuModel != null)
{
switch (menuRunCanvasModel.MenuModel.Alignment)
{
case MenuAlignment.左边:
menuWidth = wrapanl_main.ActualWidth;
break;
case MenuAlignment.顶部:
menuWidth = wrapanl_main.ActualHeight;
break;
case MenuAlignment.右边:
menuWidth = wrapanl_main.ActualWidth;
break;
case MenuAlignment.底部:
menuWidth = wrapanl_main.ActualHeight;
break;
default:
break;
}
MenuSmall();
}
}

private void timer1_Tick(object sender, EventArgs e)
{
times += 1;
}

/// <summary>
/// 根据路径运行程序
/// </summary>
@@ -59,7 +101,13 @@ namespace BeDesignerSCADA.Controls
wrapanl_main.Orientation = Orientation.Vertical;
wrapanl_main.HorizontalAlignment = HorizontalAlignment.Left;
wrapanl_main.VerticalAlignment = VerticalAlignment.Stretch;
wrapanl_main.Margin = new Thickness(0, 0, 0, 25);
TitleName.Margin = new Thickness(0, 10, 0, 10);
waibustack.Orientation = Orientation.Horizontal;
waibustack.HorizontalAlignment = HorizontalAlignment.Left;
lachu.HorizontalAlignment = HorizontalAlignment.Left;
lachu.VerticalAlignment = VerticalAlignment.Stretch;
lachu.BorderThickness = new Thickness(1, 0, 0, 0);
break;
case MenuAlignment.顶部:
PageList.HorizontalAlignment = HorizontalAlignment.Left;
@@ -68,8 +116,15 @@ namespace BeDesignerSCADA.Controls
wrapanl_main.Orientation = Orientation.Horizontal;
wrapanl_main.HorizontalAlignment = HorizontalAlignment.Stretch;
wrapanl_main.VerticalAlignment = VerticalAlignment.Top;
TitleName.LayoutTransform = new RotateTransform(){ Angle = 270 };
wrapanl_main.Margin = new Thickness(0, 0, 0, 0);
TitleName.LayoutTransform = new RotateTransform(){ Angle = 0 };
TitleName.Margin = new Thickness(10, 0,10, 0);
waibustack.Orientation = Orientation.Vertical;
waibustack.VerticalAlignment = VerticalAlignment.Top;
lachu.HorizontalAlignment = HorizontalAlignment.Stretch;
lachu.VerticalAlignment = VerticalAlignment.Top;
lachu.LayoutTransform = new RotateTransform() { Angle = 270 };
lachu.BorderThickness = new Thickness(0, 0, 1, 0);
break;
case MenuAlignment.右边:
PageList.HorizontalAlignment = HorizontalAlignment.Right;
@@ -78,7 +133,14 @@ namespace BeDesignerSCADA.Controls
wrapanl_main.Orientation = Orientation.Vertical;
wrapanl_main.HorizontalAlignment = HorizontalAlignment.Right;
wrapanl_main.VerticalAlignment = VerticalAlignment.Stretch;
wrapanl_main.Margin = new Thickness(0, 0, 0, 25);
TitleName.Margin = new Thickness(0, 10, 0, 10);
menuWidth = wrapanl_main.ActualWidth;
waibustack.Orientation = Orientation.Horizontal;
waibustack.HorizontalAlignment = HorizontalAlignment.Right;
lachu.HorizontalAlignment = HorizontalAlignment.Right;
lachu.VerticalAlignment = VerticalAlignment.Stretch;
lachu.BorderThickness = new Thickness(0, 0,0, 0);
break;
case MenuAlignment.底部:
PageList.HorizontalAlignment = HorizontalAlignment.Left;
@@ -87,16 +149,24 @@ namespace BeDesignerSCADA.Controls
wrapanl_main.Orientation = Orientation.Horizontal;
wrapanl_main.HorizontalAlignment = HorizontalAlignment.Stretch;
wrapanl_main.VerticalAlignment = VerticalAlignment.Bottom;
TitleName.LayoutTransform = new RotateTransform() { Angle = 270 };
wrapanl_main.Margin = new Thickness(0, 0, 0, 0);
TitleName.LayoutTransform = new RotateTransform() { Angle = 0 };
TitleName.Margin = new Thickness(10, 0, 10, 0);
menuWidth = wrapanl_main.ActualHeight;
waibustack.Orientation = Orientation.Vertical;
waibustack.VerticalAlignment = VerticalAlignment.Bottom;
lachu.HorizontalAlignment = HorizontalAlignment.Stretch;
lachu.VerticalAlignment = VerticalAlignment.Bottom;
lachu.LayoutTransform = new RotateTransform() { Angle = 270 };
lachu.BorderThickness= new Thickness(0, 0, 0, 0);
break;
default:
break;
}
if(canvas.IsVisibility)
wrapanl_main.Visibility = Visibility.Visible;
waibustack.Visibility = Visibility.Visible;
else
wrapanl_main.Visibility = Visibility.Collapsed;
waibustack.Visibility = Visibility.Collapsed;
itemsPanelTemplate.VisualTree = _StackPanel;
PageList.ItemsPanel = itemsPanelTemplate;
menuRunCanvasModel.MenuModel = canvas;
@@ -123,6 +193,89 @@ namespace BeDesignerSCADA.Controls
menuRunCanvasModel.MenuModel.SelectPageModels.runCanvas.RunSelect();
}
}
bool ismove = true;
int times = 0;
/// <summary>
/// 鼠标移动
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void wrapanl_main_MouseMove(object sender, MouseEventArgs e)
{
if (times < 1)
{
return;
}
if (ismove)
{
ismove = false;
MenuBig();

}
times = 0;
}
/// <summary>
/// 鼠标离开
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void wrapanl_main_MouseLeave(object sender, MouseEventArgs e)
{
menuWidthDefault = 0;
if (!ismove)
{
ismove = true;
MenuSmall();
}
times = 0;
}
private int menuWidthDefault = 0;
private double menuWidth = 86;
private void MenuBig()
{

DoubleAnimation da = new DoubleAnimation();
da.From = menuWidthDefault;
da.To = menuWidth;
da.Duration = TimeSpan.FromSeconds(0.5);
if (menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.左边 || menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.右边)
{
wrapanl_main.BeginAnimation(WidthProperty, da);
if (languageResDic.Contains("image左1"))
lachuStyle.Style = languageResDic["image左1"] as Style;
}
else if (menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.顶部 || menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.底部)
{
wrapanl_main.BeginAnimation(HeightProperty, da);
if (languageResDic.Contains("image右1"))
lachuStyle.Style = languageResDic["image右1"] as Style;
}

}
private void MenuSmall()
{

DoubleAnimation da = new DoubleAnimation();
da.From = menuWidth;
da.To = menuWidthDefault;
da.Duration = TimeSpan.FromSeconds(0.5);
if (menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.左边 || menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.右边)
{
if (languageResDic.Contains("image右1"))
lachuStyle.Style = languageResDic["image右1"] as Style;
wrapanl_main.BeginAnimation(WidthProperty, da);
}
else if (menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.顶部 || menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.底部)
{
wrapanl_main.BeginAnimation(HeightProperty, da);
if (languageResDic.Contains("image左1"))
lachuStyle.Style = languageResDic["image左1"] as Style;
}
}

}

public class MenuRunCanvasModel : ObservableObject


Loading…
Cancel
Save