Commit 6aed39c7 by wangonghui

布局功能添加默认布局

parent e110e38f
...@@ -173,5 +173,10 @@ namespace VIZ.Package.Domain ...@@ -173,5 +173,10 @@ namespace VIZ.Package.Domain
/// 时钟控件保存信息 /// 时钟控件保存信息
/// </summary> /// </summary>
public static ClockFieldEntity ClockField { get; set; } public static ClockFieldEntity ClockField { get; set; }
/// <summary>
/// 布局保存信息
/// </summary>
public static SaveLayoutFieldEntity SaveLayoutField { get; set; }
} }
} }
...@@ -24,6 +24,11 @@ namespace VIZ.Package.Domain ...@@ -24,6 +24,11 @@ namespace VIZ.Package.Domain
/// <summary> /// <summary>
/// 分隔线 /// 分隔线
/// </summary> /// </summary>
Separator Separator,
/// <summary>
/// 保存布局
/// </summary>
CheckBox1
} }
} }
...@@ -81,8 +81,22 @@ namespace VIZ.Package.Domain.Model ...@@ -81,8 +81,22 @@ namespace VIZ.Package.Domain.Model
get { return filePath; } get { return filePath; }
set { filePath=value; this.RaisePropertyChanged(nameof(FilePath)); } set { filePath=value; this.RaisePropertyChanged(nameof(FilePath)); }
} }
#endregion #endregion
/// <summary>
/// 是否勾选
/// </summary>
private bool isClosed=true;
public bool IsClosed
{
get { return isClosed; }
set { isClosed = value; this.RaisePropertyChanged(nameof(IsClosed)); }
}
#region Command -- 命令 #region Command -- 命令
private VCommand<string> command; private VCommand<string> command;
......
...@@ -303,6 +303,11 @@ namespace VIZ.Package.Module ...@@ -303,6 +303,11 @@ namespace VIZ.Package.Module
clockFieldEntity= clockFieldEntity ?? new ClockFieldEntity(); clockFieldEntity= clockFieldEntity ?? new ClockFieldEntity();
ApplicationDomainEx.ClockField= clockFieldEntity; ApplicationDomainEx.ClockField= clockFieldEntity;
// 布局保存存在加载数据读取
SaveLayoutFieldEntity saveLayoutFieldEntity= ApplicationDomainEx.LocalDbContext.SaveLayoutField.FindAll().FirstOrDefault();
saveLayoutFieldEntity= saveLayoutFieldEntity ?? new SaveLayoutFieldEntity();
ApplicationDomainEx.SaveLayoutField = saveLayoutFieldEntity;
// Step 3. 加载插件信息 // Step 3. 加载插件信息
ApplicationDomainEx.PluginInfos = this.pluginService.LoadPluginInfos(); ApplicationDomainEx.PluginInfos = this.pluginService.LoadPluginInfos();
......
...@@ -31,6 +31,11 @@ namespace VIZ.Package.Module ...@@ -31,6 +31,11 @@ namespace VIZ.Package.Module
public DataTemplate SeparatorTemplate { get; set; } public DataTemplate SeparatorTemplate { get; set; }
/// <summary> /// <summary>
/// 添加勾选布局类型
/// </summary>
public DataTemplate CheckBoxLayoutTemplate { get; set; }
/// <summary>
/// 选择模板 /// 选择模板
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
...@@ -45,6 +50,8 @@ namespace VIZ.Package.Module ...@@ -45,6 +50,8 @@ namespace VIZ.Package.Module
case MenuItemType.Button: return this.ButtonDataTemplate; case MenuItemType.Button: return this.ButtonDataTemplate;
case MenuItemType.CheckBox: return this.CheckBoxDataTemplate; case MenuItemType.CheckBox: return this.CheckBoxDataTemplate;
case MenuItemType.Separator: return this.SeparatorTemplate; case MenuItemType.Separator: return this.SeparatorTemplate;
case MenuItemType.CheckBox1:return this.CheckBoxLayoutTemplate;
} }
return null; return null;
......
...@@ -35,6 +35,17 @@ ...@@ -35,6 +35,17 @@
</ContentControl> </ContentControl>
</DataTemplate> </DataTemplate>
</local:MainTopViewMenuDataTemplateSelector.CheckBoxDataTemplate> </local:MainTopViewMenuDataTemplateSelector.CheckBoxDataTemplate>
<local:MainTopViewMenuDataTemplateSelector.CheckBoxLayoutTemplate>
<DataTemplate>
<ContentControl>
<dxb:BarCheckItem Content="{Binding Header}" Command="{Binding Path=Command}" CommandParameter="{Binding Path=FilePath}"
IsChecked="{Binding IsClosed,Mode=TwoWay,Converter={StaticResource Bool2BoolConverterSimple}}" >
</dxb:BarCheckItem>
</ContentControl>
</DataTemplate>
</local:MainTopViewMenuDataTemplateSelector.CheckBoxLayoutTemplate>
<local:MainTopViewMenuDataTemplateSelector.SeparatorTemplate> <local:MainTopViewMenuDataTemplateSelector.SeparatorTemplate>
<DataTemplate> <DataTemplate>
<ContentControl> <ContentControl>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<TextBlock Text="布局名称:" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,10,0" Grid.Row="0"></TextBlock> <TextBlock Text="布局名称:" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,10,0" Grid.Row="0"></TextBlock>
<TextBox Text="{Binding Path=FolderName,Mode=TwoWay}" Grid.Row="1" VerticalContentAlignment="Center" HorizontalAlignment="Left" HorizontalContentAlignment="Left" <TextBox Text="{Binding Path=FolderName,Mode=TwoWay}" Grid.Row="1" VerticalContentAlignment="Center" HorizontalAlignment="Left" HorizontalContentAlignment="Left"
AcceptsReturn="False" TextWrapping="NoWrap" Height="30" Margin="10,0,10,0" Width="275"></TextBox> AcceptsReturn="False" Height="30" Margin="10,0,10,0" Width="265"></TextBox>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
......
...@@ -4,6 +4,7 @@ using log4net; ...@@ -4,6 +4,7 @@ using log4net;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Security.Cryptography; using System.Security.Cryptography;
...@@ -138,6 +139,8 @@ namespace VIZ.Package.Module ...@@ -138,6 +139,8 @@ namespace VIZ.Package.Module
#endregion #endregion
// ===================================================================== // =====================================================================
// Command // Command
// ===================================================================== // =====================================================================
...@@ -205,6 +208,9 @@ namespace VIZ.Package.Module ...@@ -205,6 +208,9 @@ namespace VIZ.Package.Module
items.Add(new MenuItemModel { Type = MenuItemType.Separator }); items.Add(new MenuItemModel { Type = MenuItemType.Separator });
//读取文件中配置文件 //读取文件中配置文件
if (Directory.Exists(path)) if (Directory.Exists(path))
{ {
...@@ -216,9 +222,14 @@ namespace VIZ.Package.Module ...@@ -216,9 +222,14 @@ namespace VIZ.Package.Module
menuItemModel.Header = Path.GetFileNameWithoutExtension(file); menuItemModel.Header = Path.GetFileNameWithoutExtension(file);
if (file == ApplicationDomainEx.SaveLayoutField.Path)
{
menuItemModel.IsClosed = false;
}
if (Convert.ToString(menuItemModel.Header) != "layout" && (Convert.ToString(menuItemModel.Header) != "default_layout")) if (Convert.ToString(menuItemModel.Header) != "layout" && (Convert.ToString(menuItemModel.Header) != "default_layout"))
{ {
menuItemModel.Type = MenuItemType.Button; menuItemModel.Type = MenuItemType.CheckBox1;
menuItemModel.FilePath = file; menuItemModel.FilePath = file;
menuItemModel.Command = this.ImportLayoutCommand; menuItemModel.Command = this.ImportLayoutCommand;
...@@ -431,13 +442,13 @@ namespace VIZ.Package.Module ...@@ -431,13 +442,13 @@ namespace VIZ.Package.Module
System.IO.File.Copy(ApplicationDomainEx.VizConfig.ProjectPath, path, true); System.IO.File.Copy(ApplicationDomainEx.VizConfig.ProjectPath, path, true);
DirectoryInfo pathInfo = new DirectoryInfo(ApplicationDomainEx.VizConfig.ProjectPath); DirectoryInfo pathInfo = new DirectoryInfo(ApplicationDomainEx.VizConfig.ProjectPath);
string sourceLogPath= System.IO.Path.Combine(pathInfo.Parent.FullName,this.ProjectName+ ApplicationConstants.PROJECT_FILE_LOG_NAME_SUFFIX); string sourceLogPath = System.IO.Path.Combine(pathInfo.Parent.FullName, this.ProjectName + ApplicationConstants.PROJECT_FILE_LOG_NAME_SUFFIX);
if (System.IO.File.Exists(sourceLogPath)) if (System.IO.File.Exists(sourceLogPath))
{ {
System.IO.File.Copy(sourceLogPath, logPath,true); System.IO.File.Copy(sourceLogPath, logPath, true);
} }
//把新的东西保存新的库里 //把新的东西保存新的库里
...@@ -563,6 +574,17 @@ namespace VIZ.Package.Module ...@@ -563,6 +574,17 @@ namespace VIZ.Package.Module
// 记录操作日志 // 记录操作日志
this.recordLogService.AppendLog(ApplicationConstants.APPLICATION_GROUP_NAME, RecordLogOperate.Operate, RecordLogTrigger.Human, RecordLogConstants.OPERATE_SETTING_RESET_LAYOUT); this.recordLogService.AppendLog(ApplicationConstants.APPLICATION_GROUP_NAME, RecordLogOperate.Operate, RecordLogTrigger.Human, RecordLogConstants.OPERATE_SETTING_RESET_LAYOUT);
SaveLayoutData("");
//重新设置布局
var Items = this.ItemsSource.Where(a => a.Type == MenuItemType.CheckBox1).ToObservableCollection();
foreach (var item in Items)
{
item.IsClosed = true;
}
service.LoadLayout(); service.LoadLayout();
} }
...@@ -585,9 +607,41 @@ namespace VIZ.Package.Module ...@@ -585,9 +607,41 @@ namespace VIZ.Package.Module
service.ImportLayout(param); service.ImportLayout(param);
//this.ItemsSource.FirstOrDefault(a => a.FilePath == param).Icon = "/VIZ.Package.Module.Resource;component/Icons/right24x244.png";
var Items = this.ItemsSource.Where(a => a.Type == MenuItemType.CheckBox1).ToObservableCollection();
foreach (var item in Items)
{
if (item.FilePath == param)
{
item.IsClosed = false;
}
else
{
item.IsClosed = true;
}
}
SaveLayoutData(param);
} }
/// <summary>
/// 保存布局到数据库里
/// </summary>
/// <param name="param"></param>
private void SaveLayoutData(string param)
{
//存放布局缓存
SaveLayoutFieldEntity saveLayoutField = ApplicationDomainEx.SaveLayoutField;
saveLayoutField.Path = param;
ApplicationDomainEx.LocalDbContext.SaveLayoutField.Upsert(saveLayoutField);
}
/// <summary> /// <summary>
/// 获取布局文件路径 /// 获取布局文件路径
...@@ -646,7 +700,7 @@ namespace VIZ.Package.Module ...@@ -646,7 +700,7 @@ namespace VIZ.Package.Module
ManagerLayoutViewModel vm = managerLayout.DataContext as ManagerLayoutViewModel; ManagerLayoutViewModel vm = managerLayout.DataContext as ManagerLayoutViewModel;
vm.ItemsSource = ItemsSource.Where(a => !string.IsNullOrEmpty(a.FilePath) && Convert.ToString(a.Header) != "保存布局").ToObservableCollection(); vm.ItemsSource = ItemsSource.Where(a => a.Type == MenuItemType.CheckBox1).ToObservableCollection();
managerLayout.ShowDialog(); managerLayout.ShowDialog();
} }
......
...@@ -184,7 +184,7 @@ namespace VIZ.Package.Module ...@@ -184,7 +184,7 @@ namespace VIZ.Package.Module
private void OnApplicationClosedMessage(ApplicationClosedMessage msg) private void OnApplicationClosedMessage(ApplicationClosedMessage msg)
{ {
// 保存布局 // 保存布局
this.SaveLayout(); //this.SaveLayout();
} }
// ============================================================ // ============================================================
...@@ -224,6 +224,8 @@ namespace VIZ.Package.Module ...@@ -224,6 +224,8 @@ namespace VIZ.Package.Module
// 获取当前布局文件路径 // 获取当前布局文件路径
string path = this.GetLayoutPath(); string path = this.GetLayoutPath();
if (string.IsNullOrEmpty(ApplicationDomainEx.SaveLayoutField.Path)||!File.Exists(ApplicationDomainEx.SaveLayoutField.Path))
{
// 如果没有布局文件,那么尝试使用默认布局文件 // 如果没有布局文件,那么尝试使用默认布局文件
if (string.IsNullOrWhiteSpace(path) || !System.IO.File.Exists(path)) if (string.IsNullOrWhiteSpace(path) || !System.IO.File.Exists(path))
{ {
...@@ -241,8 +243,16 @@ namespace VIZ.Package.Module ...@@ -241,8 +243,16 @@ namespace VIZ.Package.Module
{ {
return; return;
} }
}
else
{
path = ApplicationDomainEx.SaveLayoutField.Path;
}
view.dockLayoutManager.RestoreLayoutFromXml(path); view.dockLayoutManager.RestoreLayoutFromXml(path);
} }
/// <summary> /// <summary>
......
...@@ -128,7 +128,7 @@ namespace VIZ.Package.Module ...@@ -128,7 +128,7 @@ namespace VIZ.Package.Module
service.ItemsSource.Add(new Domain.Model.MenuItemModel() service.ItemsSource.Add(new Domain.Model.MenuItemModel()
{ {
Header = FolderName, Header = FolderName,
Type = MenuItemType.Button, Type = MenuItemType.CheckBox1,
FilePath = createPath, FilePath = createPath,
Command = service.ImportLayoutCommand Command = service.ImportLayoutCommand
}); });
......
using LiteDB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Storage
{
public class SaveLayoutFieldEntity
{
/// <summary>
/// 编号
/// </summary>
[BsonId(true)]
public int Id { get; set; }
/// <summary>
/// 保存路径
/// </summary>
public string Path { get; set; }
}
}
...@@ -40,6 +40,8 @@ namespace VIZ.Package.Storage ...@@ -40,6 +40,8 @@ namespace VIZ.Package.Storage
this.Conn = this.Database.GetCollection<ConnEntity>(); this.Conn = this.Database.GetCollection<ConnEntity>();
this.PluginMappingConfig = this.Database.GetCollection<PluginMappingConfigEntity>(); this.PluginMappingConfig = this.Database.GetCollection<PluginMappingConfigEntity>();
this.ClockField = this.Database.GetCollection<ClockFieldEntity>(); this.ClockField = this.Database.GetCollection<ClockFieldEntity>();
this.SaveLayoutField = this.Database.GetCollection<SaveLayoutFieldEntity>();
} }
/// <summary> /// <summary>
...@@ -78,6 +80,11 @@ namespace VIZ.Package.Storage ...@@ -78,6 +80,11 @@ namespace VIZ.Package.Storage
/// </summary> /// </summary>
public ILiteCollection<ClockFieldEntity> ClockField { get; private set; } public ILiteCollection<ClockFieldEntity> ClockField { get; private set; }
/// <summary>
/// 布局保存字段
/// </summary>
public ILiteCollection<SaveLayoutFieldEntity> SaveLayoutField { get; private set; }
/// <summary> /// <summary>
/// 插件映射 /// 插件映射
/// </summary> /// </summary>
......
...@@ -104,6 +104,7 @@ ...@@ -104,6 +104,7 @@
<Compile Include="Entity\ControlObject\ClockFieldEntity.cs" /> <Compile Include="Entity\ControlObject\ClockFieldEntity.cs" />
<Compile Include="Entity\ControlObject\ControlFieldEntity.cs" /> <Compile Include="Entity\ControlObject\ControlFieldEntity.cs" />
<Compile Include="Entity\ControlObject\ControlObjectEntity.cs" /> <Compile Include="Entity\ControlObject\ControlObjectEntity.cs" />
<Compile Include="Entity\ControlObject\SaveLayoutFieldEntity.cs" />
<Compile Include="Entity\Page\PageEntityBase.cs" /> <Compile Include="Entity\Page\PageEntityBase.cs" />
<Compile Include="Entity\Page\PageEntity.cs" /> <Compile Include="Entity\Page\PageEntity.cs" />
<Compile Include="Entity\Page\PageGroupEntity.cs" /> <Compile Include="Entity\Page\PageGroupEntity.cs" />
......
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