Commit 52ceed85 by liulongfei

1. 设置页面

2. 插件页面
3. 连接面板
parent 2792e8e9
...@@ -79,6 +79,11 @@ namespace VIZ.Package.Domain ...@@ -79,6 +79,11 @@ namespace VIZ.Package.Domain
public static ConnModel PreviewConn { get; set; } public static ConnModel PreviewConn { get; set; }
/// <summary> /// <summary>
/// 连接分组
/// </summary>
public static List<ConnGroupModel> ConnGroups { get; set; }
/// <summary>
/// Viz预览进程 /// Viz预览进程
/// </summary> /// </summary>
public static Process VizPreviewProcess { get; set; } public static Process VizPreviewProcess { get; set; }
......
...@@ -65,5 +65,17 @@ namespace VIZ.Package.Domain ...@@ -65,5 +65,17 @@ namespace VIZ.Package.Domain
/// 命令 /// 命令
/// </summary> /// </summary>
public const string COMMAND = "COMMAND"; public const string COMMAND = "COMMAND";
// ========================================================================
/// <summary>
/// 连接设置
/// </summary>
public const string CONN_SETTING = "CONN_SETTING";
/// <summary>
/// Viz设置
/// </summary>
public const string VIZ_CONFIG_SETTING = "VIZ_CONFIG_SETTING";
} }
} }
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Domain
{
/// <summary>
/// 连接改变消息
/// </summary>
public class ConnChangedMessage
{
/// <summary>
/// 老的连接分组
/// </summary>
public ConnGroupModel OldGroup { get; set; }
/// <summary>
/// 新的连接分组
/// </summary>
public ConnGroupModel NewGroup { get; set; }
}
}
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.Package.Storage;
namespace VIZ.Package.Domain namespace VIZ.Package.Domain
{ {
...@@ -53,5 +55,34 @@ namespace VIZ.Package.Domain ...@@ -53,5 +55,34 @@ namespace VIZ.Package.Domain
} }
#endregion #endregion
#region EngineType -- 引擎类型
private EngineType engineType;
/// <summary>
/// 引擎类型
/// </summary>
public EngineType EngineType
{
get { return engineType; }
set { engineType = value; this.RaisePropertyChanged(nameof(EngineType)); }
}
#endregion
#region Items -- 连接项集合
private ObservableCollection<ConnModel> items = new ObservableCollection<ConnModel>();
/// <summary>
/// 连接项集合
/// </summary>
public ObservableCollection<ConnModel> Items
{
get { return items; }
set { items = value; this.RaisePropertyChanged(nameof(Items)); }
}
#endregion
} }
} }
...@@ -125,6 +125,22 @@ namespace VIZ.Package.Domain ...@@ -125,6 +125,22 @@ namespace VIZ.Package.Domain
#endregion #endregion
// ============================================================================
#region IsLoading -- 是否正在等待
private bool isLoading;
/// <summary>
/// 是否正在等待
/// </summary>
public bool IsLoading
{
get { return isLoading; }
set { isLoading = value; this.RaisePropertyChanged(nameof(IsLoading)); }
}
#endregion
/// <summary> /// <summary>
/// 连接终结点 /// 连接终结点
/// </summary> /// </summary>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Common;
namespace VIZ.Package.Domain
{
/// <summary>
/// 设置页模型
/// </summary>
public class SettingPageModel : NavigationConfig
{
#region Name -- 名称
private string name;
/// <summary>
/// 名称
/// </summary>
public string Name
{
get { return name; }
set { name = value; this.RaisePropertyChanged(nameof(Name)); }
}
#endregion
}
}
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
<Compile Include="Enum\ModulePluginIds.cs" /> <Compile Include="Enum\ModulePluginIds.cs" />
<Compile Include="Enum\ViewServiceKeys.cs" /> <Compile Include="Enum\ViewServiceKeys.cs" />
<Compile Include="Info\VizTreeNodeInfo.cs" /> <Compile Include="Info\VizTreeNodeInfo.cs" />
<Compile Include="Message\Conn\ConnChangedMessage.cs" />
<Compile Include="Message\ControlObject\ControlFieldChangedMessage.cs" /> <Compile Include="Message\ControlObject\ControlFieldChangedMessage.cs" />
<Compile Include="Message\Page\PageOpenMessage.cs" /> <Compile Include="Message\Page\PageOpenMessage.cs" />
<Compile Include="Message\Page\PageInitedMessage.cs" /> <Compile Include="Message\Page\PageInitedMessage.cs" />
...@@ -101,12 +102,17 @@ ...@@ -101,12 +102,17 @@
<Compile Include="Model\Resource\ResourceDragData.cs" /> <Compile Include="Model\Resource\ResourceDragData.cs" />
<Compile Include="Model\Resource\ResourceFileModelBase.cs" /> <Compile Include="Model\Resource\ResourceFileModelBase.cs" />
<Compile Include="Model\Resource\ResourceFolderModelBase.cs" /> <Compile Include="Model\Resource\ResourceFolderModelBase.cs" />
<Compile Include="Model\Setting\SettingPageModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\VIZ.Framework\VIZ.Framework.Common\VIZ.Framework.Common.csproj">
<Project>{92834c05-703e-4f05-9224-f36220939d8f}</Project>
<Name>VIZ.Framework.Common</Name>
</ProjectReference>
<ProjectReference Include="..\..\VIZ.Framework\VIZ.Framework.Connection\VIZ.Framework.Connection.csproj"> <ProjectReference Include="..\..\VIZ.Framework\VIZ.Framework.Connection\VIZ.Framework.Connection.csproj">
<Project>{e07528dd-9dee-47c2-b79d-235ecfa6b003}</Project> <Project>{e07528dd-9dee-47c2-b79d-235ecfa6b003}</Project>
<Name>VIZ.Framework.Connection</Name> <Name>VIZ.Framework.Connection</Name>
......
...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module ...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module
} }
/// <summary> /// <summary>
/// 初始化
/// </summary>
public void Initialize()
{
}
/// <summary>
/// 销毁 /// 销毁
/// </summary> /// </summary>
public void Dispose() public void Dispose()
......
...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module ...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module
} }
/// <summary> /// <summary>
/// 初始化
/// </summary>
public void Initialize()
{
}
/// <summary>
/// 销毁 /// 销毁
/// </summary> /// </summary>
public void Dispose() public void Dispose()
......
...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module ...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module
} }
/// <summary> /// <summary>
/// 初始化
/// </summary>
public void Initialize()
{
}
/// <summary>
/// 销毁 /// 销毁
/// </summary> /// </summary>
public void Dispose() public void Dispose()
......
...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module ...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module
} }
/// <summary> /// <summary>
/// 初始化
/// </summary>
public void Initialize()
{
}
/// <summary>
/// 销毁 /// 销毁
/// </summary> /// </summary>
public void Dispose() public void Dispose()
......
...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module ...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module
} }
/// <summary> /// <summary>
/// 初始化
/// </summary>
public void Initialize()
{
}
/// <summary>
/// 销毁 /// 销毁
/// </summary> /// </summary>
public void Dispose() public void Dispose()
......
...@@ -285,7 +285,7 @@ namespace VIZ.Package.Module ...@@ -285,7 +285,7 @@ namespace VIZ.Package.Module
vizConfig.PluginGroup = this.SelectedPluginGroup; vizConfig.PluginGroup = this.SelectedPluginGroup;
vizConfig.EngineFullType = (EngineFullType)this.SelectedEngineFullType.Key; vizConfig.EngineFullType = (EngineFullType)this.SelectedEngineFullType.Key;
ApplicationDomainEx.LocalDbContext.VizConfig.Update(vizConfig); ApplicationDomainEx.LocalDbContext.VizConfig.Upsert(vizConfig);
Window loginWindow = this.GetWindow(); Window loginWindow = this.GetWindow();
loginWindow.ShowInTaskbar = false; loginWindow.ShowInTaskbar = false;
......
<UserControl x:Class="VIZ.Package.Module.MainConnView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dxdo="http://schemas.devexpress.com/winfx/2008/xaml/docking"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:plugin="clr-namespace:VIZ.Package.Plugin;assembly=VIZ.Package.Plugin"
xmlns:local="clr-namespace:VIZ.Package.Module"
d:DataContext="{d:DesignInstance Type=local:MainConnViewModel}"
mc:Ignorable="d" x:Name="uc"
d:DesignHeight="35" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/VIZ.Framework.Common.Resource;component/Style/ListBox/ListBox_None.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<fcore:Bool2BoolConverter x:Key="Bool2BoolConverter"></fcore:Bool2BoolConverter>
<fcore:Bool2SolidColorBrushConverter x:Key="Bool2SolidColorBrushConverter"
TrueBrush="#FF92FF3D"
FalseBrush="#FFFF5353"
NoneBrush="#FFFF5353"></fcore:Bool2SolidColorBrushConverter>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<ListBox Style="{StaticResource ListBox_None}"
ItemsSource="{Binding Path=ItemsSrouce}"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Border>
<StackPanel Orientation="Horizontal" Background="Transparent" VerticalAlignment="Center"
IsEnabled="{Binding Path=IsLoading,Converter={StaticResource Bool2BoolConverter}}"
TextBlock.Foreground="{Binding Path=IsConnected,Converter={StaticResource Bool2SolidColorBrushConverter}}"
TextBlock.FontSize="14"
Cursor="Hand" MinWidth="120" Margin="10,0,0,0">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand Event="PreviewMouseLeftButtonDown"
CommandParameter="{Binding .}"
Command="{Binding Path=DataContext.ItemClickCommand,ElementName=uc}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
<TextBlock Text="{Binding Path=IP}" VerticalAlignment="Center"></TextBlock>
<TextBlock Text=":" Margin="3,0,3,0" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="{Binding Path=Port}" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="[" Margin="3,0,3,0" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="{Binding Path=Remark}" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="]" Margin="3,0,3,0" VerticalAlignment="Center"></TextBlock>
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Navigation;
using System.Windows.Shapes;
using VIZ.Framework.Core;
namespace VIZ.Package.Module
{
/// <summary>
/// MainConnView.xaml 的交互逻辑
/// </summary>
public partial class MainConnView : UserControl
{
public MainConnView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new MainConnViewModel());
}
}
}
<UserControl x:Class="VIZ.Package.Module.MainStatusView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VIZ.Package.Module"
mc:Ignorable="d"
d:DesignHeight="35" d:DesignWidth="800">
<Grid>
<TextBlock Text="状态" Foreground="Red" FontSize="24" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Navigation;
using System.Windows.Shapes;
using VIZ.Framework.Core;
namespace VIZ.Package.Module
{
/// <summary>
/// MainStatusView.xaml 的交互逻辑
/// </summary>
public partial class MainStatusView : UserControl
{
public MainStatusView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new MainStatusViewModel());
}
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Package.Connection;
using VIZ.Package.Domain;
using VIZ.Package.Service;
namespace VIZ.Package.Module
{
/// <summary>
/// 主连接视图模型
/// </summary>
public class MainConnViewModel : ViewModelBase
{
/// <summary>
/// 日志
/// </summary>
private readonly static ILog log = LogManager.GetLogger(typeof(MainConnViewModel));
public MainConnViewModel()
{
// 初始化命令
this.InitCommnad();
// 初始化消息
this.InitMessage();
}
/// <summary>
/// 初始化命令
/// </summary>
private void InitCommnad()
{
this.ItemClickCommand = new VCommand<ConnModel>(this.ItemClick);
}
/// <summary>
/// 初始化消息
/// </summary>
private void InitMessage()
{
ApplicationDomainEx.MessageManager.Register<ConnChangedMessage>(this, this.OnConnChangedMessage);
ApplicationDomainEx.MessageManager.Register<VizPreviewReadyMessage>(this, this.OnVizPreviewReadyMessage);
}
// ==========================================================================
// Field & Service
// ==========================================================================
/// <summary>
/// 连接服务
/// </summary>
private ConnService connService = new ConnService();
// ==========================================================================
// Property
// ==========================================================================
#region ItemsSrouce -- 数据源
private ObservableCollection<ConnModel> itemsSrouce = new ObservableCollection<ConnModel>();
/// <summary>
/// 数据源
/// </summary>
public ObservableCollection<ConnModel> ItemsSrouce
{
get { return itemsSrouce; }
set { itemsSrouce = value; this.RaisePropertyChanged(nameof(ItemsSrouce)); }
}
#endregion
// ==========================================================================
// Command
// ==========================================================================
#region ItemClickCommand -- 项点击命令
/// <summary>
/// 项点击命令
/// </summary>
public VCommand<ConnModel> ItemClickCommand { get; set; }
/// <summary>
/// 项点击命令
/// </summary>
/// <param name="model">连接模型</param>
private void ItemClick(ConnModel model)
{
model.IsLoading = true;
ThreadHelper.SafeRun(action: () =>
{
if (model.IsConnected)
{
model.EndpointManager.Disconnect();
}
else
{
model.EndpointManager.Connect();
}
}, final: () =>
{
model.IsLoading = false;
});
}
#endregion
// ==========================================================================
// Message
// ==========================================================================
/// <summary>
/// 连接改变消息
/// </summary>
/// <param name="msg">消息</param>
private void OnConnChangedMessage(ConnChangedMessage msg)
{
if (msg.OldGroup != null)
{
foreach (ConnModel item in msg.OldGroup.Items)
{
item.Dispose();
}
}
this.InitAndConnnectGroups(msg.NewGroup);
}
/// <summary>
/// Viz引擎初始化完成消息
/// </summary>
/// <param name="msg">消息</param>
private void OnVizPreviewReadyMessage(VizPreviewReadyMessage msg)
{
List<ConnGroupModel> groups = this.connService.LoadGroups();
ApplicationDomainEx.ConnGroups = groups;
ConnGroupModel group = groups.FirstOrDefault(p => p.IsEnabled == true);
this.InitAndConnnectGroups(group);
}
/// <summary>
/// 初始化 & 连接
/// </summary>
/// <param name="group">连接分组</param>
private void InitAndConnnectGroups(ConnGroupModel group)
{
this.ItemsSrouce.Clear();
// 预览连接
this.ItemsSrouce.Add(ApplicationDomainEx.PreviewConn);
if (group == null)
return;
foreach (ConnModel item in group.Items)
{
item.InitEndpointManager(new VizEndpointManager(item.ConnID.ToString(), item.IP, item.Port));
this.ItemsSrouce.Add(item);
// 启动连接
ThreadHelper.SafeRun(() =>
{
try
{
item.EndpointManager.Connect();
}
catch (Exception ex)
{
log.Error(ex);
}
});
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
namespace VIZ.Package.Module
{
/// <summary>
/// 状态视图模型
/// </summary>
public class MainStatusViewModel : ViewModelBase
{
}
}
...@@ -253,7 +253,9 @@ namespace VIZ.Package.Module ...@@ -253,7 +253,9 @@ namespace VIZ.Package.Module
/// </summary> /// </summary>
private void Setting() private void Setting()
{ {
SettingWindow window = new SettingWindow();
window.Owner = ApplicationDomainEx.MainWindow;
window.ShowDialog();
} }
#endregion #endregion
......
...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module ...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module
} }
/// <summary> /// <summary>
/// 初始化
/// </summary>
public void Initialize()
{
}
/// <summary>
/// 销毁 /// 销毁
/// </summary> /// </summary>
public void Dispose() public void Dispose()
......
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
xmlns:local="clr-namespace:VIZ.Package.Module" xmlns:local="clr-namespace:VIZ.Package.Module"
d:DataContext="{d:DesignInstance Type=local:PageAddViewModel}" d:DataContext="{d:DesignInstance Type=local:PageAddViewModel}"
mc:Ignorable="d" WindowStartupLocation="CenterScreen" mc:Ignorable="d" WindowStartupLocation="CenterScreen"
Title="PageAddWindow" Height="800" Width="1000"> Title="添加页" Height="300" Width="600">
<dxmvvm:Interaction.Behaviors> <dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="Loaded" Command="{Binding Path=LoadedCommand}"></dxmvvm:EventToCommand> <dxmvvm:EventToCommand EventName="Loaded" Command="{Binding Path=LoadedCommand}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors> </dxmvvm:Interaction.Behaviors>
<Grid> <Grid Margin="20">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="120"></ColumnDefinition> <ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition> <ColumnDefinition Width="*"></ColumnDefinition>
...@@ -53,8 +53,8 @@ ...@@ -53,8 +53,8 @@
<!-- 按钮组 --> <!-- 按钮组 -->
<StackPanel Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal"> <StackPanel Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal">
<Button Width="80" Height="30" Content="確定" Margin="10" Command="{Binding Path=EnterCommand}"></Button> <Button Width="80" Height="30" Content="確定" Margin="0" Command="{Binding Path=EnterCommand}"></Button>
<Button Width="80" Height="30" Content="取消" Margin="10" Command="{Binding Path=CancelCommand}"></Button> <Button Width="80" Height="30" Content="取消" Margin="20,0,0,0" Command="{Binding Path=CancelCommand}"></Button>
</StackPanel> </StackPanel>
</Grid> </Grid>
......
...@@ -122,7 +122,7 @@ namespace VIZ.Package.Module ...@@ -122,7 +122,7 @@ namespace VIZ.Package.Module
/// </summary> /// </summary>
private void Loaded() private void Loaded()
{ {
this.TemplatePlugins = ApplicationDomainEx.PluginInfos.Where(p => p.PluginType == PluginType.Pages).ToList(); this.TemplatePlugins = ApplicationDomainEx.PluginInfos.Where(p => p.PluginType == PluginType.Page).ToList();
// TODO: 选择默认模板 // TODO: 选择默认模板
} }
......
...@@ -265,6 +265,7 @@ namespace VIZ.Package.Module ...@@ -265,6 +265,7 @@ namespace VIZ.Package.Module
} }
#endregion #endregion
// ====================================================================================== // ======================================================================================
// Message // Message
// ====================================================================================== // ======================================================================================
...@@ -287,6 +288,7 @@ namespace VIZ.Package.Module ...@@ -287,6 +288,7 @@ namespace VIZ.Package.Module
var pageGroups = this.pageService.LoadPageGroups().ToObservableCollection(); var pageGroups = this.pageService.LoadPageGroups().ToObservableCollection();
// 更新界面 // 更新界面
WPFHelper.Invoke(() => WPFHelper.Invoke(() =>
{ {
this.PageGroupModels = pageGroups; this.PageGroupModels = pageGroups;
......
...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module ...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module
} }
/// <summary> /// <summary>
/// 初始化
/// </summary>
public void Initialize()
{
}
/// <summary>
/// 销毁 /// 销毁
/// </summary> /// </summary>
public void Dispose() public void Dispose()
......
...@@ -239,7 +239,7 @@ namespace VIZ.Package.Module ...@@ -239,7 +239,7 @@ namespace VIZ.Package.Module
PageTemplateModel cmd = new PageTemplateModel(); PageTemplateModel cmd = new PageTemplateModel();
cmd.PageType = PageType.Command; cmd.PageType = PageType.Command;
cmd.Remark = "命令模板"; cmd.Remark = "命令模板";
cmd.EngineType = EngineType.VIZ; cmd.EngineType = EngineType.Viz;
cmd.ThumbnailBitmap = VIZ.Package.Module.Resource.Properties.Resources.cmd_template; cmd.ThumbnailBitmap = VIZ.Package.Module.Resource.Properties.Resources.cmd_template;
otherTemplateModels.Add(cmd); otherTemplateModels.Add(cmd);
...@@ -307,7 +307,7 @@ namespace VIZ.Package.Module ...@@ -307,7 +307,7 @@ namespace VIZ.Package.Module
model.ScenePath = fileModel.Path; model.ScenePath = fileModel.Path;
model.Layer = VizLayer.MAIN_LAYER; model.Layer = VizLayer.MAIN_LAYER;
model.PageType = PageType.Scene; model.PageType = PageType.Scene;
model.EngineType = EngineType.VIZ; model.EngineType = EngineType.Viz;
model.ThumbnailUri = fileModel.Thumbnail; model.ThumbnailUri = fileModel.Thumbnail;
model.ThumbnailBitmap = fileModel.ThumbnailBitmap; model.ThumbnailBitmap = fileModel.ThumbnailBitmap;
// 获取缩略图 // 获取缩略图
......
...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module ...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module
} }
/// <summary> /// <summary>
/// 初始化
/// </summary>
public void Initialize()
{
}
/// <summary>
/// 销毁 /// 销毁
/// </summary> /// </summary>
public void Dispose() public void Dispose()
......
...@@ -3,11 +3,22 @@ ...@@ -3,11 +3,22 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:fcommon="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common"
xmlns:storage="clr-namespace:VIZ.Package.Storage;assembly=VIZ.Package.Storage"
xmlns:resource="clr-namespace:VIZ.Package.Module.Resource;assembly=VIZ.Package.Module.Resource"
xmlns:local="clr-namespace:VIZ.Package.Module" xmlns:local="clr-namespace:VIZ.Package.Module"
xmlns:domain="clr-namespace:VIZ.Package.Domain;assembly=VIZ.Package.Domain"
d:DataContext="{d:DesignInstance Type=local:PluginViewModel}"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800">
<Grid> <Grid>
<TextBlock Text="插件" VerticalAlignment="Center" HorizontalAlignment="Center" <fcommon:NavigationControl ItemsSource="{Binding ItemsSource}"
FontSize="36" Foreground="Red"></TextBlock> SelectedValue="{Binding Path=SelectedItem,Mode=TwoWay}"></fcommon:NavigationControl>
</Grid> </Grid>
</UserControl> </UserControl>
using System; using log4net;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using VIZ.Framework.Common;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.Package.Domain;
using VIZ.Package.Plugin;
namespace VIZ.Package.Module namespace VIZ.Package.Module
{ {
...@@ -12,5 +17,126 @@ namespace VIZ.Package.Module ...@@ -12,5 +17,126 @@ namespace VIZ.Package.Module
/// </summary> /// </summary>
public class PluginViewModel : ViewModelBase public class PluginViewModel : ViewModelBase
{ {
/// <summary>
/// 日志
/// </summary>
private readonly static ILog log = LogManager.GetLogger(typeof(PluginViewModel));
public PluginViewModel()
{
// 初始化消息
this.InitMessage();
}
/// <summary>
/// 初始化消息
/// </summary>
private void InitMessage()
{
ApplicationDomainEx.MessageManager.Register<ProjectCloseMessage>(this, this.OnProjectCloseMessage);
ApplicationDomainEx.MessageManager.Register<PageInitedMessage>(this, this.OnPageInitedMessage);
}
// ========================================================================
// Property
// ========================================================================
#region SelectedValue -- 当前选择项
private NavigationConfig selectedValue;
/// <summary>
/// 当前选择项
/// </summary>
public NavigationConfig SelectedValue
{
get { return selectedValue; }
set { selectedValue = value; this.RaisePropertyChanged(nameof(SelectedValue)); }
}
#endregion
#region ItemsSource -- 数据源
private ObservableCollection<NavigationConfig> itemsSource = new ObservableCollection<NavigationConfig>();
/// <summary>
/// 数据源
/// </summary>
public ObservableCollection<NavigationConfig> ItemsSource
{
get { return itemsSource; }
set { itemsSource = value; this.RaisePropertyChanged(nameof(ItemsSource)); }
}
#endregion
// ========================================================================
// Command
// ========================================================================
// ========================================================================
// Message
// ========================================================================
/// <summary>
/// 项目关闭消息
/// </summary>
/// <param name="msg">消息</param>
private void OnProjectCloseMessage(ProjectCloseMessage msg)
{
this.SelectedValue = null;
foreach (NavigationConfig config in this.ItemsSource)
{
if (config.View == null || !config.View.TryGetTarget(out object target))
continue;
if (!(target is IPluginView view))
continue;
try
{
view.Dispose();
}
catch (Exception ex)
{
log.Error(ex);
}
}
}
/// <summary>
/// 页初始化完成消息
/// </summary>
/// <param name="msg">消息</param>
private void OnPageInitedMessage(PageInitedMessage msg)
{
// 页模板没有插件
if (msg.Page == null || msg.Page is PageTemplateModel)
{
this.SelectedValue = null;
return;
}
// 页拥有插件
PageModel page = msg.Page as PageModel;
NavigationConfig config = this.ItemsSource.FirstOrDefault(p => p.Key == page.PageID.ToString());
if (config != null)
{
this.SelectedValue = config;
return;
}
PluginInfo plugin = ApplicationDomainEx.PluginInfos.FirstOrDefault(p => p.ID == page.PluginID);
if (plugin == null)
return;
config = new NavigationConfig();
config.Key = page.PageID.ToString();
config.ViewType = plugin.ViewType;
this.ItemsSource.Add(config);
this.SelectedValue = config;
}
} }
} }
...@@ -65,8 +65,8 @@ namespace VIZ.Package.Module ...@@ -65,8 +65,8 @@ namespace VIZ.Package.Module
} }
if (vizConfig.EngineFullType == EngineFullType.VIZ_Eng4) if (vizConfig.EngineFullType == EngineFullType.VIZ_Eng4)
{ {
//ApplicationDomainEx.LocalVizManager.VizRenderersProcess.StartInfo.Arguments = $" -o -P -db {loginInfo.VIZ_UserName}:@{loginInfo.VIZ_IP}/{loginInfo.GH_ServerName}:{loginInfo.GH_Port}"; ApplicationDomainEx.VizPreviewProcess.StartInfo.Arguments = $" -o -P -db {vizConfig.VIZ_UserName}:@{vizConfig.VIZ_IP}/{vizConfig.GH_ServerName}:{vizConfig.GH_Port}";
ApplicationDomainEx.VizPreviewProcess.StartInfo.Arguments = $" -u1 -n -M -e {vizConfig.VIZ_UserName}:@{vizConfig.VIZ_IP}/{vizConfig.GH_ServerName}:{vizConfig.GH_Port}"; //ApplicationDomainEx.VizPreviewProcess.StartInfo.Arguments = $" -u1 -n -M -e {vizConfig.VIZ_UserName}:@{vizConfig.VIZ_IP}/{vizConfig.GH_ServerName}:{vizConfig.GH_Port}";
} }
ApplicationDomainEx.VizPreviewProcess.StartInfo.UseShellExecute = true; ApplicationDomainEx.VizPreviewProcess.StartInfo.UseShellExecute = true;
......
...@@ -493,6 +493,7 @@ namespace VIZ.Package.Module ...@@ -493,6 +493,7 @@ namespace VIZ.Package.Module
conn = new ConnModel(); conn = new ConnModel();
conn.IP = vizConfig.VIZ_IP; conn.IP = vizConfig.VIZ_IP;
conn.Port = vizConfig.VIZ_Port; conn.Port = vizConfig.VIZ_Port;
conn.Remark = "预览";
conn.InitEndpointManager(new VizEndpointManager("local", vizConfig.VIZ_IP, vizConfig.VIZ_Port)); conn.InitEndpointManager(new VizEndpointManager("local", vizConfig.VIZ_IP, vizConfig.VIZ_Port));
ApplicationDomainEx.PreviewConn = conn; ApplicationDomainEx.PreviewConn = conn;
......
...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module ...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module
} }
/// <summary> /// <summary>
/// 初始化
/// </summary>
public void Initialize()
{
}
/// <summary>
/// 销毁 /// 销毁
/// </summary> /// </summary>
public void Dispose() public void Dispose()
......
...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module ...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module
} }
/// <summary> /// <summary>
/// 初始化
/// </summary>
public void Initialize()
{
}
/// <summary>
/// 销毁 /// 销毁
/// </summary> /// </summary>
public void Dispose() public void Dispose()
......
...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module ...@@ -41,14 +41,6 @@ namespace VIZ.Package.Module
} }
/// <summary> /// <summary>
/// 初始化
/// </summary>
public void Initialize()
{
}
/// <summary>
/// 销毁 /// 销毁
/// </summary> /// </summary>
public void Dispose() public void Dispose()
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Package.Domain;
using VIZ.Package.Plugin;
namespace VIZ.Package.Module
{
/// <summary>
/// 连接插件生命周期
/// </summary>
public class ConnPluginLifeCycle : IPluginLifeCycle
{
/// <summary>
/// 插件ID
/// </summary>
/// <remarks>
/// 插件ID不能包含点号
/// </remarks>
public const string PLUGIN_ID = ModulePluginIds.CONN_SETTING;
/// <summary>
/// 插件名称
/// </summary>
public const string PLUGIN_NAME = "连接设置";
/// <summary>
/// 注册
/// </summary>
/// <returns>插件信息</returns>
public PluginInfo Register()
{
PluginInfo info = new PluginInfo();
info.ID = PLUGIN_ID;
info.Name = PLUGIN_NAME;
info.SettingViewType = typeof(ConnSettingView);
return info;
}
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Navigation;
using System.Windows.Shapes;
using VIZ.Framework.Core;
using VIZ.Package.Plugin;
namespace VIZ.Package.Module
{
/// <summary>
/// ConnSettingView.xaml 的交互逻辑
/// </summary>
public partial class ConnSettingView : UserControl, IPluginSettingView
{
public ConnSettingView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new ConnSettingViewModel());
}
/// <summary>
/// 保存
/// </summary>
public void Save()
{
ConnSettingViewModel vm = this.DataContext as ConnSettingViewModel;
vm.Save();
}
}
}
\ No newline at end of file
using log4net;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Package.Connection;
using VIZ.Package.Domain;
using VIZ.Package.Service;
namespace VIZ.Package.Module
{
/// <summary>
/// 连接设置视图模型
/// </summary>
public class ConnSettingViewModel : ViewModelBase
{
/// <summary>
/// 日志
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(ConnSettingViewModel));
public ConnSettingViewModel()
{
// 初始化命令
this.InitCommand();
}
/// <summary>
/// 初始化命令
/// </summary>
private void InitCommand()
{
this.LoadedCommand = new VCommand(this.Loaded);
this.AddGroupCommand = new VCommand(this.AddGroup);
this.DeleteGroupCommand = new VCommand(this.DeleteGroup);
this.EnabledGroupCommand = new VCommand(this.EnabledGroup);
this.AddItemCommand = new VCommand(this.AddItem);
this.DeleteItemCommand = new VCommand(this.DeleteItem);
}
// ==========================================================================
// Field & Service
// ==========================================================================
/// <summary>
/// 连接服务
/// </summary>
private ConnService connService = new ConnService();
// ======================================================================================
// Property
// ======================================================================================
#region Groups -- 分组集合
private ObservableCollection<ConnGroupModel> groups;
/// <summary>
/// 分组集合
/// </summary>
public ObservableCollection<ConnGroupModel> Groups
{
get { return groups; }
set { groups = value; this.RaisePropertyChanged(nameof(Groups)); }
}
#endregion
#region SelectedGroup -- 当前选中的分组
private ConnGroupModel selectedGroup;
/// <summary>
/// 当前选中的分组
/// </summary>
public ConnGroupModel SelectedGroup
{
get { return selectedGroup; }
set { selectedGroup = value; this.RaisePropertyChanged(nameof(SelectedGroup)); }
}
#endregion
#region SelectedItem -- 当前选中的项
private ConnModel selectedItem;
/// <summary>
/// 当前选中的项
/// </summary>
public ConnModel SelectedItem
{
get { return selectedItem; }
set { selectedItem = value; this.RaisePropertyChanged(nameof(SelectedItem)); }
}
#endregion
// ======================================================================================
// Command
// ======================================================================================
#region LoadedCommand -- 加载命令
/// <summary>
/// 加载命令
/// </summary>
public VCommand LoadedCommand { get; set; }
/// <summary>
/// 加载
/// </summary>
private void Loaded()
{
if (this.IsAlreadyLoaded)
return;
this.IsAlreadyLoaded = true;
this.Groups = this.connService.LoadGroups().ToObservableCollection();
}
#endregion
#region AddGroupCommand -- 添加分组命令
/// <summary>
/// 添加分组命令
/// </summary>
public VCommand AddGroupCommand { get; set; }
/// <summary>
/// 添加分组
/// </summary>
private void AddGroup()
{
ConnGroupModel group = new ConnGroupModel();
group.GroupID = Guid.NewGuid();
group.Name = "新建分组";
this.Groups.Add(group);
}
#endregion
#region DeleteGroupCommand -- 删除分组命令
/// <summary>
/// 删除分组
/// </summary>
public VCommand DeleteGroupCommand { get; set; }
/// <summary>
/// 删除分组
/// </summary>
private void DeleteGroup()
{
if (this.SelectedGroup == null)
return;
this.Groups.Remove(this.SelectedGroup);
}
#endregion
#region EnabledGroupCommand -- 启用组命令
/// <summary>
/// 启用组命令
/// </summary>
public VCommand EnabledGroupCommand { get; set; }
/// <summary>
/// 启用组
/// </summary>
private void EnabledGroup()
{
if (this.SelectedGroup == null)
return;
foreach (var group in this.Groups)
{
group.IsEnabled = group == this.SelectedGroup;
}
}
#endregion
#region AddItemCommand -- 添加项命令
/// <summary>
/// 添加项命令
/// </summary>
public VCommand AddItemCommand { get; set; }
/// <summary>
/// 添加项
/// </summary>
private void AddItem()
{
if (this.SelectedGroup == null)
return;
ConnModel item = new ConnModel();
item.ConnID = Guid.NewGuid();
item.GroupID = this.SelectedGroup.GroupID;
item.IP = "127.0.0.1";
item.Port = 6100;
this.SelectedGroup.Items.Add(item);
}
#endregion
#region DeleteItemCommand -- 删除项命令
/// <summary>
/// 删除项命令
/// </summary>
public VCommand DeleteItemCommand { get; set; }
/// <summary>
/// 删除项
/// </summary>
private void DeleteItem()
{
if (this.SelectedItem == null || this.SelectedGroup == null)
return;
this.SelectedGroup.Items.Remove(this.SelectedItem);
}
#endregion
// ======================================================================================
// Public Function
// ======================================================================================
/// <summary>
/// 保存
/// </summary>
public void Save()
{
// 保存配置
this.connService.SaveGroups(this.Groups);
ConnGroupModel oldGroup = ApplicationDomainEx.ConnGroups.FirstOrDefault(p => p.IsEnabled);
ConnGroupModel newGroup = this.Groups.FirstOrDefault(p => p.IsEnabled);
ApplicationDomainEx.ConnGroups = this.Groups.ToList();
// 发送连接改变消息
ConnChangedMessage msg = new ConnChangedMessage();
msg.OldGroup = oldGroup;
msg.NewGroup = newGroup;
ApplicationDomainEx.MessageManager.Send(msg);
}
}
}
<dx:ThemedWindow x:Class="VIZ.Package.Module.SettingWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:fcommon="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common"
xmlns:domain="clr-namespace:VIZ.Package.Domain;assembly=VIZ.Package.Domain"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VIZ.Package.Module"
d:DataContext="{d:DesignInstance Type=local:SettingWindowModel}"
mc:Ignorable="d" WindowStartupLocation="CenterScreen"
Title="设置" Height="800" Width="1400">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="Loaded" Command="{Binding Path=LoadedCommand}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
</Grid.RowDefinitions>
<!-- 设置项 -->
<GroupBox Header="设置" Margin="10" Padding="10">
<ListBox ItemsSource="{Binding Path=ItemsSource}" Margin="0,0,6,0" Background="Transparent"
SelectedValue="{Binding Path=SelectedValue,Mode=TwoWay}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="30" Margin="5" Background="Transparent">
<TextBlock Text="{Binding Path=Name}" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</GroupBox>
<!-- 设置页面 -->
<fcommon:NavigationControl Grid.Column="1" ItemsSource="{Binding Path=ItemsSource}"
SelectedValue="{Binding Path=SelectedValue}"></fcommon:NavigationControl>
<!-- 按钮组 -->
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right"
Margin="0,0,20,0">
<Button Content="保存" Width="120" Height="30" Command="{Binding Path=SaveCommand}"></Button>
<Button Content="取消" Width="120" Height="30" Command="{Binding Path=CancelCommand}" Margin="20,0,0,0"></Button>
</StackPanel>
</Grid>
</dx:ThemedWindow>
using DevExpress.Xpf.Core;
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 VIZ.Framework.Core;
namespace VIZ.Package.Module
{
/// <summary>
/// Interaction logic for SettingWindow.xaml
/// </summary>
public partial class SettingWindow : ThemedWindow
{
public SettingWindow()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new SettingWindowModel());
}
}
}
using DevExpress.Xpf.Core;
using log4net;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using VIZ.Framework.Common;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
using VIZ.Package.Plugin;
using VIZ.Package.Service;
namespace VIZ.Package.Module
{
/// <summary>
/// 设置窗口模型
/// </summary>
public class SettingWindowModel : ViewModelBase
{
/// <summary>
/// 日志
/// </summary>
private readonly static ILog log = LogManager.GetLogger(typeof(SettingWindowModel));
public SettingWindowModel()
{
// 初始化命令
this.InitCommand();
}
/// <summary>
/// 初始化命令
/// </summary>
private void InitCommand()
{
this.LoadedCommand = new VCommand(this.Loaded);
this.SaveCommand = new VCommand(this.Save);
this.CancelCommand = new VCommand(this.Cancel);
}
// ==========================================================================
// Property
// ==========================================================================
#region ItemsSource -- 数据源
private ObservableCollection<SettingPageModel> itemsSource = new ObservableCollection<SettingPageModel>();
/// <summary>
/// 数据源
/// </summary>
public ObservableCollection<SettingPageModel> ItemsSource
{
get { return itemsSource; }
set { itemsSource = value; this.RaisePropertyChanged(nameof(ItemsSource)); }
}
#endregion
#region SelectedValue -- 当前选中的设置项
private SettingPageModel selectedValue;
/// <summary>
/// 当前选中的设置项
/// </summary>
public SettingPageModel SelectedValue
{
get { return selectedValue; }
set { selectedValue = value; this.RaisePropertyChanged(nameof(SelectedValue)); }
}
#endregion
// ==========================================================================
// Command
// ==========================================================================
#region LoadedCommand -- 加载命令
/// <summary>
/// 加载命令
/// </summary>
public VCommand LoadedCommand { get; set; }
/// <summary>
/// 加载
/// </summary>
private void Loaded()
{
if (this.IsAlreadyLoaded)
return;
this.IsAlreadyLoaded = true;
var modules = ApplicationDomainEx.PluginInfos.Where(p => p.PluginType == PluginType.Module && p.SettingViewType != null);
var templates = ApplicationDomainEx.PluginInfos.Where(p => p.PluginType == PluginType.Page && p.SettingViewType != null);
foreach (var item in modules)
{
SettingPageModel config = new SettingPageModel();
config.Name = item.Name;
config.ViewType = item.SettingViewType;
this.ItemsSource.Add(config);
}
foreach (var item in templates)
{
SettingPageModel config = new SettingPageModel();
config.Name = item.Name;
config.ViewType = item.SettingViewType;
this.ItemsSource.Add(config);
}
this.SelectedValue = this.ItemsSource.FirstOrDefault();
}
#endregion
#region SaveCommand -- 保存命令
/// <summary>
/// 保存命令
/// </summary>
public VCommand SaveCommand { get; set; }
/// <summary>
/// 保存
/// </summary>
private void Save()
{
if (this.SelectedValue == null || this.SelectedValue.View == null)
return;
if (!this.SelectedValue.View.TryGetTarget(out object target))
return;
if (!(target is IPluginSettingView view))
return;
try
{
view.Save();
DXMessageBox.Show("保存成功!");
}
catch (Exception ex)
{
log.Error(ex);
DXMessageBox.Show("保存失败!");
}
}
#endregion
#region CancelCommand -- 取消命令
/// <summary>
/// 取消命令
/// </summary>
public VCommand CancelCommand { get; set; }
/// <summary>
/// 取消
/// </summary>
private void Cancel()
{
Window window = this.GetWindow();
window?.Close();
}
#endregion
}
}
<UserControl x:Class="VIZ.Package.Module.VizConfigSettingView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:local="clr-namespace:VIZ.Package.Module"
d:DataContext="{d:DesignInstance Type=local:VizConfigSettingViewModel}"
d:Background="White"
mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="800">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="Loaded" Command="{Binding Path=LoadedCommand}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<!-- GH 设置 -->
<GroupBox Header="GH设置" Margin="10" Padding="10">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
</Grid.RowDefinitions>
<!-- IP地址 -->
<TextBlock Text="IP地址:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"></TextBlock>
<dxe:TextEdit Grid.Column="1" Height="30"
EditValue="{Binding Path=GH_IP,Mode=TwoWay}"></dxe:TextEdit>
<!-- 端口 -->
<TextBlock Text="端口:" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"></TextBlock>
<dxe:TextEdit Grid.Row="1" Grid.Column="1" Height="30" MaskType="RegEx"
Mask="[0-9]{0,7}"
EditValue="{Binding Path=GH_Port,Mode=TwoWay}"></dxe:TextEdit>
<!-- 服务名 -->
<TextBlock Text="服务名:" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"></TextBlock>
<dxe:TextEdit Grid.Row="2" Grid.Column="1" Height="30"
EditValue="{Binding Path=GH_ServerName,Mode=TwoWay}"></dxe:TextEdit>
<!-- 用户名 -->
<TextBlock Text="用户名:" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"></TextBlock>
<dxe:TextEdit Grid.Row="3" Grid.Column="1" Height="30"
EditValue="{Binding Path=GH_UserName,Mode=TwoWay}"></dxe:TextEdit>
<!-- 密码 -->
<TextBlock Text="密码:" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"></TextBlock>
<dxe:TextEdit Grid.Row="4" Grid.Column="1" Height="30"
EditValue="{Binding Path=GH_Password,Mode=TwoWay}"></dxe:TextEdit>
</Grid>
</GroupBox>
<!-- 本机VIZ设置 -->
<GroupBox Header="VIZ设置" Grid.Row="1" Margin="10" Padding="10">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
</Grid.RowDefinitions>
<!-- IP地址 -->
<TextBlock Text="IP地址:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"></TextBlock>
<dxe:TextEdit Grid.Column="1" Height="30"
EditValue="{Binding Path=VIZ_IP,Mode=TwoWay}"></dxe:TextEdit>
<!-- 端口 -->
<TextBlock Text="端口:" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"></TextBlock>
<dxe:TextEdit Grid.Row="1" Grid.Column="1" Height="30" MaskType="RegEx"
Mask="[0-9]{0,7}"
EditValue="{Binding Path=VIZ_Port,Mode=TwoWay}"></dxe:TextEdit>
<!-- 用户名 -->
<TextBlock Text="用户名:" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"></TextBlock>
<dxe:TextEdit Grid.Row="2" Grid.Column="1" Height="30"
EditValue="{Binding Path=VIZ_UserName,Mode=TwoWay}"></dxe:TextEdit>
<!-- 密码 -->
<TextBlock Text="密码:" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"></TextBlock>
<dxe:TextEdit Grid.Row="3" Grid.Column="1" Height="30"
EditValue="{Binding Path=VIZ_Password,Mode=TwoWay}"></dxe:TextEdit>
<!-- 本机Eng3路径 -->
<TextBlock Text="本机Eng3路径:" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"></TextBlock>
<Grid Grid.Row="4" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
</Grid.ColumnDefinitions>
<dxe:TextEdit Height="30"
EditValue="{Binding Path=VIZ_Eng3Path,Mode=TwoWay}"></dxe:TextEdit>
<Button Grid.Column="1" HorizontalAlignment="Right" Height="30" Width="80"
Content="..." Command="{Binding Path=SelectEng3PathCommand}"></Button>
</Grid>
<!-- 本机Eng4路径 -->
<TextBlock Text="本机Eng4路径:" Grid.Row="5" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"></TextBlock>
<Grid Grid.Row="5" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
</Grid.ColumnDefinitions>
<dxe:TextEdit Height="30"
EditValue="{Binding Path=VIZ_Eng4Path,Mode=TwoWay}"></dxe:TextEdit>
<Button Grid.Column="1" HorizontalAlignment="Right" Height="30" Width="80"
Content="..." Command="{Binding SelectEng4PathCommand}"></Button>
</Grid>
</Grid>
</GroupBox>
</Grid>
</UserControl>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Navigation;
using System.Windows.Shapes;
using VIZ.Framework.Core;
using VIZ.Package.Plugin;
namespace VIZ.Package.Module
{
/// <summary>
/// VizConfigSettingView.xaml 的交互逻辑
/// </summary>
public partial class VizConfigSettingView : UserControl, IPluginSettingView
{
public VizConfigSettingView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new VizConfigSettingViewModel());
}
/// <summary>
/// 保存
/// </summary>
public void Save()
{
VizConfigSettingViewModel vm = this.DataContext as VizConfigSettingViewModel;
vm.Save();
}
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
using VIZ.Package.Storage;
namespace VIZ.Package.Module
{
/// <summary>
/// Viz配置设置视图模型
/// </summary>
public class VizConfigSettingViewModel : ViewModelBase
{
/// <summary>
/// 日志
/// </summary>
private readonly static ILog log = LogManager.GetLogger(typeof(VizConfigSettingViewModel));
/// <summary>
/// VIZ设置视图模型
/// </summary>
public VizConfigSettingViewModel()
{
// 初始化命令
this.InitCommand();
}
/// <summary>
/// 初始化命令
/// </summary>
private void InitCommand()
{
this.LoadedCommand = new VCommand(this.Loaded);
this.SelectEng3PathCommand = new VCommand(this.SelectEng3Path);
this.SelectEng4PathCommand = new VCommand(this.SelectEng4Path);
}
// =========================================================================
// Property
// =========================================================================
#region GH_IP -- GH IP
private string gh_ip;
/// <summary>
/// GH_IP
/// </summary>
public string GH_IP
{
get { return gh_ip; }
set { gh_ip = value; this.RaisePropertyChanged(nameof(GH_IP)); }
}
#endregion
#region GH_Port -- GH 端口
private int gh_port;
/// <summary>
/// GH 端口
/// </summary>
public int GH_Port
{
get { return gh_port; }
set { gh_port = value; this.RaisePropertyChanged(nameof(GH_Port)); }
}
#endregion
#region GH_ServerName -- GH 服务名
private string gh_serverName;
/// <summary>
/// GH 服务名
/// </summary>
public string GH_ServerName
{
get { return gh_serverName; }
set { gh_serverName = value; this.RaisePropertyChanged(nameof(GH_ServerName)); }
}
#endregion
#region GH_UserName -- GH 用户名
private string gh_userName;
/// <summary>
/// GH 用户名
/// </summary>
public string GH_UserName
{
get { return gh_userName; }
set { gh_userName = value; this.RaisePropertyChanged(nameof(GH_UserName)); }
}
#endregion
#region GH_Password -- GH 密码
private string gh_password;
/// <summary>
/// GH 密码
/// </summary>
public string GH_Password
{
get { return gh_password; }
set { gh_password = value; this.RaisePropertyChanged(nameof(GH_Password)); }
}
#endregion
// -----------------------------------
#region VIZ_IP -- VIZ IP
private string viz_ip;
/// <summary>
/// VIZ_IP
/// </summary>
public string VIZ_IP
{
get { return viz_ip; }
set { viz_ip = value; this.RaisePropertyChanged(nameof(VIZ_IP)); }
}
#endregion
#region VIZ_Port -- VIZ 端口
private int viz_port;
/// <summary>
/// VIZ 端口
/// </summary>
public int VIZ_Port
{
get { return viz_port; }
set { viz_port = value; this.RaisePropertyChanged(nameof(VIZ_Port)); }
}
#endregion
#region VIZ_UserName -- VIZ 用户名
private string viz_userName;
/// <summary>
/// VIZ 用户名
/// </summary>
public string VIZ_UserName
{
get { return viz_userName; }
set { viz_userName = value; this.RaisePropertyChanged(nameof(VIZ_UserName)); }
}
#endregion
#region VIZ_Password -- VIZ 密码
private string viz_password;
/// <summary>
/// VIZ 密码
/// </summary>
public string VIZ_Password
{
get { return viz_password; }
set { viz_password = value; this.RaisePropertyChanged(nameof(VIZ_Password)); }
}
#endregion
#region VIZ_Eng3Path -- VIZ 引擎3路径
private string viz_eng3path;
/// <summary>
/// VIZ 引擎3路径
/// </summary>
public string VIZ_Eng3Path
{
get { return viz_eng3path; }
set { viz_eng3path = value; this.RaisePropertyChanged(nameof(VIZ_Eng3Path)); }
}
#endregion
#region VIZ_Eng4Path -- VIZ 引擎4路径
private string viz_eng4path;
/// <summary>
/// VIZ 引擎4路径
/// </summary>
public string VIZ_Eng4Path
{
get { return viz_eng4path; }
set { viz_eng4path = value; this.RaisePropertyChanged(nameof(VIZ_Eng4Path)); }
}
#endregion
// =========================================================================
// Command
// =========================================================================
#region LoadedCommand -- 加载命令
/// <summary>
/// 加载命令
/// </summary>
public VCommand LoadedCommand { get; set; }
/// <summary>
/// 加载
/// </summary>
private void Loaded()
{
VizConfigEntity config = ApplicationDomainEx.LocalDbContext.VizConfig.FindAll().FirstOrDefault();
this.GH_IP = config.GH_IP;
this.GH_Port = config.GH_Port;
this.GH_ServerName = config.GH_ServerName;
this.GH_UserName = config.GH_UserName;
this.GH_Password = config.GH_Password;
this.VIZ_IP = config.VIZ_IP;
this.VIZ_Port = config.VIZ_Port;
this.VIZ_UserName = config.VIZ_UserName;
this.VIZ_Password = config.VIZ_Password;
this.VIZ_Eng3Path = config.VIZ_Eng3Path;
this.VIZ_Eng4Path = config.VIZ_Eng4Path;
}
#endregion
#region SelectEng3PathCommand -- 选择引擎3路径命令
/// <summary>
/// 选择引擎3路径命令
/// </summary>
public VCommand SelectEng3PathCommand { get; set; }
/// <summary>
/// 选择引擎3路径
/// </summary>
private void SelectEng3Path()
{
System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
ofd.Multiselect = false;
ofd.Filter = "应用程序|*.exe";
if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
return;
this.VIZ_Eng3Path = ofd.FileName;
}
#endregion
#region SelectEng4PathCommand -- 选择引擎4路径命令
/// <summary>
/// 选择引擎4路径命令
/// </summary>
public VCommand SelectEng4PathCommand { get; set; }
/// <summary>
/// 选择引擎4
/// </summary>
private void SelectEng4Path()
{
System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
ofd.Multiselect = false;
ofd.Filter = "应用程序|*.exe";
if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
return;
this.VIZ_Eng4Path = ofd.FileName;
}
#endregion
// =========================================================================
// Public Function
// =========================================================================
/// <summary>
/// 保存
/// </summary>
public void Save()
{
VizConfigEntity config = ApplicationDomainEx.LocalDbContext.VizConfig.FindAll().FirstOrDefault();
config.GH_IP = this.GH_IP;
config.GH_Port = this.GH_Port;
config.GH_ServerName = this.GH_ServerName;
config.GH_UserName = this.GH_UserName;
config.GH_Password = this.GH_Password;
config.VIZ_IP = this.VIZ_IP;
config.VIZ_Port = this.VIZ_Port;
config.VIZ_UserName = this.VIZ_UserName;
config.VIZ_Password = this.VIZ_Password;
config.VIZ_Eng3Path = this.VIZ_Eng3Path;
config.VIZ_Eng4Path = this.VIZ_Eng4Path;
ApplicationDomainEx.LocalDbContext.VizConfig.Update(config);
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Package.Domain;
using VIZ.Package.Plugin;
namespace VIZ.Package.Module
{
/// <summary>
/// Viz配置插件生命周期
/// </summary>
public class VizConfigPluginLifeCycle : IPluginLifeCycle
{
/// <summary>
/// 插件ID
/// </summary>
/// <remarks>
/// 插件ID不能包含点号
/// </remarks>
public const string PLUGIN_ID = ModulePluginIds.VIZ_CONFIG_SETTING;
/// <summary>
/// 插件名称
/// </summary>
public const string PLUGIN_NAME = "Viz设置";
/// <summary>
/// 注册
/// </summary>
/// <returns>插件信息</returns>
public PluginInfo Register()
{
PluginInfo info = new PluginInfo();
info.ID = PLUGIN_ID;
info.Name = PLUGIN_NAME;
info.SettingViewType = typeof(VizConfigSettingView);
return info;
}
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
}
}
}
...@@ -87,6 +87,19 @@ ...@@ -87,6 +87,19 @@
<Reference Include="WindowsFormsIntegration" /> <Reference Include="WindowsFormsIntegration" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Main\ViewModel\MainConnViewModel.cs" />
<Compile Include="Main\View\MainConnView.xaml.cs">
<DependentUpon>MainConnView.xaml</DependentUpon>
</Compile>
<Compile Include="Main\ViewModel\MainStatusViewModel.cs" />
<Compile Include="Main\View\MainStatusView.xaml.cs">
<DependentUpon>MainStatusView.xaml</DependentUpon>
</Compile>
<Compile Include="Setting\Conn\View\ConnSettingView.xaml.cs">
<DependentUpon>ConnSettingView.xaml</DependentUpon>
</Compile>
<Compile Include="Setting\Conn\ConnPluginLifeCycle.cs" />
<Compile Include="Setting\Conn\ViewModel\ConnSettingViewModel.cs" />
<Compile Include="ControlObject\Command\CommandPluginLifeCycle.cs" /> <Compile Include="ControlObject\Command\CommandPluginLifeCycle.cs" />
<Compile Include="ControlObject\Command\ViewModel\CommandViewModel.cs" /> <Compile Include="ControlObject\Command\ViewModel\CommandViewModel.cs" />
<Compile Include="ControlObject\Command\View\CommandView.xaml.cs"> <Compile Include="ControlObject\Command\View\CommandView.xaml.cs">
...@@ -247,6 +260,12 @@ ...@@ -247,6 +260,12 @@
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<Compile Include="Setting\Core\ViewModel\SettingWindowModel.cs" />
<Compile Include="Setting\Core\View\SettingWindow.xaml.cs">
<DependentUpon>SettingWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Setting\VizConfig\VizConfigPluginLifeCycle.cs" />
<Compile Include="Setting\VizConfig\ViewModel\VizConfigSettingViewModel.cs" />
<Compile Include="Setup\AppSetup_InitLiteDB.cs" /> <Compile Include="Setup\AppSetup_InitLiteDB.cs" />
<Compile Include="Preview\VizPreview\Controller\VizPreviewController.cs" /> <Compile Include="Preview\VizPreview\Controller\VizPreviewController.cs" />
<Compile Include="Preview\VizPreview\VizPreviewPluginLifeCycle.cs" /> <Compile Include="Preview\VizPreview\VizPreviewPluginLifeCycle.cs" />
...@@ -260,6 +279,9 @@ ...@@ -260,6 +279,9 @@
<Compile Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\TextListCellEdit.xaml.cs"> <Compile Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\TextListCellEdit.xaml.cs">
<DependentUpon>TextListCellEdit.xaml</DependentUpon> <DependentUpon>TextListCellEdit.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Setting\VizConfig\View\VizConfigSettingView.xaml.cs">
<DependentUpon>VizConfigSettingView.xaml</DependentUpon>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
...@@ -275,6 +297,18 @@ ...@@ -275,6 +297,18 @@
<Folder Include="Main\Controller\" /> <Folder Include="Main\Controller\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Include="Main\View\MainConnView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Main\View\MainStatusView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Setting\Conn\View\ConnSettingView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ControlObject\Command\View\CommandView.xaml"> <Page Include="ControlObject\Command\View\CommandView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
...@@ -411,10 +445,18 @@ ...@@ -411,10 +445,18 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Setting\Core\View\SettingWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Generic.xaml"> <Page Include="Themes\Generic.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="Setting\VizConfig\View\VizConfigSettingView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\VIZ.Framework\VIZ.Framework.Common.Resource\VIZ.Framework.Common.Resource.csproj"> <ProjectReference Include="..\..\VIZ.Framework\VIZ.Framework.Common.Resource\VIZ.Framework.Common.Resource.csproj">
......
...@@ -18,11 +18,6 @@ namespace VIZ.Package.Plugin ...@@ -18,11 +18,6 @@ namespace VIZ.Package.Plugin
PluginInfo Register(); PluginInfo Register();
/// <summary> /// <summary>
/// 初始化
/// </summary>
void Initialize();
/// <summary>
/// 销毁 /// 销毁
/// </summary> /// </summary>
void Dispose(); void Dispose();
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Plugin
{
/// <summary>
/// 插件设置视图
/// </summary>
public interface IPluginSettingView
{
/// <summary>
/// 保存
/// </summary>
void Save();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Plugin
{
/// <summary>
/// 插件视图
/// </summary>
public interface IPluginView : IDisposable
{
}
}
...@@ -38,14 +38,14 @@ namespace VIZ.Package.Plugin ...@@ -38,14 +38,14 @@ namespace VIZ.Package.Plugin
public Type ViewType { get; set; } public Type ViewType { get; set; }
/// <summary> /// <summary>
/// 插件类型 /// 设置视图类型
/// </summary> /// </summary>
public PluginType PluginType { get; set; } public Type SettingViewType { get; set; }
/// <summary> /// <summary>
/// 引擎类型筛选器 /// 插件类型
/// </summary> /// </summary>
public List<EngineFullType> EngineFullTypesFilter { get; set; } public PluginType PluginType { get; set; }
/// <summary> /// <summary>
/// 生命周期 /// 生命周期
......
...@@ -19,6 +19,6 @@ namespace VIZ.Package.Plugin ...@@ -19,6 +19,6 @@ namespace VIZ.Package.Plugin
/// <summary> /// <summary>
/// 页插件 /// 页插件
/// </summary> /// </summary>
Pages Page
} }
} }
...@@ -82,6 +82,8 @@ ...@@ -82,6 +82,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Control\PluginLoader.cs" /> <Compile Include="Control\PluginLoader.cs" />
<Compile Include="Core\IPluginSettingView.cs" />
<Compile Include="Core\IPluginView.cs" />
<Compile Include="Core\PluginInfo.cs" /> <Compile Include="Core\PluginInfo.cs" />
<Compile Include="Core\IPluginLifeCycle.cs" /> <Compile Include="Core\IPluginLifeCycle.cs" />
<Compile Include="Core\PluginType.cs" /> <Compile Include="Core\PluginType.cs" />
......
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
using VIZ.Package.Storage;
namespace VIZ.Package.Service
{
/// <summary>
/// 连接服务
/// </summary>
public class ConnService
{
/// <summary>
/// 加载包装连接分组
/// </summary>
/// <returns>包装连接分组</returns>
public List<ConnGroupModel> LoadGroups()
{
List<ConnGroupModel> groups = new List<ConnGroupModel>();
foreach (ConnGroupEntity entity in ApplicationDomainEx.LocalDbContext.ConnGroup.FindAll())
{
ConnGroupModel model = new ConnGroupModel();
model.GroupID = entity.GroupID;
model.IsEnabled = entity.IsEnabled;
model.Name = entity.Name;
model.EngineType = entity.EngineType;
groups.Add(model);
}
Dictionary<Guid, ConnGroupModel> dic = groups.ToDictionary(p => p.GroupID, p => p);
foreach (ConnEntity entity in ApplicationDomainEx.LocalDbContext.Conn.FindAll())
{
if (!dic.TryGetValue(entity.GroupID, out ConnGroupModel group))
continue;
ConnModel model = new ConnModel();
model.ConnID = entity.ConnID;
model.GroupID = entity.GroupID;
model.IP = entity.IP;
model.Port = entity.Port;
model.Remark = entity.Remark;
model.IsEnabled = entity.IsEnabled;
group.Items.Add(model);
}
return groups;
}
/// <summary>
/// 保存包装连接分组集合
/// </summary>
/// <param name="groups">分组集合</param>
public void SaveGroups(IList<ConnGroupModel> groups)
{
List<ConnGroupEntity> groupList = new List<ConnGroupEntity>();
List<ConnEntity> itemList = new List<ConnEntity>();
foreach (ConnGroupModel group in groups)
{
ConnGroupEntity groupEntity = new ConnGroupEntity();
groupEntity.GroupID = group.GroupID;
groupEntity.IsEnabled = group.IsEnabled;
groupEntity.Name = group.Name;
groupEntity.EngineType = group.EngineType;
groupList.Add(groupEntity);
foreach (ConnModel item in group.Items)
{
ConnEntity itemEntity = new ConnEntity();
itemEntity.ConnID = item.ConnID;
itemEntity.GroupID = item.GroupID;
itemEntity.IP = item.IP;
itemEntity.Port = item.Port;
itemEntity.Remark = item.Remark;
itemEntity.IsEnabled = item.IsEnabled;
itemList.Add(itemEntity);
}
}
ApplicationDomainEx.LocalDbContext.ConnGroup.DeleteAll();
ApplicationDomainEx.LocalDbContext.Conn.DeleteAll();
ApplicationDomainEx.LocalDbContext.ConnGroup.Insert(groupList);
ApplicationDomainEx.LocalDbContext.Conn.Insert(itemList);
}
}
}
...@@ -23,7 +23,7 @@ namespace VIZ.Package.Service ...@@ -23,7 +23,7 @@ namespace VIZ.Package.Service
/// <summary> /// <summary>
/// 包装插件前缀 /// 包装插件前缀
/// </summary> /// </summary>
public const string PLUGIN_ASSEMBLY_PREFIX = "VIZ.Package."; public const string PLUGIN_ASSEMBLY_PREFIX = "VIZ.";
/// <summary> /// <summary>
/// 加载插件信息集合 /// 加载插件信息集合
......
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="DB\Conn\ConnService.cs" />
<Compile Include="DB\Page\PageService.cs" /> <Compile Include="DB\Page\PageService.cs" />
<Compile Include="Logic\Plugin\PluginService.cs" /> <Compile Include="Logic\Plugin\PluginService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
......
...@@ -44,11 +44,6 @@ namespace VIZ.Package.Storage ...@@ -44,11 +44,6 @@ namespace VIZ.Package.Storage
public string Remark { get; set; } public string Remark { get; set; }
/// <summary> /// <summary>
/// 引擎类型
/// </summary>
public EngineType EngineType { get; set; }
/// <summary>
/// 是否启用 /// 是否启用
/// </summary> /// </summary>
public bool IsEnabled { get; set; } public bool IsEnabled { get; set; }
......
...@@ -29,6 +29,11 @@ namespace VIZ.Package.Storage ...@@ -29,6 +29,11 @@ namespace VIZ.Package.Storage
public string Name { get; set; } public string Name { get; set; }
/// <summary> /// <summary>
/// 引擎类型
/// </summary>
public EngineType EngineType { get; set; }
/// <summary>
/// 是否启用 /// 是否启用
/// </summary> /// </summary>
public bool IsEnabled { get; set; } public bool IsEnabled { get; set; }
......
...@@ -13,9 +13,9 @@ namespace VIZ.Package.Storage ...@@ -13,9 +13,9 @@ namespace VIZ.Package.Storage
public enum EngineType public enum EngineType
{ {
/// <summary> /// <summary>
/// VIZ /// Viz
/// </summary> /// </summary>
[Description("VIZ引擎")] [Description("Viz引擎")]
VIZ Viz
} }
} }
...@@ -9,6 +9,17 @@ ...@@ -9,6 +9,17 @@
<!-- 主视图顶部 --> <!-- 主视图顶部 -->
<module:MainTopView></module:MainTopView> <module:MainTopView></module:MainTopView>
</dx:ThemedWindow.ToolbarItems> </dx:ThemedWindow.ToolbarItems>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="35"></RowDefinition>
<RowDefinition Height="35"></RowDefinition>
</Grid.RowDefinitions>
<!-- 主视图 --> <!-- 主视图 -->
<module:MainView></module:MainView> <module:MainView></module:MainView>
<!-- 状态视图 -->
<module:MainStatusView Grid.Row="1"></module:MainStatusView>
<!-- 连接视图 -->
<module:MainConnView Grid.Row="2"></module:MainConnView>
</Grid>
</dx:ThemedWindow> </dx:ThemedWindow>
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