Просмотр исходного кода

增加可视化菜单界面

样式分支
fyf 2 лет назад
Родитель
Сommit
6d297a1710
20 измененных файлов: 513 добавлений и 438 удалений
  1. +20
    -0
      BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj
  2. Двоичные данные
     
  3. Двоичные данные
     
  4. Двоичные данные
     
  5. Двоичные данные
     
  6. Двоичные данные
     
  7. +123
    -14
      BPASmartClient.SCADAControl/Themes/Generic.xaml
  8. +85
    -32
      BeDesignerSCADA/Common/MenuModel.cs
  9. +2
    -164
      BeDesignerSCADA/Controls/CanvasPanelNew.xaml
  10. +13
    -7
      BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs
  11. +1
    -3
      BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs
  12. +24
    -6
      BeDesignerSCADA/Controls/MenuRunCanvas.xaml
  13. +140
    -89
      BeDesignerSCADA/Controls/MenuRunCanvas.xaml.cs
  14. +0
    -25
      BeDesignerSCADA/MainWindow.xaml.cs
  15. +3
    -0
      BeDesignerSCADA/Themes/Styles.xaml
  16. +1
    -1
      BeDesignerSCADA/View/RunWindows.xaml
  17. +4
    -3
      BeDesignerSCADA/View/RunWindows.xaml.cs
  18. +25
    -0
      BeDesignerSCADA/View/RunWindowsLao.xaml
  19. +32
    -0
      BeDesignerSCADA/View/RunWindowsLao.xaml.cs
  20. +40
    -94
      BeDesignerSCADA/ViewModel/MainViewModelNew.cs

+ 20
- 0
BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj Просмотреть файл

@@ -19,6 +19,8 @@
<None Remove="Images\Cb_Checked.png" />
<None Remove="Images\Cb_HalfChecked.png" />
<None Remove="Images\databj.png" />
<None Remove="Images\Exp.png" />
<None Remove="Images\leftImage.png" />
<None Remove="Images\mqtt.png" />
<None Remove="Images\mqttrun.png" />
<None Remove="Images\mqttstop.png" />
@@ -37,9 +39,12 @@
<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" />
<None Remove="Images\光柱.png" />
<None Remove="Images\矩形边框.png" />
<None Remove="Images\退出.png" />
<None Remove="Images\顶部线条.png" />
</ItemGroup>

<ItemGroup>
@@ -91,6 +96,12 @@
<Resource Include="Images\databj.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Exp.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\leftImage.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\mqtt.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
@@ -145,6 +156,9 @@
<Resource Include="Images\timericon.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\上箭头.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\借出.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
@@ -160,9 +174,15 @@
<Resource Include="Images\button2.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>
</ItemGroup>

</Project>

Двоичные данные
Просмотреть файл


Двоичные данные
Просмотреть файл


Двоичные данные
Просмотреть файл


Двоичные данные
Просмотреть файл


Двоичные данные
Просмотреть файл


+ 123
- 14
BPASmartClient.SCADAControl/Themes/Generic.xaml Просмотреть файл

@@ -265,18 +265,6 @@
</Setter>
</Style>

<!--<Style BasedOn="{StaticResource {x:Type Slider}}" TargetType="{x:Type ctrl:TheSlider}">
<Setter Property="Width" Value="140" />
<Setter Property="Maximum" Value="100" />
<Setter Property="IsSnapToTickEnabled" Value="True" />
<Setter Property="Minimum" Value="0" />
<Setter Property="AutoToolTipPlacement" Value="BottomRight" />
<Setter Property="SmallChange" Value="0.1" />
<Setter Property="LargeChange" Value="0.1" />
</Style>-->

<!--<Style TargetType="{x:Type ctrl:TheTextBox}" BasedOn="{StaticResource {x:Type TextBox}}"/>-->

<Style TargetType="{x:Type ctrl:TheTimer}">
<Setter Property="Template">
<Setter.Value>
@@ -1129,8 +1117,6 @@

</Style>



<Style TargetType="{x:Type ctrl:TheDataGrid}">
<Setter Property="AutoGenerateColumns" Value="False" />
<Setter Property="Background" Value="Transparent" />
@@ -2975,4 +2961,127 @@
</Style>
<!--#endregion-->

<!--#region 菜单栏-->
<Style x:Key="caidan_1" TargetType="{x:Type RadioButton}">
<Style.Setters>
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Margin" Value="10,10,0,0" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/button2.png" />
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" />
<Setter Property="Height" Value="30" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Border
x:Name="BD"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Cursor="Hand">
<StackPanel
HorizontalAlignment="Center"
Cursor="Hand"
Orientation="Horizontal">
<TextBlock
x:Name="textBlock"
Margin="15,5,15,5"
VerticalAlignment="Center"
Cursor="Hand"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
FontWeight="{TemplateBinding FontWeight}"
Foreground="{TemplateBinding Foreground}"
Text="{TemplateBinding Content}" />
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="BD" Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/Tab4_Select.png" />
</Setter.Value>
</Setter>
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource MeunSelectForeground}" />
</Trigger>
<Trigger Property="IsChecked" Value="False">
<Setter TargetName="BD" Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/Tab4_No.png" />
</Setter.Value>
</Setter>
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonUnSelectForeground}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style.Setters>
</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}}">
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid Height="50" Width="100" >
<Grid.Background>
<ImageBrush ImageSource="../Images/bj.png" Stretch="UniformToFill"/>
</Grid.Background>
</Grid>
<Rectangle Height="50" Width="100" Stroke="CadetBlue" StrokeThickness="1">
<Rectangle.Fill>
<VisualBrush Visual="{Binding visual,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</Rectangle.Fill>
</Rectangle>
<Rectangle Width="100" Height="20" Grid.Row="1" Fill="Transparent" Stroke="CadetBlue" StrokeThickness="1,0,1,1"/>
<TextBlock FontWeight="Bold" Margin="5,0,0,0" FontSize="14" Foreground="#FFFFA500"
x:Name="txt"
Grid.Row="2"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Text="{Binding Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</Grid>
</Button>

<DataTemplate.Triggers>
</DataTemplate.Triggers>
</DataTemplate>


<!--#endregion-->
<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>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>


</ResourceDictionary>

+ 85
- 32
BeDesignerSCADA/Common/MenuModel.cs Просмотреть файл

@@ -2,9 +2,12 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Markup;

namespace BeDesignerSCADA.Common
{
@@ -17,7 +20,7 @@ namespace BeDesignerSCADA.Common
/// <summary>
/// 是否显示菜单
/// </summary>
private bool _IsVisibility;
private bool _IsVisibility = true;
public bool IsVisibility
{
get
@@ -33,7 +36,7 @@ namespace BeDesignerSCADA.Common
/// <summary>
/// 程序集名称
/// </summary>
private string _Name;
private string _Name = "可视化程序";
public string Name
{
get
@@ -49,7 +52,7 @@ namespace BeDesignerSCADA.Common
/// <summary>
/// 菜单显示方向
/// </summary>
private MenuAlignment _Alignment;
private MenuAlignment _Alignment = MenuAlignment.左边;
public MenuAlignment Alignment
{
get
@@ -62,10 +65,40 @@ namespace BeDesignerSCADA.Common
OnPropertyChanged("Alignment");
}
}

/// <summary>
/// 选中页面
/// </summary>
private PageModel _SelectPageModels;
public PageModel SelectPageModels
{
get
{
return _SelectPageModels;
}
set
{
_SelectPageModels = value;
OnPropertyChanged("SelectPageModels");
}
}

/// <summary>
/// 页面控件集合
/// 页面Model
/// </summary>
public Dictionary<string, PageBase> PageChildren = new Dictionary<string, PageBase>();
private ObservableCollection<PageModel> _pageModels;
public ObservableCollection<PageModel> pageModels
{
get
{
return _pageModels;
}
set
{
_pageModels = value;
OnPropertyChanged("pageModels");
}
}
}
/// <summary>
/// 菜单选择枚举
@@ -78,19 +111,9 @@ namespace BeDesignerSCADA.Common
底部,
}
/// <summary>
/// 页面Model
/// </summary>
public class PageModel : PageBase
{
/// <summary>
/// 页面控件集合
/// </summary>
public CanvasPanel visual { get; set; }
}
/// <summary>
/// 页面
/// </summary>
public class PageBase : ObservableObject
public class PageModel : ObservableObject
{
/// <summary>
/// 是否首页
@@ -111,37 +134,33 @@ namespace BeDesignerSCADA.Common
/// <summary>
/// 排序
/// </summary>
public int Sort { get; set; }
/// <summary>
/// 页面名称
/// </summary>
private string _Name;
public string Name
private int _Sort;
public int Sort
{
get
{
return _Name;
return _Sort;
}
set
{
_Name = value;
OnPropertyChanged("Name");
_Sort = value;
OnPropertyChanged("Sort");
}
}
/// <summary>
/// 菜单名称
/// 页面名称
/// </summary>
private string _MenuName;
public string MenuName
private string _Name;
public string Name
{
get
{
return _MenuName;
return _Name;
}
set
{
_MenuName = value;
OnPropertyChanged("MenuName");
_Name = value;
OnPropertyChanged("Name");
}
}
/// <summary>
@@ -153,9 +172,43 @@ namespace BeDesignerSCADA.Common
/// </summary>
public List<string> ChildrenStr { get; set; }

public PageBase()
/// <summary>
/// 页面控件集合,不被序列化
/// </summary>
private CanvasPanel _visual { get; set; }
[Newtonsoft.Json.JsonIgnore]
public CanvasPanel visual
{
get
{
return _visual;
}
set
{
_visual = value;
try
{
List<string> ChildrenStr = new List<string>();
foreach (FrameworkElement element in _visual?.Children)
{
string xamlText = XamlWriter.Save(element);
ChildrenStr.Add(xamlText);
}
ChildrenStr = ChildrenStr;
}
catch (Exception ex)
{

}

OnPropertyChanged("visual");
}
}
public PageModel()
{
ChildrenStr = new List<string>();
visual = new CanvasPanel();
Id = Guid.NewGuid().ToString();
}
}


+ 2
- 164
BeDesignerSCADA/Controls/CanvasPanelNew.xaml Просмотреть файл

@@ -18,168 +18,6 @@
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" />
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
<!--#region Menu-->
<SolidColorBrush x:Key="Menu.Static.Background" Color="#FFF0F0F0" />
<SolidColorBrush x:Key="Expander.Static.Circle.Stroke" Color="#FF333333" />
<SolidColorBrush x:Key="Expander.Static.Circle.Fill" Color="#FFFFFFFF" />
<SolidColorBrush x:Key="Expander.Static.Arrow.Stroke" Color="#FF333333" />
<SolidColorBrush x:Key="Expander.MouseOver.Circle.Stroke" Color="#FF5593FF" />
<SolidColorBrush x:Key="Expander.MouseOver.Circle.Fill" Color="#FFF3F9FF" />
<SolidColorBrush x:Key="Expander.MouseOver.Arrow.Stroke" Color="#FF000000" />
<SolidColorBrush x:Key="Expander.Pressed.Circle.Stroke" Color="#FF3C77DD" />
<SolidColorBrush x:Key="Expander.Pressed.Circle.Fill" Color="#FFD9ECFF" />
<SolidColorBrush x:Key="Expander.Pressed.Arrow.Stroke" Color="#FF000000" />
<SolidColorBrush x:Key="Expander.Disabled.Circle.Stroke" Color="#FFBCBCBC" />
<SolidColorBrush x:Key="Expander.Disabled.Circle.Fill" Color="#FFE6E6E6" />
<SolidColorBrush x:Key="Expander.Disabled.Arrow.Stroke" Color="#FF707070" />
<Style x:Key="ExpanderHeaderFocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Border>
<Rectangle
Margin="0"
SnapsToDevicePixels="true"
Stroke="Black"
StrokeDashArray="1 2"
StrokeThickness="1" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ExpanderDownHeaderStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Padding="{TemplateBinding Padding}" Cursor="Hand">
<Grid
Height="25"
Margin="5"
SnapsToDevicePixels="False">
<Grid.Background>
<ImageBrush ImageSource="../Images/Exp.png" />
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Ellipse
x:Name="circle"
Width="19"
Height="19"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Fill="{StaticResource Expander.Static.Circle.Fill}"
Stroke="{StaticResource Expander.Static.Circle.Stroke}"
Visibility="Collapsed" />
<Path
x:Name="arrow"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M 1,1.5 L 4.5,5 L 8,1.5"
SnapsToDevicePixels="false"
Stroke="{StaticResource Expander.Static.Arrow.Stroke}"
StrokeThickness="2"
Visibility="Collapsed" />
<ContentPresenter
Grid.Column="1"
Margin="4,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
RecognizesAccessKey="True"
SnapsToDevicePixels="True" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="arrow" Property="Data" Value="M 1,4.5 L 4.5,1 L 8,4.5" />
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="circle" Property="Stroke" Value="{StaticResource Expander.MouseOver.Circle.Stroke}" />
<Setter TargetName="circle" Property="Fill" Value="{StaticResource Expander.MouseOver.Circle.Fill}" />
<Setter TargetName="arrow" Property="Stroke" Value="{StaticResource Expander.MouseOver.Arrow.Stroke}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="circle" Property="Stroke" Value="{StaticResource Expander.Pressed.Circle.Stroke}" />
<Setter TargetName="circle" Property="StrokeThickness" Value="1.5" />
<Setter TargetName="circle" Property="Fill" Value="{StaticResource Expander.Pressed.Circle.Fill}" />
<Setter TargetName="arrow" Property="Stroke" Value="{StaticResource Expander.Pressed.Arrow.Stroke}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="circle" Property="Stroke" Value="{StaticResource Expander.Disabled.Circle.Stroke}" />
<Setter TargetName="circle" Property="Fill" Value="{StaticResource Expander.Disabled.Circle.Fill}" />
<Setter TargetName="arrow" Property="Stroke" Value="{StaticResource Expander.Disabled.Arrow.Stroke}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="expang_1" TargetType="{x:Type Expander}">
<Setter Property="Foreground" Value="#FF5593FF" />
<Setter Property="FontSize" Value="16" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Expander}">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="3"
SnapsToDevicePixels="true">
<DockPanel>
<ToggleButton
x:Name="HeaderSite"
MinWidth="0"
MinHeight="0"
Margin="1"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
DockPanel.Dock="Top"
FocusVisualStyle="{StaticResource ExpanderHeaderFocusVisual}"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
FontStretch="{TemplateBinding FontStretch}"
FontStyle="{TemplateBinding FontStyle}"
FontWeight="{TemplateBinding FontWeight}"
Foreground="{TemplateBinding Foreground}"
IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource ExpanderDownHeaderStyle}" />
<ContentPresenter
x:Name="ExpandSite"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
DockPanel.Dock="Bottom"
Focusable="false"
Visibility="Collapsed" />
</DockPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="true">
<Setter TargetName="ExpandSite" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<!--#endregion-->
</ResourceDictionary>
</UserControl.Resources>
<Grid x:Name="grid">
@@ -193,7 +31,7 @@
<TabControl SelectedIndex="0">
<TabItem Header="页面编辑">
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Background="Transparent" >
<ListBox x:Name="PageList" Grid.Row="0" Margin="0,5,0,0" HorizontalAlignment="Center" SelectedItem="{Binding SelectPageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding pageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Background="Transparent" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemTemplate="{DynamicResource PageBoxStyle}" FontSize="14" BorderThickness="0" >
<ListBox x:Name="PageList" Grid.Row="0" Margin="0,5,0,0" HorizontalAlignment="Center" SelectedItem="{Binding MenuModel.SelectPageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding MenuModel.pageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Background="Transparent" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemTemplate="{DynamicResource PageBoxStyle}" FontSize="14" BorderThickness="0" >
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="设置首页" Command="{Binding SetHomePageCommand}">
@@ -405,7 +243,7 @@
</TransformGroup>
</Compiler:CanvasPanel.RenderTransform>
</Compiler:CanvasPanel>
<ctl:RunCanvas x:Name="runCanvas" Visibility="{Binding RunCanvasVisibility}" />
<ctl:RunCanvas x:Name="runCanvas" Visibility="{Binding DataContext.RunCanvasVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
</Grid>
</ScrollViewer>


+ 13
- 7
BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs Просмотреть файл

@@ -259,11 +259,17 @@ namespace BeDesignerSCADA.Controls
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
RunWindows runWindows = null;
private void MNRunBtn_Click(object sender, RoutedEventArgs e)
{
cav.ClearSelection();
RunWindows runWindows = new RunWindows();
runWindows.LoadingData(cav.Generator());
if (runWindows != null)
{
runWindows.Close();
runWindows = null;
}
runWindows = new RunWindows();
runWindows.LoadingData(viewModel.MenuModel);
runWindows.Show();
}
/// <summary>
@@ -319,16 +325,16 @@ namespace BeDesignerSCADA.Controls
/// <param name="e"></param>
private void SavePage_Click(object sender, RoutedEventArgs e)
{
if (viewModel.SelectPageModels == null)
viewModel.SelectPageModels = viewModel.pageModels[0];
viewModel.SelectPageModels.visual.Children.Clear();
if (viewModel.MenuModel.SelectPageModels == null)
viewModel.MenuModel.SelectPageModels = viewModel.MenuModel.pageModels[0];
viewModel.MenuModel.SelectPageModels.visual?.Children.Clear();
foreach (FrameworkElement element in cav.Children)
{
string xamlText = XamlWriter.Save(element);
FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement;
viewModel.SelectPageModels.visual.Children.Add(item);
viewModel.MenuModel.SelectPageModels.visual.Children.Add(item);
}
viewModel.UpdatePageBase(viewModel.SelectPageModels);
viewModel.UpdatePageBase(viewModel.MenuModel.SelectPageModels);
}
#endregion



+ 1
- 3
BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs Просмотреть файл

@@ -165,7 +165,7 @@ namespace BeDesignerSCADA.Controls
private void MNRunBtn_Click(object sender, RoutedEventArgs e)
{
cav.ClearSelection();
RunWindows runWindows=new RunWindows();
RunWindowsLao runWindows = new RunWindowsLao();
runWindows.LoadingData(cav.Generator());
runWindows.Show();
}
@@ -510,8 +510,6 @@ namespace BeDesignerSCADA.Controls

}
}


#endregion




+ 24
- 6
BeDesignerSCADA/Controls/MenuRunCanvas.xaml Просмотреть файл

@@ -8,13 +8,16 @@
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<con:ZoomConverter x:Key="ZoomX" IsHeight="False" />
<con:ZoomConverter x:Key="ZoomY" IsHeight="True" />
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
<con:ZoomConverter x:Key="ZoomX" IsHeight="False" />
<con:ZoomConverter x:Key="ZoomY" IsHeight="True" />
</ResourceDictionary>
</UserControl.Resources>
<Grid ClipToBounds="True">
<Grid>
</Grid>

<Grid>
<Canvas
x:Name="RootCanvas"
@@ -32,7 +35,6 @@
</Canvas.RenderTransform>
</Canvas>
</Grid>

<Grid VerticalAlignment="Bottom" Background="#4B959595">
<StackPanel
@@ -49,5 +51,21 @@
Content="缩放" />
</StackPanel>
</Grid>


<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"
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>
</Grid>
</UserControl>

+ 140
- 89
BeDesignerSCADA/Controls/MenuRunCanvas.xaml.cs Просмотреть файл

@@ -1,6 +1,7 @@
using BeDesignerSCADA.Common;
using BPASmartClient.Compiler;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -53,83 +54,112 @@ namespace BeDesignerSCADA.Controls
/// </summary>
public void LoadingData(string path)
{
menuRunCanvasModel.MenuModel = BinaryFile.ReadBinary<MenuModel>(path) as MenuModel;
menuRunCanvasModel.pageModels.Clear();
menuRunCanvasModel.MenuModel?.PageChildren?.ToList().ForEach(par =>
RunMenu(BinaryFile.ReadBinary<MenuModel>(path) as MenuModel);
}

/// <summary>
/// 运行菜单
/// </summary>
/// <param name="canvas"></param>
public void RunMenu(MenuModel canvas)
{
ItemsPanelTemplate itemsPanelTemplate = new ItemsPanelTemplate();
FrameworkElementFactory _StackPanel = new FrameworkElementFactory(typeof(StackPanel));
switch (canvas.Alignment)
{
PageModel page = new PageModel
{
Id = par.Value.Id,
ChildrenStr = par.Value.ChildrenStr,
IsHome = par.Value.IsHome,
MenuName = par.Value.MenuName,
Name = par.Value.Name,
Sort = par.Value.Sort,
};
page.visual = new CanvasPanel();
par.Value?.ChildrenStr?.ForEach(k =>
case MenuAlignment.左边:
PageList.HorizontalAlignment = HorizontalAlignment.Left;
PageList.VerticalAlignment = VerticalAlignment.Top;
_StackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Vertical);
wrapanl_main.Orientation = Orientation.Vertical;
wrapanl_main.HorizontalAlignment = HorizontalAlignment.Left;
wrapanl_main.VerticalAlignment = VerticalAlignment.Stretch;
TitleName.Margin = new Thickness(0, 10, 0, 10);
break;
case MenuAlignment.顶部:
PageList.HorizontalAlignment = HorizontalAlignment.Left;
PageList.VerticalAlignment = VerticalAlignment.Top;
_StackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
wrapanl_main.Orientation = Orientation.Horizontal;
wrapanl_main.HorizontalAlignment = HorizontalAlignment.Stretch;
wrapanl_main.VerticalAlignment = VerticalAlignment.Top;
TitleName.LayoutTransform = new RotateTransform(){ Angle = 270 };
TitleName.Margin = new Thickness(10, 0,10, 0);
break;
case MenuAlignment.右边:
PageList.HorizontalAlignment = HorizontalAlignment.Right;
PageList.VerticalAlignment = VerticalAlignment.Top;
_StackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Vertical);
wrapanl_main.Orientation = Orientation.Vertical;
wrapanl_main.HorizontalAlignment = HorizontalAlignment.Right;
wrapanl_main.VerticalAlignment = VerticalAlignment.Stretch;
TitleName.Margin = new Thickness(0, 10, 0, 10);
break;
case MenuAlignment.底部:
PageList.HorizontalAlignment = HorizontalAlignment.Left;
PageList.VerticalAlignment = VerticalAlignment.Bottom;
_StackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
wrapanl_main.Orientation = Orientation.Horizontal;
wrapanl_main.HorizontalAlignment = HorizontalAlignment.Stretch;
wrapanl_main.VerticalAlignment = VerticalAlignment.Bottom;
TitleName.LayoutTransform = new RotateTransform() { Angle = 270 };
TitleName.Margin = new Thickness(10, 0, 10, 0);
break;
default:
break;
}
if(canvas.IsVisibility)
wrapanl_main.Visibility = Visibility.Visible;
else
wrapanl_main.Visibility = Visibility.Collapsed;
itemsPanelTemplate.VisualTree = _StackPanel;
PageList.ItemsPanel = itemsPanelTemplate;
menuRunCanvasModel.canvas1 = RootCanvas;
menuRunCanvasModel.MenuModel = canvas;
menuRunCanvasModel.MenuModel?.pageModels?.ToList().ForEach(par =>
{
par.visual = new CanvasPanel();
par?.ChildrenStr?.ForEach(k =>
{
FrameworkElement item = XamlReader.Parse(k) as FrameworkElement;
page.visual.Children.Add(item);
par.visual.Children.Add(item);
});
menuRunCanvasModel.pageModels.Add(page);
});
if (menuRunCanvasModel.pageModels.Count > 0)
if (menuRunCanvasModel.MenuModel.pageModels.Count > 0)
{
menuRunCanvasModel.SelectPageModels = menuRunCanvasModel.pageModels[0];
menuRunCanvasModel.MenuModel.SelectPageModels = menuRunCanvasModel.MenuModel.pageModels[0];
}

//try
//{
// SelectPageModels = obj as PageModel;
// try
// {
// canvasPanel.Children.Clear();
// foreach (FrameworkElement element in (SelectPageModels?.visual as CanvasPanel).Children)
// {
// string xamlText = XamlWriter.Save(element);
// FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement;
// canvasPanel.Children.Add(item);
// }
// canvasPanel.SelectedItems?.Clear();
// }
// catch (Exception ex)
// {

// }
//}
//catch (Exception ex)
//{

//}






SelectMenu();
}

/// <summary>
/// 选中菜单
/// </summary>
public void SelectMenu()
{
try
{
List<FrameworkElement> Children = new List<FrameworkElement>();
if (menuRunCanvasModel.MenuModel.SelectPageModels != null)
{
foreach (FrameworkElement element in (menuRunCanvasModel?.MenuModel.SelectPageModels?.visual as CanvasPanel).Children)
{
string xamlText = XamlWriter.Save(element);
FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement;
Children.Add(item);
}
}
Run(Children);
}
catch (Exception ex)
{

}

}


////加载控件
//List<FrameworkElement> Children = new List<FrameworkElement>();
//FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
//using (StreamReader sr = new StreamReader(fs, System.Text.Encoding.Unicode))
//{
// while (sr.Peek() > -1)
// {
// string str = sr.ReadLine();
// var ele = XamlReader.Parse(str) as FrameworkElement;
// Children.Add(ele);
// }
//}
//if (Children.Count > 0)
//{
// Run(Children);
//}
}
/// <summary>
/// 运行
/// </summary>
@@ -231,44 +261,65 @@ namespace BeDesignerSCADA.Controls
OnPropertyChanged("MenuModel");
}
}
public RelayCommand<object> MenSelectPageCommand { get; set; }
public Canvas canvas1;
public MenuRunCanvasModel()
{
MenuModel = new MenuModel();
MenuModel.pageModels = new ObservableCollection<PageModel>();
MenuModel.pageModels.Add(new PageModel { Name = "首页面", Sort = 0 });
MenuModel.SelectPageModels = MenuModel.pageModels[0];
MenSelectPageCommand = new RelayCommand<object>(new Action<object?>(SelectPageHeader));
}
/// <summary>
/// 选中页面
/// 选中
/// </summary>
private PageModel _SelectPageModels;
public PageModel SelectPageModels
/// <param name="obj"></param>
public void SelectPageHeader(object obj)
{
get
try
{
return _SelectPageModels;
MenuModel.SelectPageModels = obj as PageModel;
List<FrameworkElement> Children = new List<FrameworkElement>();
if (MenuModel.SelectPageModels != null)
{
foreach (FrameworkElement element in (MenuModel.SelectPageModels?.visual as CanvasPanel).Children)
{
string xamlText = XamlWriter.Save(element);
FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement;
Children.Add(item);
}
}
Run(Children);
}
set
catch (Exception ex)
{
_SelectPageModels = value;
OnPropertyChanged("SelectPageModels");

}
}
/// <summary>
/// 页面Model
/// </summary>
private ObservableCollection<PageModel> _pageModels;
public ObservableCollection<PageModel> pageModels

public void Run(List<FrameworkElement> canvas)
{
get
{
return _pageModels;
}
set
canvas1.Children.Clear();
foreach (FrameworkElement element in canvas)
{
_pageModels = value;
OnPropertyChanged("pageModels");
if (element is IExecutable executable)
executable.IsExecuteState = true;
canvas1.Children.Add(element);
RegisterJsName(element);
}
}
public MenuRunCanvasModel()

static void RegisterJsName(FrameworkElement element)
{
MenuModel = new MenuModel();
pageModels = new ObservableCollection<PageModel>();
pageModels.Add(new PageModel { Name = "首页面", visual = new CanvasPanel(), Sort = 0 });
SelectPageModels = pageModels[0];
Config.GetInstance().SetVariable(element.Name, element);
if (element is Panel panel)
{
foreach (var item in panel.Children)
{
RegisterJsName(item as FrameworkElement);
}
}
}
}
}

+ 0
- 25
BeDesignerSCADA/MainWindow.xaml.cs Просмотреть файл

@@ -1,30 +1,5 @@
using BeDesignerSCADA.Controls;
using BeDesignerSCADA.ViewModel;
using BPASmart.Model;
using BPASmartClient.Compiler;
using BPASmartClient.DATABUS;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
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;

namespace BeDesignerSCADA
{


+ 3
- 0
BeDesignerSCADA/Themes/Styles.xaml Просмотреть файл

@@ -570,6 +570,7 @@
</Setter.Value>
</Setter>
</Style>
<DataTemplate x:Key="Category">
<TextBlock
FontSize="20"
@@ -577,4 +578,6 @@
Text="{Binding}" />
</DataTemplate>
<!--#endregion-->
</ResourceDictionary>

+ 1
- 1
BeDesignerSCADA/View/RunWindows.xaml Просмотреть файл

@@ -20,6 +20,6 @@
<Grid.Background>
<ImageBrush ImageSource="../Images/bj.png"/>
</Grid.Background>
<ctl:RunCanvas x:Name="runCanvas" Visibility="{Binding RunCanvasVisibility}" />
<ctl:MenuRunCanvas x:Name="runCanvas" Visibility="{Binding DataContext.RunCanvasVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
</Grid>
</Window>

+ 4
- 3
BeDesignerSCADA/View/RunWindows.xaml.cs Просмотреть файл

@@ -1,4 +1,5 @@
using System;
using BeDesignerSCADA.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -24,9 +25,9 @@ namespace BeDesignerSCADA.View
InitializeComponent();
}

public void LoadingData(List<FrameworkElement> frameworks)
public void LoadingData(MenuModel frameworks)
{
runCanvas.Run(frameworks);
runCanvas.RunMenu(frameworks);
}
}
}

+ 25
- 0
BeDesignerSCADA/View/RunWindowsLao.xaml Просмотреть файл

@@ -0,0 +1,25 @@
<Window x:Class="BeDesignerSCADA.View.RunWindowsLao"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BeDesignerSCADA.View"
xmlns:ctl="clr-namespace:BeDesignerSCADA.Controls"
mc:Ignorable="d"
WindowState="Maximized"
Title="模拟运行器" Height="450" Width="800">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" />
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.Background>
<ImageBrush ImageSource="../Images/bj.png"/>
</Grid.Background>
<ctl:RunCanvas x:Name="runCanvas" Visibility="{Binding DataContext.RunCanvasVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
</Grid>
</Window>

+ 32
- 0
BeDesignerSCADA/View/RunWindowsLao.xaml.cs Просмотреть файл

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
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.Shapes;

namespace BeDesignerSCADA.View
{
/// <summary>
/// RunWindowsLao.xaml 的交互逻辑
/// </summary>
public partial class RunWindowsLao : Window
{
public RunWindowsLao()
{
InitializeComponent();
}

public void LoadingData(List<FrameworkElement> frameworks)
{
runCanvas.Run(frameworks);
}
}
}

+ 40
- 94
BeDesignerSCADA/ViewModel/MainViewModelNew.cs Просмотреть файл

@@ -7,6 +7,7 @@ using ICSharpCode.AvalonEdit;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using Microsoft.Win32;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -56,11 +57,11 @@ namespace BeDesignerSCADA.ViewModel
if (value)
{
RunCanvasVisibility = Visibility.Visible;
CanvasPanelVisibility = Visibility.Hidden;
CanvasPanelVisibility = Visibility.Collapsed;
}
else
{
RunCanvasVisibility = Visibility.Hidden;
RunCanvasVisibility = Visibility.Collapsed;
CanvasPanelVisibility = Visibility.Visible;
}
OnPropertyChanged("IsRunning");
@@ -154,38 +155,7 @@ namespace BeDesignerSCADA.ViewModel
OnPropertyChanged("MenuModel");
}
}
/// <summary>
/// 选中页面
/// </summary>
private PageModel _SelectPageModels;
public PageModel SelectPageModels
{
get
{
return _SelectPageModels;
}
set
{
_SelectPageModels = value;
OnPropertyChanged("SelectPageModels");
}
}
/// <summary>
/// 页面Model
/// </summary>
private ObservableCollection<PageModel> _pageModels;
public ObservableCollection<PageModel> pageModels
{
get
{
return _pageModels;
}
set
{
_pageModels = value;
OnPropertyChanged("pageModels");
}
}

#endregion

#region 命令
@@ -220,16 +190,7 @@ namespace BeDesignerSCADA.ViewModel
string xamlText = XamlWriter.Save(element);
ChildrenStr.Add(xamlText);
}
PageBase page = new PageBase()
{
ChildrenStr = ChildrenStr,
Id = _pageModel.Id,
IsHome = _pageModel.IsHome,
MenuName = _pageModel.MenuName,
Name = _pageModel.Name,
Sort = _pageModel.Sort,
};
MenuModel.PageChildren[_pageModel.Id] = page;
MenuModel.SelectPageModels.ChildrenStr= ChildrenStr;
}
catch (Exception ex)
{
@@ -246,7 +207,7 @@ namespace BeDesignerSCADA.ViewModel
/// <summary>
/// 当前运行界面
/// </summary>
public RunCanvas runCanvas;
public object runCanvas;
/// <summary>
/// 加载
/// </summary>
@@ -255,7 +216,7 @@ namespace BeDesignerSCADA.ViewModel
{
canvasPanel = objCan as CanvasPanel;

runCanvas = objRun as RunCanvas;
runCanvas = objRun;// as RunCanvas;

InitCommand();
}
@@ -446,25 +407,24 @@ namespace BeDesignerSCADA.ViewModel
LoadValuesCommand = new RelayCommand(new Action(LoadValuesHeader));
MenuModel = new MenuModel();
pageModels = new ObservableCollection<PageModel>();
pageModels.Add(new PageModel { Name = "首页面", visual = new CanvasPanel(), Sort = 0 });
SelectPageModels = pageModels[0];
MenuModel.pageModels = new ObservableCollection<PageModel>();
MenuModel.pageModels.Add(new PageModel { Name = "首页面", Sort = 0 });
MenuModel.SelectPageModels = MenuModel.pageModels[0];
GxSortTarget();
}

/// <summary>
/// 刷新排序
/// </summary>
public void GxSortTarget()
{
MenuModel.PageChildren.Clear();
for (int i = 0; i < pageModels.Count; i++)
for (int i = 0; i < MenuModel.pageModels.Count; i++)
{
pageModels[i].Sort = i;
MenuModel.pageModels[i].Sort = i;
if(i==0)
pageModels[i].IsHome = true;
MenuModel.pageModels[i].IsHome = true;
else
pageModels[i].IsHome = false;
UpdatePageBase(pageModels[i]);
MenuModel.pageModels[i].IsHome = false;
}
}
/// <summary>
@@ -474,11 +434,11 @@ namespace BeDesignerSCADA.ViewModel
{
try
{
if (SelectPageModels != null)
if (MenuModel.SelectPageModels != null)
{
PageModel mode = SelectPageModels;
pageModels.Remove(mode);
pageModels.Insert(0,mode);
PageModel mode = MenuModel.SelectPageModels;
MenuModel.pageModels.Remove(mode);
MenuModel.pageModels.Insert(0,mode);
GxSortTarget();
}
}
@@ -494,13 +454,13 @@ namespace BeDesignerSCADA.ViewModel
{
try
{
if (SelectPageModels != null)
if (MenuModel.SelectPageModels != null)
{
PageModel mode = SelectPageModels;
PageModel mode = MenuModel.SelectPageModels;
if (mode.Sort > 0)
{
pageModels.Remove(mode);
pageModels.Insert(mode.Sort - 1, mode);
MenuModel.pageModels.Remove(mode);
MenuModel.pageModels.Insert(mode.Sort - 1, mode);
GxSortTarget();
}
@@ -518,13 +478,13 @@ namespace BeDesignerSCADA.ViewModel
{
try
{
if (SelectPageModels != null)
if (MenuModel.SelectPageModels != null)
{
PageModel mode = SelectPageModels;
if (mode.Sort > 0 && mode.Sort+1< pageModels.Count)
PageModel mode = MenuModel.SelectPageModels;
if (mode.Sort > 0 && mode.Sort+1< MenuModel.pageModels.Count)
{
pageModels.Remove(mode);
pageModels.Insert(mode.Sort + 1, mode);
MenuModel.pageModels.Remove(mode);
MenuModel.pageModels.Insert(mode.Sort + 1, mode);
GxSortTarget();
}
}
@@ -544,14 +504,14 @@ namespace BeDesignerSCADA.ViewModel

if (obj != null && obj is PageModel mode)
{
if (mode.Sort >= 0 && mode.Sort + 1 < pageModels.Count)
if (mode.Sort >= 0 && mode.Sort + 1 < MenuModel.pageModels.Count)
{
pageModels.Insert(mode.Sort + 1,new PageModel { Name = "页面"+ pageModels.Count, MenuName = "页面" + pageModels.Count, visual = new CanvasPanel(), Sort = pageModels.Count });
MenuModel.pageModels.Insert(mode.Sort + 1,new PageModel { Name = "页面"+ MenuModel.pageModels.Count, Sort = MenuModel.pageModels.Count });
GxSortTarget();
}
else if (mode.Sort + 1 == pageModels.Count)
else if (mode.Sort + 1 == MenuModel.pageModels.Count)
{
pageModels.Add(new PageModel { Name = "页面" + pageModels.Count, MenuName= "页面" + pageModels.Count,visual = new CanvasPanel(), Sort = pageModels.Count });
MenuModel.pageModels.Add(new PageModel { Name = "页面" + MenuModel.pageModels.Count, Sort = MenuModel.pageModels.Count });
GxSortTarget();
}
}
@@ -570,7 +530,7 @@ namespace BeDesignerSCADA.ViewModel
{
if (obj != null && obj is PageModel page)
{
pageModels.Remove(page);
MenuModel.pageModels.Remove(page);
GxSortTarget();
}
}
@@ -587,11 +547,11 @@ namespace BeDesignerSCADA.ViewModel
{
try
{
SelectPageModels = obj as PageModel;
MenuModel.SelectPageModels = obj as PageModel;
try
{
canvasPanel.Children.Clear();
foreach (FrameworkElement element in (SelectPageModels?.visual as CanvasPanel).Children)
foreach (FrameworkElement element in (MenuModel.SelectPageModels?.visual as CanvasPanel).Children)
{
string xamlText = XamlWriter.Save(element);
FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement;
@@ -640,29 +600,15 @@ namespace BeDesignerSCADA.ViewModel
ofd.Filter = "页面布局|*.yf";
if (ofd.ShowDialog() == true)
{
MenuModel obj = BinaryFile.ReadBinary<MenuModel>(ofd.FileName) as MenuModel;
MenuModel = obj;


pageModels.Clear();
MenuModel?.PageChildren?.ToList().ForEach(par =>
MenuModel = BinaryFile.ReadBinary<MenuModel>(ofd.FileName) as MenuModel;
MenuModel?.pageModels?.ToList().ForEach(par =>
{
PageModel page = new PageModel
{
Id = par.Value.Id,
ChildrenStr = par.Value.ChildrenStr,
IsHome = par.Value.IsHome,
MenuName = par.Value.MenuName,
Name = par.Value.Name,
Sort = par.Value.Sort,
};
page.visual = new CanvasPanel();
par.Value?.ChildrenStr?.ForEach(k =>
par.visual = new CanvasPanel();
par?.ChildrenStr?.ForEach(k =>
{
FrameworkElement item = XamlReader.Parse(k) as FrameworkElement;
page.visual.Children.Add(item);
par.visual.Children.Add(item);
});
pageModels.Add(page);
});

}


Загрузка…
Отмена
Сохранить