Commit 759db348 by liulongfei

模板和场景多选模式

parent a6d01dbb
......@@ -36,11 +36,6 @@ namespace VIZ.Package.Domain
public static Type MainWindowType { get; set; }
/// <summary>
/// 主等待窗口
/// </summary>
public static Window MainLoadingWindow { get; set; }
/// <summary>
/// 字段编辑窗口
/// </summary>
public static Window FieldEditWindow { get; set; }
......
......@@ -12,8 +12,8 @@ namespace VIZ.Package.Domain
public class PageDeleteMessage
{
/// <summary>
///
/// 删除的页集合
/// </summary>
public PageModelBase Page { get; set; }
public List<PageModelBase> Pages { get; set; }
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
......@@ -68,5 +69,23 @@ namespace VIZ.Package.Domain
}
#endregion
// ===========================================================
// 扩展属性
// ===========================================================
#region SelectedPages -- 当前选中的页集合
private IList selectedPages;
/// <summary>
/// 当前选中的页集合
/// </summary>
public IList SelectedPages
{
get { return selectedPages; }
set { selectedPages = value; this.RaisePropertyChanged(nameof(SelectedPages)); }
}
#endregion
}
}
......@@ -198,14 +198,6 @@ namespace VIZ.Package.Module
public void SetIsEnabled(bool isEnabled)
{
this.IsEnabled = isEnabled;
if (ApplicationDomainEx.MainLoadingWindow == null)
{
ApplicationDomainEx.MainLoadingWindow = new MainLoadingWindow();
ApplicationDomainEx.MainLoadingWindow.Owner = ApplicationDomainEx.MainWindow;
}
ApplicationDomainEx.MainLoadingWindow.Visibility = isEnabled ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible;
}
// ============================================================
......
using DevExpress.XtraPrinting.Native;
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.Service;
namespace VIZ.Package.Module
{
/// <summary>
/// 页视图模型辅助类
/// </summary>
public class PageViewModelHelper
{
/// <summary>
/// 日志
/// </summary>
private readonly static ILog log = LogManager.GetLogger(typeof(PageViewModelHelper));
/// <summary>
/// GH服务
/// </summary>
private GHService ghService = new GHService();
/// <summary>
/// Viz控制对象下载服务
/// </summary>
private VizControlObjectDownloadService vizControlObjectDownloadService = new VizControlObjectDownloadService();
/// <summary>
/// 开始下载图片任务
/// </summary>
/// <param name="pages">页集合</param>
public void BeginDownLoadIamge(List<PageModelBase> pages)
{
ThreadHelper.SafeRun(() =>
{
foreach (PageModelBase page in pages)
{
if (page.ThumbnailBitmap != null)
continue;
if (string.IsNullOrWhiteSpace(page.ThumbnailUri))
continue;
var bitmap = this.ghService.GetImage(page.ThumbnailUri);
WPFHelper.BeginInvoke(() =>
{
page.ThumbnailBitmap = bitmap;
});
}
});
}
/// <summary>
/// 开始下载控制对象
/// </summary>
/// <param name="pages">页集合</param>
/// <param name="callback">下载完成回调</param>
public void BeginDownLoadControlObject(List<PageModelBase> pages, Action callback)
{
if (pages == null || pages.Count == 0)
return;
PageLoadingWindow window = new PageLoadingWindow();
window.Owner = ApplicationDomainEx.MainWindow;
Task.Run(() =>
{
IMainViewService service = ApplicationDomainEx.ServiceManager.GetService<IMainViewService>(ViewServiceKeys.MAIN_VIEW_SERVICE);
// 设置主窗口不可用
WPFHelper.Invoke(() =>
{
ApplicationDomainEx.IsSceneLoading = true;
service?.SetIsEnabled(false);
window?.Show();
});
// 下载页控制对象信息
try
{
this.vizControlObjectDownloadService.Load(pages);
}
catch (Exception ex)
{
log.Error(ex);
}
finally
{
// 恢复主窗口可用
WPFHelper.Invoke(() =>
{
ApplicationDomainEx.IsSceneLoading = false;
service?.SetIsEnabled(true);
window?.Close();
// 回调
callback?.Invoke();
});
}
});
}
}
}
<Window x:Class="VIZ.Package.Module.MainLoadingWindow"
<Window x:Class="VIZ.Package.Module.PageLoadingWindow"
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"
......
......@@ -16,21 +16,13 @@ using System.Windows.Shapes;
namespace VIZ.Package.Module
{
/// <summary>
/// Interaction logic for MainLoadingWindow.xaml
/// Interaction logic for PageLoadingWindow.xaml
/// </summary>
public partial class MainLoadingWindow : Window
public partial class PageLoadingWindow : Window
{
public MainLoadingWindow()
public PageLoadingWindow()
{
InitializeComponent();
this.Closing += MainLoadingWindow_Closing;
}
private void MainLoadingWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
this.Visibility = Visibility.Collapsed;
}
}
}
......@@ -39,6 +39,8 @@
<MenuItem Header="新建分组" Command="{Binding Path=PlacementTarget.DataContext.AddGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="重命名分组" Command="{Binding Path=PlacementTarget.DataContext.RenameGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<Separator></Separator>
<MenuItem Header="更新页" Command="{Binding Path=PlacementTarget.DataContext.UpdateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<Separator></Separator>
<MenuItem Header="删除分组" Command="{Binding Path=PlacementTarget.DataContext.DeleteGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="删除节目单项" Command="{Binding Path=PlacementTarget.DataContext.DeleteItemCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
......@@ -62,8 +64,8 @@
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<dxg:GridControl ItemsSource="{Binding Pages}" ShowBorder="False" IsFilterEnabled="False"
SelectedItem="{Binding ElementName=uc, Path=DataContext.SelectedPageModel,Mode=TwoWay}">
<dxg:GridControl ItemsSource="{Binding Path=Pages}" ShowBorder="False" IsFilterEnabled="False" SelectionMode="Row"
SelectedItems="{Binding Path=SelectedPages,Mode=OneWayToSource}">
<dxg:GridControl.Columns>
<dxg:GridColumn Header="编号" AllowSorting="False" AllowColumnFiltering="False" AllowResizing="True"
FieldName="PageNum">
......
......@@ -27,8 +27,8 @@
</UserControl.Resources>
<Grid IsEnabled="{Binding Path=IsEnabled}" Margin="0,10,0,10">
<dxg:GridControl ItemsSource="{Binding Path=SceneTemplateModels}" ShowBorder="False"
SelectedItem="{Binding Path=SelectedSceneTemplateModel,Mode=TwoWay}">
<dxg:GridControl ItemsSource="{Binding Path=SceneTemplateModels}" ShowBorder="False" SelectionMode="Row"
SelectedItems="{Binding Path=SelectedSceneTemplateModels,Mode=OneWayToSource}">
<dxg:GridControl.ContextMenu>
<ContextMenu>
<MenuItem Header="打开" Command="{Binding Path=PlacementTarget.DataContext.OpenScenePageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
......
......@@ -203,15 +203,18 @@ namespace VIZ.Package.Module
/// <param name="msg">消息</param>
private void OnPageDeleteMessage(PageDeleteMessage msg)
{
if (msg.Page == null)
if (msg.Pages == null || msg.Pages.Count == 0)
return;
PluginNavigationConfig config = this.ItemsSource.FirstOrDefault(p => p.PageModel == msg.Page);
foreach (PageModelBase page in msg.Pages)
{
PluginNavigationConfig config = this.ItemsSource.FirstOrDefault(p => p.PageModel == page);
if (config == null)
return;
this.ItemsSource.Remove(config);
}
}
/// <summary>
/// 页分组删除消息
......
......@@ -137,10 +137,10 @@ namespace VIZ.Package.Module
/// <param name="msg">消息</param>
private void OnPageDeleteMessage(PageDeleteMessage msg)
{
if (msg.Page == null)
if (msg.Pages == null || msg.Pages.Count == 0)
return;
var query = this.ItemsSource.Where(p => p.PageModel == msg.Page).ToList();
var query = this.ItemsSource.Where(p => msg.Pages.Contains(p.PageModel)).ToList();
foreach (PackageTaskModel task in query)
{
this.Cancel(task);
......
......@@ -118,8 +118,9 @@
<Compile Include="ControlObject\FieldEdit\ViewModel\FieldEditViewModelBase.cs" />
<Compile Include="ControlObject\FieldTree\Service\IFieldTreeService.cs" />
<Compile Include="Log\ViewModel\VizCommandWindowModel.cs" />
<Compile Include="Main\View\MainLoadingWindow.xaml.cs">
<DependentUpon>MainLoadingWindow.xaml</DependentUpon>
<Compile Include="Page\Core\Helper\PageViewModelHelper.cs" />
<Compile Include="Page\Core\View\PageLoadingWindow.xaml.cs">
<DependentUpon>PageLoadingWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Main\ViewModel\MainConnViewModel.cs" />
<Compile Include="Main\View\MainConnView.xaml.cs">
......@@ -402,7 +403,7 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Main\View\MainLoadingWindow.xaml">
<Page Include="Page\Core\View\PageLoadingWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
......
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