@@ -241,11 +241,14 @@ namespace BPASmart.ConfigurationSoftware | |||||
/// <param name="o"></param> | /// <param name="o"></param> | ||||
public void RemovePageCommand(object o) | public void RemovePageCommand(object o) | ||||
{ | { | ||||
MessageLog.GetInstance.Show($"准备删除页面:{o.ToString()}"); | |||||
if (!string.IsNullOrEmpty(o?.ToString())) | if (!string.IsNullOrEmpty(o?.ToString())) | ||||
{ | { | ||||
if (Pages.FirstOrDefault(p => p == o.ToString()) != null) | if (Pages.FirstOrDefault(p => p == o.ToString()) != null) | ||||
{ | { | ||||
Pages.Remove(o.ToString()); | Pages.Remove(o.ToString()); | ||||
if (Json<ProjectModel>.Data.Pages.ContainsKey(o.ToString())) | |||||
Json<ProjectModel>.Data.Pages.Remove(o.ToString()); | |||||
string path = $"{FileConfigModel.ConstPath}\\{FileConfigModel.PageDirName}\\{o.ToString()}.lay"; | string path = $"{FileConfigModel.ConstPath}\\{FileConfigModel.PageDirName}\\{o.ToString()}.lay"; | ||||
if (File.Exists(path)) File.Delete(path); | if (File.Exists(path)) File.Delete(path); | ||||
if (!File.Exists(path)) MessageLog.GetInstance.Show($"页面 {o.ToString()} 删除成功"); | if (!File.Exists(path)) MessageLog.GetInstance.Show($"页面 {o.ToString()} 删除成功"); | ||||
@@ -265,6 +268,7 @@ namespace BPASmart.ConfigurationSoftware | |||||
Serialization<BinConfigFile>.Data.StartPageName = o.ToString(); | Serialization<BinConfigFile>.Data.StartPageName = o.ToString(); | ||||
Serialization<BinConfigFile>.Save($"{FileConfigModel.GetBinConfigPath}"); | Serialization<BinConfigFile>.Save($"{FileConfigModel.GetBinConfigPath}"); | ||||
} | } | ||||
MessageLog.GetInstance.Show($"当前启动页面:{Serialization<BinConfigFile>.Data.StartPageName}"); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -275,7 +279,7 @@ namespace BPASmart.ConfigurationSoftware | |||||
{ | { | ||||
if (!string.IsNullOrEmpty(o?.ToString())) | if (!string.IsNullOrEmpty(o?.ToString())) | ||||
{ | { | ||||
MessageLog.GetInstance.Show($"页面 {o.ToString()}重命名"); | |||||
} | } | ||||
} | } | ||||
@@ -191,17 +191,17 @@ | |||||
GroupName="All" | GroupName="All" | ||||
Style="{StaticResource RadioMiniButtonStyle}"> | Style="{StaticResource RadioMiniButtonStyle}"> | ||||
<RadioButton.ContextMenu> | <RadioButton.ContextMenu> | ||||
<ContextMenu> | |||||
<ContextMenu ItemsSource="{Binding DataContext}"> | |||||
<MenuItem | <MenuItem | ||||
Command="{Binding DataContext.RemovePageCommand, RelativeSource={RelativeSource AncestorType=Grid, AncestorLevel=4, Mode=FindAncestor}}" | |||||
Command="{Binding DataContext.RemovePageCommand, RelativeSource={RelativeSource AncestorType=Grid,AncestorLevel=5, Mode=FindAncestor}}" | |||||
CommandParameter="{Binding}" | CommandParameter="{Binding}" | ||||
Header="删除页面" /> | Header="删除页面" /> | ||||
<MenuItem | <MenuItem | ||||
Command="{Binding DataContext.SetStartPageCommand, RelativeSource={RelativeSource AncestorType=Grid, AncestorLevel=4, Mode=FindAncestor}}" | |||||
Command="{Binding DataContext.SetStartPageCommand,RelativeSource={RelativeSource AncestorType=Grid,AncestorLevel=5,Mode=FindAncestor}}" | |||||
CommandParameter="{Binding}" | CommandParameter="{Binding}" | ||||
Header="设为启动界面" /> | Header="设为启动界面" /> | ||||
<MenuItem | <MenuItem | ||||
Command="{Binding DataContext.ReNameCommand, RelativeSource={RelativeSource AncestorType=Grid, AncestorLevel=4, Mode=FindAncestor}}" | |||||
Command="{Binding DataContext.ReNameCommand, RelativeSource={RelativeSource AncestorType=Grid,AncestorLevel=5, Mode=FindAncestor}}" | |||||
CommandParameter="{Binding}" | CommandParameter="{Binding}" | ||||
Header="重命名" /> | Header="重命名" /> | ||||
</ContextMenu> | </ContextMenu> | ||||
@@ -29,7 +29,7 @@ | |||||
Height="30" | Height="30" | ||||
VerticalAlignment="Top" | VerticalAlignment="Top" | ||||
FontSize="16" | FontSize="16" | ||||
Text="{Binding NewData.ProjectName}" /> | |||||
Text="" /> | |||||
<TextBlock | <TextBlock | ||||
@@ -48,6 +48,7 @@ | |||||
<Button | <Button | ||||
Margin="10,2,10,2" | Margin="10,2,10,2" | ||||
IsDefault="True" | |||||
Click="Button_Click_1" | Click="Button_Click_1" | ||||
Content="创建" /> | Content="创建" /> | ||||
<Button | <Button | ||||
@@ -24,6 +24,22 @@ namespace BPASmart.ConfigurationSoftware | |||||
public NewPageView() | public NewPageView() | ||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
DefaultPageName(); | |||||
this.pageName.Focus(); | |||||
} | |||||
private void DefaultPageName() | |||||
{ | |||||
int count = 0; | |||||
while (true) | |||||
{ | |||||
count++; | |||||
if (!Json<ProjectModel>.Data.Pages.ContainsKey($"Page{count}")) | |||||
{ | |||||
this.pageName.Text = $"Page{count}"; | |||||
break; | |||||
} | |||||
} | |||||
} | } | ||||
private void Button_Click(object sender, RoutedEventArgs e) | private void Button_Click(object sender, RoutedEventArgs e) | ||||
@@ -28,6 +28,7 @@ | |||||
<TextBlock VerticalAlignment="Center" Text="项目名称:" /> | <TextBlock VerticalAlignment="Center" Text="项目名称:" /> | ||||
<TextBox | <TextBox | ||||
Name="projectName" | |||||
Grid.Row="1" | Grid.Row="1" | ||||
VerticalAlignment="Center" | VerticalAlignment="Center" | ||||
FontSize="20" | FontSize="20" | ||||
@@ -67,7 +68,8 @@ | |||||
<Button | <Button | ||||
Margin="10,2,10,2" | Margin="10,2,10,2" | ||||
Command="{Binding CreateCommand}" | Command="{Binding CreateCommand}" | ||||
Content="创建" /> | |||||
Content="创建" | |||||
IsDefault="True" /> | |||||
<Button | <Button | ||||
Grid.Column="1" | Grid.Column="1" | ||||
Grid.ColumnSpan="2" | Grid.ColumnSpan="2" | ||||
@@ -23,6 +23,7 @@ namespace BPASmart.ConfigurationSoftware | |||||
public NewProjectView() | public NewProjectView() | ||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
projectName.Focus(); | |||||
ActionManage.GetInstance.Register(new Action<object>((o) => | ActionManage.GetInstance.Register(new Action<object>((o) => | ||||
{ | { | ||||
this.DialogResult = true; | this.DialogResult = true; | ||||
@@ -18,6 +18,7 @@ namespace BPASmart.ConfigurationSoftware | |||||
{ | { | ||||
//Json<BasicInformation>.Read(); | //Json<BasicInformation>.Read(); | ||||
NewData.ProjectPath = Json<LocalPar>.Data.ProjectDefaultPath; | NewData.ProjectPath = Json<LocalPar>.Data.ProjectDefaultPath; | ||||
DefaultName(); | |||||
OpenBrowserDialogCommand = new RelayCommand(() => | OpenBrowserDialogCommand = new RelayCommand(() => | ||||
{ | { | ||||
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); | FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); | ||||
@@ -59,6 +60,21 @@ namespace BPASmart.ConfigurationSoftware | |||||
} | } | ||||
private void DefaultName() | |||||
{ | |||||
var res = Directory.GetDirectories(NewData.ProjectPath); | |||||
int count = 0; | |||||
while (true) | |||||
{ | |||||
count++; | |||||
if (res?.ToList()?.FirstOrDefault(p => p.Contains($"default{count}")) == null) | |||||
{ | |||||
NewData.ProjectName = $"default{count}"; | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
public NewProjectModel NewData { get { return _mNewData; } set { _mNewData = value; OnPropertyChanged(); } } | public NewProjectModel NewData { get { return _mNewData; } set { _mNewData = value; OnPropertyChanged(); } } | ||||
private NewProjectModel _mNewData = new NewProjectModel(); | private NewProjectModel _mNewData = new NewProjectModel(); | ||||
@@ -12,6 +12,9 @@ | |||||
WindowState="Maximized" | WindowState="Maximized" | ||||
mc:Ignorable="d"> | mc:Ignorable="d"> | ||||
<Grid> | <Grid> | ||||
<Grid.Background> | |||||
<ImageBrush ImageSource="/BeDesignerSCADA;component/Images/bj.png" /> | |||||
</Grid.Background> | |||||
<ctrl:RunCanvas x:Name="runCanvas" /> | <ctrl:RunCanvas x:Name="runCanvas" /> | ||||
</Grid> | </Grid> | ||||
</Window> | </Window> |