Commit 5e49ed99 authored by 潘栩锋's avatar 潘栩锋 🚴

新增 主界面配置文件列表,用于和美换产品

parent 11276630
......@@ -22,18 +22,32 @@
<RowDefinition Height="auto" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource ButtonStyle_back}" Click="btnBackClick" />
<StackPanel Style="{StaticResource SpStyle_Header}">
<TextBlock Text="主界面布局管理" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource ButtonStyle_back}" Click="btnBackClick" />
<StackPanel Style="{StaticResource SpStyle_Header}">
<TextBlock Text="主界面布局管理" />
</StackPanel>
<Button Style="{StaticResource ButtonStyle_icon}" Click="btnSettingClick" Margin="20,0" >
<StackPanel>
<iconPacks:PackIconMaterial Kind="Settings" />
<TextBlock Text="设置"/>
</StackPanel>
</Button>
</StackPanel>
<Button Style="{StaticResource ButtonStyle_icon}" Click="btnSettingClick" Margin="20,0" >
<Button Grid.Column="1" Style="{StaticResource ButtonStyle_icon}" Click="btnFileClick" Margin="20,0" >
<StackPanel>
<iconPacks:PackIconMaterial Kind="Settings" />
<TextBlock Text="设置"/>
<iconPacks:PackIconMaterial Kind="FileAccountOutline" />
<TextBlock Text="布局文件"/>
</StackPanel>
</Button>
</StackPanel>
</Grid>
<TabControl Grid.Row="1" Margin="{StaticResource ControlMargin}" TabStripPlacement="Left" Template="{StaticResource GageTab}">
<TabItem Header="△△">
<Grid Background="#bcbcbc" >
......
......@@ -52,5 +52,11 @@ namespace MultiLayout.MainEdit
FlyLayoutManager.NavigationService.GoBack();
}
private void btnFileClick(object sender, RoutedEventArgs e)
{
WdLoadFile w = new WdLoadFile();
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
w.ShowDialog();
}
}
}
<flyctrllib:WindowBigClose x:Class="MultiLayout.MainEdit.WdLoadFile"
xmlns:flyctrllib="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary"
Title="Window_FixSave" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" WindowStartupLocation="CenterScreen" SizeToContent="WidthAndHeight">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid TextBlock.FontSize="24" TextBlock.FontStyle="Normal" Margin="5,20">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition/>
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<ListBox Name="listview_profile" Margin="5" MinWidth="400" Height="400" Grid.Row="1" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding .}" FontWeight="Bold" FontSize="26" FontFamily="Microsoft Sans Serif" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Margin="5">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeader}" Text="布局列表" VerticalAlignment="Center" FontSize="44" />
</StackPanel>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Style="{StaticResource ButtonStyle2}" Content="保存" Width="200" Margin="5" Click="button_save_Click" />
<Button Grid.Column="1" Style="{StaticResource ButtonStyle2}" Content="加载" Width="200" Margin="5" Click="button_read_Click" Background="#FF127300" />
<Button Grid.Column="2" Style="{StaticResource ButtonStyle2}" Content="删除" Width="200" Margin="5" Click="button_del_Click" Background="#FFEC0000" />
</Grid>
</Grid>
</flyctrllib:WindowBigClose >
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
using System.Collections.ObjectModel;
using System.IO;
namespace MultiLayout.MainEdit
{
/// <summary>
/// Window_Load.xaml 的交互逻辑
/// </summary>
public partial class WdLoadFile : FLY.ControlLibrary.WindowBigClose
{
ObservableCollection<string> mList = new ObservableCollection<string>();
public WdLoadFile()
{
InitializeComponent();
Init();
}
public void Init()
{
this.listview_profile.ItemsSource = mList;
//查找 layout/graphcustoms 下的全部文件名
string dirPath = System.IO.Path.Combine(FlyLayout.BasePath, "graphcustoms");
DirectoryInfo directoryInfo = new DirectoryInfo(dirPath);
if (!directoryInfo.Exists) {
return;
}
var files = directoryInfo.GetFiles("*.json");
foreach (var file in files) {
mList.Add(System.IO.Path.GetFileNameWithoutExtension(file.Name));
}
}
private void button_read_Click(object sender, RoutedEventArgs e)
{
if (listview_profile.SelectedItem != null)
{
string strTipRebootForExecute = "需要重启,才能生效";
if (FLY.ControlLibrary.MyMessageBox.Show(strTipRebootForExecute) == true)
{
string filename = listview_profile.SelectedItem as string;
string filePath = System.IO.Path.Combine(FlyLayout.BasePath, "graphcustoms", filename + ".json");
string destPath = System.IO.Path.Combine(FlyLayout.BasePath, "graphcustom.json");
File.Copy(filePath, destPath, true);
System.Windows.Forms.Application.Restart();
Application.Current.Shutdown();
}
return;
}
}
private void button_del_Click(object sender, RoutedEventArgs e)
{
if (listview_profile.SelectedItem != null)
{
string filename = listview_profile.SelectedItem as string;
string filePath = System.IO.Path.Combine(FlyLayout.BasePath, "graphcustoms", filename + ".json");
File.Delete(filePath);
mList.Remove(filename);
FLY.ControlLibrary.Window_Tip.Show("删除成功",
filename,
TimeSpan.FromSeconds(2));
}
}
private void button_save_Click(object sender, RoutedEventArgs e)
{
WdSaveFile w = new WdSaveFile();
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
if (w.ShowDialog() == true) {
if (mList.Contains(w.FileName)) {
if (FLY.ControlLibrary.MyMessageBox.Show("文件已经存在,是否覆盖?")!=true)
{
return;
}
}
string dirPath = System.IO.Path.Combine(FlyLayout.BasePath, "graphcustoms");
if (!Directory.Exists(dirPath))
Directory.CreateDirectory(dirPath);
string filename = w.FileName;
string destPath = System.IO.Path.Combine(FlyLayout.BasePath, "graphcustoms", filename + ".json");
string srcPath = System.IO.Path.Combine(FlyLayout.BasePath, "graphcustom.json");
File.Copy(srcPath, destPath, true);
if (!mList.Contains(w.FileName))
{
mList.Add(filename);
}
FLY.ControlLibrary.Window_Tip.Show("保存成功",
filename,
TimeSpan.FromSeconds(2));
}
}
}
}
<flyctrllib:WindowBigClose x:Class="MultiLayout.MainEdit.WdSaveFile"
xmlns:flyctrllib="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary"
Title="Window_FixSave" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Loaded="WindowBigClose_Loaded" SizeToContent="WidthAndHeight">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid TextBlock.FontSize="24" TextBlock.FontStyle="Normal" Width="400">
<StackPanel Margin="5,20">
<StackPanel Grid.Column="1" Margin="5">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="请输入布局名称:" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Name="textbox_productname" Tag="Full" MinWidth="300"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal"></StackPanel>
<Button Content="保存" Style="{StaticResource ButtonStyle2}" Margin="5" Width="auto" Click="button_save_Click" />
</StackPanel>
</Grid>
</flyctrllib:WindowBigClose >
using System.Windows;
namespace MultiLayout.MainEdit
{
/// <summary>
/// Window_Save.xaml 的交互逻辑
/// </summary>
public partial class WdSaveFile : FLY.ControlLibrary.WindowBigClose
{
public WdSaveFile()
{
InitializeComponent();
}
public string FileName;
private void button_save_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
FileName = this.textbox_productname.Text;
}
private void WindowBigClose_Loaded(object sender, RoutedEventArgs e)
{
this.textbox_productname.Text = FileName;
}
}
}
......@@ -58,6 +58,12 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CustomMenu\MainEditMenu.cs" />
<Compile Include="MainEdit\WdLoadFile.xaml.cs">
<DependentUpon>WdLoadFile.xaml</DependentUpon>
</Compile>
<Compile Include="MainEdit\WdSaveFile.xaml.cs">
<DependentUpon>WdSaveFile.xaml</DependentUpon>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
......@@ -207,6 +213,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainEdit\WdLoadFile.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MainEdit\WdMainConfig.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......@@ -215,6 +225,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainEdit\WdSaveFile.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment