Преглед на файлове

上位机设计框架搭建

样式分支
pry преди 2 години
родител
ревизия
3a43febf27
променени са 14 файла, в които са добавени 189 реда и са изтрити 50 реда
  1. +1
    -1
      BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj
  2. +18
    -0
      BPASmart.ConfigurationSoftware/BasicInformation.cs
  3. +32
    -0
      BPASmart.ConfigurationSoftware/Global.cs
  4. +16
    -0
      BPASmart.ConfigurationSoftware/MainCanvasPageModel.cs
  5. +9
    -3
      BPASmart.ConfigurationSoftware/MainWindow.xaml
  6. +38
    -15
      BPASmart.ConfigurationSoftware/MainWindowViewModel.cs
  7. +14
    -3
      BPASmart.ConfigurationSoftware/NewPageView.xaml
  8. +6
    -1
      BPASmart.ConfigurationSoftware/NewPageView.xaml.cs
  9. +8
    -1
      BPASmart.ConfigurationSoftware/NewProjectView.xaml
  10. +30
    -9
      BPASmart.ConfigurationSoftware/NewProjectViewModel.cs
  11. +1
    -1
      BPASmart.Server/BPASmart.Server.csproj
  12. +1
    -1
      BeDesignerSCADA/Controls/MainCanvasPanel.xaml
  13. +14
    -14
      BeDesignerSCADA/Themes/Styles.xaml
  14. +1
    -1
      ComputerTestDemo/ComputerTestDemo.csproj

+ 1
- 1
BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj Целия файл

@@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.7" />
<PackageReference Include="BPA.Helper" Version="1.0.8" />
</ItemGroup>

<ItemGroup>


+ 18
- 0
BPASmart.ConfigurationSoftware/BasicInformation.cs Целия файл

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmart.ConfigurationSoftware
{
public class BasicInformation
{
/// <summary>
/// 项目上次保存的目录
/// </summary>
public string ProjectDefaultPath { get; set; } = string.Empty;


}
}

+ 32
- 0
BPASmart.ConfigurationSoftware/Global.cs Целия файл

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmart.ConfigurationSoftware
{
public class Global
{
/// <summary>
/// 页面文件夹名称
/// </summary>
public const string PageDirectoryName = "Layouts";


/// <summary>
/// 项目路径
/// </summary>
public static string ProjectPath { get; set; } = string.Empty;

/// <summary>
/// 项目名称
/// </summary>
public static string ProjectName { get; set; }

/// <summary>
/// 变量管理器路径
/// </summary>
public static string VarManagerPath => $"{AppDomain.CurrentDomain.BaseDirectory}BPASmart.VariableManager.exe";
}
}

+ 16
- 0
BPASmart.ConfigurationSoftware/MainCanvasPageModel.cs Целия файл

@@ -0,0 +1,16 @@
using BeDesignerSCADA.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmart.ConfigurationSoftware
{
public class MainCanvasPageModel
{
public MainCanvasPanel MainCanvasPanelModel { get; set; }
public string PageName { get; set; }

}
}

+ 9
- 3
BPASmart.ConfigurationSoftware/MainWindow.xaml Целия файл

@@ -121,7 +121,7 @@
<Button
Width="60"
Margin="5"
Command="{Binding NewCommand}"
Command="{Binding SaveCommand}"
Content="保存" />

<Button
@@ -195,9 +195,15 @@
</ScrollViewer>
</Grid>

<Canvas Name="cav" Grid.Column="1" Grid.Row="1">
<ContentControl
Grid.Row="1"
Grid.Column="1"
Width="auto"
Height="auto"
Content="{Binding MainContent}" />
<!--<Canvas Name="cav" Grid.Column="1" Grid.Row="1">

</Canvas>
</Canvas>-->

</Grid>



+ 38
- 15
BPASmart.ConfigurationSoftware/MainWindowViewModel.cs Целия файл

@@ -11,27 +11,26 @@ using System.IO;
using BPA.Helper;
using System.Diagnostics;
using BeDesignerSCADA;
using BeDesignerSCADA.Controls;
using System.Windows;
using System.Reflection;

namespace BPASmart.ConfigurationSoftware
{
public class MainWindowViewModel : NoticeBase
{
string LayoutPath
{
get
{
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\Layouts"));
return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\Layouts\\";
}
}

public MainWindowViewModel()
{

ActionManage.GetInstance.Register(new Action<object>((o) =>
{
Pages.Add(o.ToString());
File.WriteAllText(LayoutPath + o.ToString(), null, Encoding.Unicode);
}), "PageName");
string path = $"{Global.ProjectPath}\\{Global.PageDirectoryName}";
Directory.CreateDirectory(path);
File.WriteAllText($"{path}\\{o.ToString()}.lay", null, Encoding.Unicode);
}), "AddPage");

NewCommand = new RelayCommand(() =>
{
NewProjectView newProjectView = new NewProjectView();
@@ -40,8 +39,11 @@ namespace BPASmart.ConfigurationSoftware
{
if (newProjectView.Tag != null && newProjectView.Tag is NewDataModel objModel)
{
Directory.CreateDirectory(Path.Combine(objModel.ProjectPath, objModel.ProjectName));
string path = $"{objModel.ProjectPath}\\{objModel.ProjectName}";
Directory.CreateDirectory(path);
Global.ProjectPath = path;
Head = objModel.ProjectName;
Global.ProjectName = objModel.ProjectName;
}
}
});
@@ -54,20 +56,38 @@ namespace BPASmart.ConfigurationSoftware

OpenVarManagerCommand = new RelayCommand(() =>
{
string path = $"{AppDomain.CurrentDomain.BaseDirectory}BPASmart.VariableManager.exe";
if (File.Exists(path))
if (File.Exists(Global.VarManagerPath))
{
Process[] pro = Process.GetProcesses();
if (pro?.ToList().FirstOrDefault(p => p.ProcessName.Contains("BPASmart.VariableManager")) == null)
{
Process.Start(path);
Process.Start(Global.VarManagerPath);
}
}
});

SelectedCommand = new RelayCommand<object>((o) =>
{
string path = $"{Global.ProjectPath}\\{Global.PageDirectoryName}\\{o.ToString()}.lay";
mainCanvasPanels.Add(new MainCanvasPageModel()
{
MainCanvasPanelModel = new MainCanvasPanel(path),
PageName = o.ToString(),
});
var res = mainCanvasPanels.FirstOrDefault(p => p.PageName == o.ToString());
if (res != null)
{
ConstructorInfo cti = res.MainCanvasPanelModel.GetType()?.GetConstructor(System.Type.EmptyTypes);
MainContent = (FrameworkElement)cti?.Invoke(null);
}
});

SaveCommand = new RelayCommand(() =>
{
for (int i = 0; i < mainCanvasPanels.Count; i++)
{
mainCanvasPanels.ElementAt(i).MainCanvasPanelModel.FileSave();
}
});
}

@@ -84,7 +104,10 @@ namespace BPASmart.ConfigurationSoftware
public string Head { get { return _mHead; } set { _mHead = value; OnPropertyChanged(); } }
private string _mHead;

//public ObservableCollection<MainCanvasPanel>
public FrameworkElement MainContent { get { return _mMainContent; } set { _mMainContent = value; OnPropertyChanged(); } }
private FrameworkElement _mMainContent;

public List<MainCanvasPageModel> mainCanvasPanels { get; set; } = new List<MainCanvasPageModel>();

public ObservableCollection<string> Pages { get; set; } = new ObservableCollection<string>();



+ 14
- 3
BPASmart.ConfigurationSoftware/NewPageView.xaml Целия файл

@@ -32,19 +32,30 @@
Text="{Binding NewData.ProjectName}" />


<Grid Grid.Row="4">
<TextBlock
Name="ErrorInfo"
Grid.Row="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Red" />

<Grid Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="35*" />
<ColumnDefinition Width="32*" />
<ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>

<Button Margin="10,2,10,2" Content="创建" Click="Button_Click_1" />
<Button
Margin="10,2,10,2"
Click="Button_Click_1"
Content="创建" />
<Button
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="10,2,10,2"
Content="取消" Click="Button_Click" />
Click="Button_Click"
Content="取消" />

</Grid>



+ 6
- 1
BPASmart.ConfigurationSoftware/NewPageView.xaml.cs Целия файл

@@ -35,10 +35,15 @@ namespace BPASmart.ConfigurationSoftware
{
if (this.pageName.Text.Trim().Length > 0)
{

this.DialogResult = true;
ActionManage.GetInstance.Send("PageName", this.pageName.Text);
ActionManage.GetInstance.Send("AddPage", this.pageName.Text);
this.Close();
}
else
{
ErrorInfo.Text = "请输入页面名称";
}

}
}


+ 8
- 1
BPASmart.ConfigurationSoftware/NewProjectView.xaml Целия файл

@@ -23,6 +23,7 @@
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock VerticalAlignment="Center" Text="项目名称:" />
@@ -48,7 +49,13 @@
Content="..." />
</Grid>

<Grid Grid.Row="4">
<TextBlock
Grid.Row="4"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding ErrorInfo}" Foreground="Red"/>

<Grid Grid.Row="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="35*" />
<ColumnDefinition Width="32*" />


+ 30
- 9
BPASmart.ConfigurationSoftware/NewProjectViewModel.cs Целия файл

@@ -8,43 +8,64 @@ using Microsoft.Toolkit.Mvvm.Input;
using System.Windows;
using BPA.Helper;
using System.Windows.Forms;
using System.IO;

namespace BPASmart.ConfigurationSoftware
{
public class NewProjectViewModel : NoticeBase
{
public NewProjectViewModel()
{
Json<BasicInformation>.Read();
NewData.ProjectPath = Json<BasicInformation>.Data.ProjectDefaultPath;
OpenBrowserDialogCommand = new RelayCommand(() =>
{
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
NewData.ProjectPath = folderBrowserDialog.SelectedPath;
Json<BasicInformation>.Data.ProjectDefaultPath = NewData.ProjectPath;
Json<BasicInformation>.Save();
}
});

CreateCommand = new RelayCommand(() =>
{
ActionManage.GetInstance.Send("CreateCommand", NewData);
if (NewData.ProjectName == null || NewData.ProjectName?.Length <= 0)
{
ErrorInfo = "项目名不能为空";
return;
}

if (NewData.ProjectPath == null || NewData.ProjectPath?.Length <= 0)
{
ErrorInfo = "项目路径不合法";
return;
}
var res = Directory.GetDirectories(NewData.ProjectPath);
if (res?.ToList()?.FirstOrDefault(p => p.Contains(NewData.ProjectName)) == null)
{
ActionManage.GetInstance.Send("CreateCommand", NewData);
}
else
{
ErrorInfo = "该项目已经存在";
return;
}

});

CancelCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("CancelCommand"); });

}



public NewDataModel NewData { get { return _mNewData; } set { _mNewData = value; OnPropertyChanged(); } }
private NewDataModel _mNewData = new NewDataModel();


public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } }
private string _mErrorInfo;

//public string ProjectName { get { return _mProjectName; } set { _mProjectName = value; OnPropertyChanged(); } }
//private string _mProjectName;


//public string ProjectPath { get { return _mProjectPath; } set { _mProjectPath = value; OnPropertyChanged(); } }
//private string _mProjectPath;

public RelayCommand CreateCommand { get; set; }



+ 1
- 1
BPASmart.Server/BPASmart.Server.csproj Целия файл

@@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="BPA.Communication" Version="1.0.13" />
<PackageReference Include="BPA.Helper" Version="1.0.7" />
<PackageReference Include="BPA.Helper" Version="1.0.8" />
</ItemGroup>

<ItemGroup>


+ 1
- 1
BeDesignerSCADA/Controls/MainCanvasPanel.xaml Целия файл

@@ -138,7 +138,7 @@
<!--中间画布-->
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Margin="4">
<Border.Background>
<ImageBrush ImageSource="/Images/bj.png" Stretch="UniformToFill"/>
<ImageBrush ImageSource="../Images/bj.png" Stretch="UniformToFill"/>
</Border.Background>
<Grid>
<Grid.ColumnDefinitions>


+ 14
- 14
BeDesignerSCADA/Themes/Styles.xaml Целия файл

@@ -300,16 +300,16 @@
<Setter TargetName="txt" Property="Text" Value="物料仓" />
</DataTrigger>
<DataTrigger Binding="{Binding Name}" Value="NewConveyorBelt">
<Setter Property="Kind" TargetName="icon" Value="Attachment"/>
<Setter Property="Text" TargetName="txt" Value="滚动线"/>
<Setter TargetName="icon" Property="Kind" Value="Attachment" />
<Setter TargetName="txt" Property="Text" Value="滚动线" />
</DataTrigger>
<DataTrigger Binding="{Binding Name}" Value="TheDataGrid">
<Setter Property="Kind" TargetName="icon" Value="BorderAll"/>
<Setter Property="Text" TargetName="txt" Value="表格"/>
<Setter TargetName="icon" Property="Kind" Value="BorderAll" />
<Setter TargetName="txt" Property="Text" Value="表格" />
</DataTrigger>
<DataTrigger Binding="{Binding Name}" Value="TheListBox">
<Setter Property="Kind" TargetName="icon" Value="ViewHeadline"/>
<Setter Property="Text" TargetName="txt" Value="列表控件"/>
<Setter TargetName="icon" Property="Kind" Value="ViewHeadline" />
<Setter TargetName="txt" Property="Text" Value="列表控件" />
</DataTrigger>

<DataTrigger Binding="{Binding Name}" Value="TheRedis">
@@ -323,23 +323,23 @@
</DataTrigger>

<DataTrigger Binding="{Binding Name}" Value="TheProgressBar">
<Setter Property="Kind" TargetName="icon" Value="Texture"/>
<Setter Property="Text" TargetName="txt" Value="进度条正常"/>
<Setter TargetName="icon" Property="Kind" Value="Texture" />
<Setter TargetName="txt" Property="Text" Value="进度条正常" />
</DataTrigger>

<DataTrigger Binding="{Binding Name}" Value="TheRedProgressBar">
<Setter Property="Kind" TargetName="icon" Value="CircleSlice5"/>
<Setter Property="Text" TargetName="txt" Value="进度条圆形红"/>
<Setter TargetName="icon" Property="Kind" Value="CircleSlice5" />
<Setter TargetName="txt" Property="Text" Value="进度条圆形红" />
</DataTrigger>

<DataTrigger Binding="{Binding Name}" Value="TheBlueProgressBar">
<Setter Property="Kind" TargetName="icon" Value="CircleSlice5"/>
<Setter Property="Text" TargetName="txt" Value="进度条圆形蓝"/>
<Setter TargetName="icon" Property="Kind" Value="CircleSlice5" />
<Setter TargetName="txt" Property="Text" Value="进度条圆形蓝" />
</DataTrigger>

<DataTrigger Binding="{Binding Name}" Value="TheGreenProgressBar">
<Setter Property="Kind" TargetName="icon" Value="CircleSlice5"/>
<Setter Property="Text" TargetName="txt" Value="进度条圆形绿"/>
<Setter TargetName="icon" Property="Kind" Value="CircleSlice5" />
<Setter TargetName="txt" Property="Text" Value="进度条圆形绿" />
</DataTrigger>

<DataTrigger Binding="{Binding Name}" Value="TheAPI">


+ 1
- 1
ComputerTestDemo/ComputerTestDemo.csproj Целия файл

@@ -10,7 +10,7 @@

<ItemGroup>
<PackageReference Include="BPA.Communication" Version="1.0.13" />
<PackageReference Include="BPA.Helper" Version="1.0.7" />
<PackageReference Include="BPA.Helper" Version="1.0.8" />
</ItemGroup>

<ItemGroup>


Зареждане…
Отказ
Запис