Commit 6aed39c7 by wangonghui

布局功能添加默认布局

parent e110e38f
......@@ -173,5 +173,10 @@ namespace VIZ.Package.Domain
/// 时钟控件保存信息
/// </summary>
public static ClockFieldEntity ClockField { get; set; }
/// <summary>
/// 布局保存信息
/// </summary>
public static SaveLayoutFieldEntity SaveLayoutField { get; set; }
}
}
......@@ -24,6 +24,11 @@ namespace VIZ.Package.Domain
/// <summary>
/// 分隔线
/// </summary>
Separator
Separator,
/// <summary>
/// 保存布局
/// </summary>
CheckBox1
}
}
......@@ -81,8 +81,22 @@ namespace VIZ.Package.Domain.Model
get { return filePath; }
set { filePath=value; this.RaisePropertyChanged(nameof(FilePath)); }
}
#endregion
/// <summary>
/// 是否勾选
/// </summary>
private bool isClosed=true;
public bool IsClosed
{
get { return isClosed; }
set { isClosed = value; this.RaisePropertyChanged(nameof(IsClosed)); }
}
#region Command -- 命令
private VCommand<string> command;
......
......@@ -303,6 +303,11 @@ namespace VIZ.Package.Module
clockFieldEntity= clockFieldEntity ?? new ClockFieldEntity();
ApplicationDomainEx.ClockField= clockFieldEntity;
// 布局保存存在加载数据读取
SaveLayoutFieldEntity saveLayoutFieldEntity= ApplicationDomainEx.LocalDbContext.SaveLayoutField.FindAll().FirstOrDefault();
saveLayoutFieldEntity= saveLayoutFieldEntity ?? new SaveLayoutFieldEntity();
ApplicationDomainEx.SaveLayoutField = saveLayoutFieldEntity;
// Step 3. 加载插件信息
ApplicationDomainEx.PluginInfos = this.pluginService.LoadPluginInfos();
......
......@@ -31,6 +31,11 @@ namespace VIZ.Package.Module
public DataTemplate SeparatorTemplate { get; set; }
/// <summary>
/// 添加勾选布局类型
/// </summary>
public DataTemplate CheckBoxLayoutTemplate { get; set; }
/// <summary>
/// 选择模板
/// </summary>
/// <returns></returns>
......@@ -45,6 +50,8 @@ namespace VIZ.Package.Module
case MenuItemType.Button: return this.ButtonDataTemplate;
case MenuItemType.CheckBox: return this.CheckBoxDataTemplate;
case MenuItemType.Separator: return this.SeparatorTemplate;
case MenuItemType.CheckBox1:return this.CheckBoxLayoutTemplate;
}
return null;
......
......@@ -23,7 +23,7 @@
<DataTemplate>
<ContentControl>
<dxb:BarButtonItem Glyph="{Binding Icon}" Content="{Binding Header}"
Command="{Binding Path=Command}" CommandParameter="{Binding Path=FilePath}" ></dxb:BarButtonItem>
Command="{Binding Path=Command}" CommandParameter="{Binding Path=FilePath}" ></dxb:BarButtonItem>
</ContentControl>
</DataTemplate>
</local:MainTopViewMenuDataTemplateSelector.ButtonDataTemplate>
......@@ -35,6 +35,17 @@
</ContentControl>
</DataTemplate>
</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>
<DataTemplate>
<ContentControl>
......
......@@ -19,7 +19,7 @@
<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"
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">
......
......@@ -4,6 +4,7 @@ using log4net;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
......@@ -138,6 +139,8 @@ namespace VIZ.Package.Module
#endregion
// =====================================================================
// Command
// =====================================================================
......@@ -205,6 +208,9 @@ namespace VIZ.Package.Module
items.Add(new MenuItemModel { Type = MenuItemType.Separator });
//读取文件中配置文件
if (Directory.Exists(path))
{
......@@ -216,9 +222,14 @@ namespace VIZ.Package.Module
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"))
{
menuItemModel.Type = MenuItemType.Button;
menuItemModel.Type = MenuItemType.CheckBox1;
menuItemModel.FilePath = file;
menuItemModel.Command = this.ImportLayoutCommand;
......@@ -431,13 +442,13 @@ namespace VIZ.Package.Module
System.IO.File.Copy(ApplicationDomainEx.VizConfig.ProjectPath, path, true);
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))
{
System.IO.File.Copy(sourceLogPath, logPath,true);
System.IO.File.Copy(sourceLogPath, logPath, true);
}
//把新的东西保存新的库里
......@@ -449,7 +460,7 @@ namespace VIZ.Package.Module
ApplicationDomainEx.VizConfig.ProjectPath = path;
ApplicationDomainEx.LocalDbContext.VizConfig.Update(ApplicationDomainEx.VizConfig);
this.ProjectName = System.IO.Path.GetFileNameWithoutExtension(path);
this.ProjectName = System.IO.Path.GetFileNameWithoutExtension(path);
// 记录操作日志
......@@ -563,6 +574,17 @@ namespace VIZ.Package.Module
// 记录操作日志
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();
}
......@@ -585,9 +607,41 @@ namespace VIZ.Package.Module
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>
/// 获取布局文件路径
......@@ -646,7 +700,7 @@ namespace VIZ.Package.Module
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();
}
......
......@@ -184,7 +184,7 @@ namespace VIZ.Package.Module
private void OnApplicationClosedMessage(ApplicationClosedMessage msg)
{
// 保存布局
this.SaveLayout();
//this.SaveLayout();
}
// ============================================================
......@@ -224,25 +224,35 @@ namespace VIZ.Package.Module
// 获取当前布局文件路径
string path = this.GetLayoutPath();
// 如果没有布局文件,那么尝试使用默认布局文件
if (string.IsNullOrWhiteSpace(path) || !System.IO.File.Exists(path))
if (string.IsNullOrEmpty(ApplicationDomainEx.SaveLayoutField.Path)||!File.Exists(ApplicationDomainEx.SaveLayoutField.Path))
{
path = this.GetDefaultLayoutPath();
// 如果没有布局文件,那么尝试使用默认布局文件
if (string.IsNullOrWhiteSpace(path) || !System.IO.File.Exists(path))
{
path = this.GetDefaultLayoutPath();
}
// 如果没有对应插件布局文件,那么尝试使用系统默认布局文件
if (string.IsNullOrWhiteSpace(path) || !System.IO.File.Exists(path))
{
path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "layout", "default_layout.xml");
}
// 如果布局文件不存在,那么不加载布局
if (!System.IO.File.Exists(path))
{
return;
}
}
// 如果没有对应插件布局文件,那么尝试使用系统默认布局文件
if (string.IsNullOrWhiteSpace(path) || !System.IO.File.Exists(path))
else
{
path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "layout", "default_layout.xml");
path = ApplicationDomainEx.SaveLayoutField.Path;
}
// 如果布局文件不存在,那么不加载布局
if (!System.IO.File.Exists(path))
{
return;
}
view.dockLayoutManager.RestoreLayoutFromXml(path);
}
/// <summary>
......
......@@ -128,7 +128,7 @@ namespace VIZ.Package.Module
service.ItemsSource.Add(new Domain.Model.MenuItemModel()
{
Header = FolderName,
Type = MenuItemType.Button,
Type = MenuItemType.CheckBox1,
FilePath = createPath,
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
this.Conn = this.Database.GetCollection<ConnEntity>();
this.PluginMappingConfig = this.Database.GetCollection<PluginMappingConfigEntity>();
this.ClockField = this.Database.GetCollection<ClockFieldEntity>();
this.SaveLayoutField = this.Database.GetCollection<SaveLayoutFieldEntity>();
}
/// <summary>
......@@ -78,6 +80,11 @@ namespace VIZ.Package.Storage
/// </summary>
public ILiteCollection<ClockFieldEntity> ClockField { get; private set; }
/// <summary>
/// 布局保存字段
/// </summary>
public ILiteCollection<SaveLayoutFieldEntity> SaveLayoutField { get; private set; }
/// <summary>
/// 插件映射
/// </summary>
......
......@@ -104,6 +104,7 @@
<Compile Include="Entity\ControlObject\ClockFieldEntity.cs" />
<Compile Include="Entity\ControlObject\ControlFieldEntity.cs" />
<Compile Include="Entity\ControlObject\ControlObjectEntity.cs" />
<Compile Include="Entity\ControlObject\SaveLayoutFieldEntity.cs" />
<Compile Include="Entity\Page\PageEntityBase.cs" />
<Compile Include="Entity\Page\PageEntity.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