Commit 60ee21fa by liulongfei

1. 场景多选

2. 退出程序时询问是否保存项目
parent 0a7cf5aa
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Domain
{
/// <summary>
/// 资源文件选择模式
/// </summary>
public enum ResourceFileSelectionMode
{
/// <summary>
/// 单选
/// </summary>
Single,
/// <summary>
/// 多选
/// </summary>
Multiple
}
}
......@@ -117,6 +117,20 @@ namespace VIZ.Package.Domain
#endregion
#region IsChecked -- 是否被选中
private bool isChecked;
/// <summary>
/// 是否被选中
/// </summary>
public bool IsChecked
{
get { return isChecked; }
set { isChecked = value; this.RaisePropertyChanged(nameof(IsChecked)); }
}
#endregion
// ---------------------------------------------------------------------
// 方法
......
......@@ -34,7 +34,7 @@ namespace VIZ.Package.Domain
#region Files -- 文件集合
private ObservableCollection<GHResourceFileModel> files;
private ObservableCollection<GHResourceFileModel> files = new ObservableCollection<GHResourceFileModel>();
/// <summary>
/// 文件集合
/// </summary>
......
......@@ -96,6 +96,7 @@
<Compile Include="Model\Page\PageModel.cs" />
<Compile Include="Model\Page\PageModelBase.cs" />
<Compile Include="Model\Page\PageTemplateModel.cs" />
<Compile Include="Model\Resource\Enum\ResourceFileSelectionMode.cs" />
<Compile Include="Model\Resource\Enum\ResourceFileType.cs" />
<Compile Include="Model\Resource\Enum\ResourceFolderType.cs" />
<Compile Include="Model\Resource\GH\GHResourceFileModel.cs" />
......
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using VIZ.Package.Domain;
namespace VIZ.Package.Module.Resource
{
/// <summary>
/// 资源文件选择模式转化器
/// </summary>
public class ResourceFileSelectionModeConverter : IValueConverter
{
/// <summary>
/// 单选模式数据模板
/// </summary>
public DataTemplate SingleDataTemplate { get; set; }
/// <summary>
/// 多选模式数据模板
/// </summary>
public DataTemplate MultipleDataTemplate { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is ResourceFileSelectionMode mode))
return null;
switch (mode)
{
case ResourceFileSelectionMode.Single: return this.SingleDataTemplate;
case ResourceFileSelectionMode.Multiple: return this.MultipleDataTemplate;
default: return null;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- CheckBox_Resource -->
<Style x:Key="CheckBox_Resource" TargetType="CheckBox">
<Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CheckBox">
<Grid Background="Transparent">
<Image x:Name="img_hover" Width="36" Height="36" Visibility="Collapsed"
VerticalAlignment="Top" HorizontalAlignment="Right"
Source="/VIZ.Package.Module.Resource;component/Icons/checked_36x36.png"></Image>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="img_hover" Property="Visibility" Value="Visible"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
\ No newline at end of file
......@@ -77,6 +77,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Style\CheckBox\CheckBox_Resource.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Style\CheckBox\CheckBox_Preview.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......@@ -95,6 +99,7 @@
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Converter\ResourceFileSelectionModeConverter.cs" />
<Compile Include="Converter\RichText2TextConverter.cs" />
<Compile Include="Converter\RowHandleConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
......@@ -145,6 +150,14 @@
<Project>{75b39591-4bc3-4b09-bd7d-ec9f67efa96e}</Project>
<Name>VIZ.Framework.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\VIZ.Framework\VIZ.Framework.Domain\VIZ.Framework.Domain.csproj">
<Project>{28661e82-c86a-4611-a028-c34f6ac85c97}</Project>
<Name>VIZ.Framework.Domain</Name>
</ProjectReference>
<ProjectReference Include="..\VIZ.Package.Domain\VIZ.Package.Domain.csproj">
<Project>{dbaeae47-1f2d-4b05-82c3-abf7cc33aa2d}</Project>
<Name>VIZ.Package.Domain</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\bb_36x36.png" />
......@@ -166,5 +179,8 @@
<Resource Include="Icons\ta_36x36.png" />
<Resource Include="Icons\ta_hover_36x36.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\checked_36x36.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
......@@ -6,6 +6,7 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
......@@ -51,6 +52,7 @@ namespace VIZ.Package.Module
private void InitMessage()
{
ApplicationDomainEx.MessageManager.Register<VizPreviewReadyMessage>(this, this.OnVizPreviewReadyMessage);
ApplicationDomainEx.MessageManager.Register<ApplicationCloseMessage>(this, this.OnApplicationCloseMessage);
}
// =====================================================================
......@@ -358,6 +360,21 @@ namespace VIZ.Package.Module
this.IsVizPreviewReady = true;
}
/// <summary>
/// 应用程序关闭消息
/// </summary>
/// <param name="msg">消息</param>
private void OnApplicationCloseMessage(ApplicationCloseMessage msg)
{
if (ApplicationDomainEx.ProjectDbContext == null)
return;
if (DXMessageBox.Show("是否保存项目?", "提示", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
return;
this.SaveProject();
}
// =====================================================================
// Public Function
// =====================================================================
......
......@@ -500,9 +500,6 @@ namespace VIZ.Package.Module
if (ApplicationDomainEx.VizPreviewProcess == null || ApplicationDomainEx.VizPreviewProcess.HasExited)
return;
if (DXMessageBox.Show("是否关闭Viz引擎?", "提示", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
return;
try
{
ApplicationDomainEx.VizPreviewProcess.Kill();
......
......@@ -61,6 +61,12 @@ namespace VIZ.Package.Module
return;
}
// 清除选择
foreach (GHResourceFileModel file in folder.Files)
{
file.IsChecked = false;
}
// 已经获取过文件
if (folder.IsRefreshedFiles)
{
......
......@@ -12,6 +12,7 @@
xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:local="clr-namespace:VIZ.Package.Module"
xmlns:domain="clr-namespace:VIZ.Package.Domain;assembly=VIZ.Package.Domain"
xmlns:resource="clr-namespace:VIZ.Package.Module.Resource;assembly=VIZ.Package.Module.Resource"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=local:GHResourcePanelModel}"
d:DesignHeight="450" d:DesignWidth="800">
......@@ -20,8 +21,41 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/VIZ.Package.Module.Resource;component/DevExpreess/GridControl/GridControl_Files.xaml"></ResourceDictionary>
<ResourceDictionary Source="/VIZ.Framework.Common.Resource;component/Style/GridSplitter/GridSplitter_None.xaml"></ResourceDictionary>
<ResourceDictionary Source="/VIZ.Package.Module.Resource;component/Style/CheckBox/CheckBox_Resource.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<fcore:Bitmap2ImageSourceConverter x:Key="Bitmap2ImageSourceConverter"></fcore:Bitmap2ImageSourceConverter>
<resource:ResourceFileSelectionModeConverter x:Key="ResourceFileSelectionModeConverter">
<!-- 单选 -->
<resource:ResourceFileSelectionModeConverter.SingleDataTemplate>
<DataTemplate>
<Grid Width="120" ClipToBounds="False" UseLayoutRounding="True" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="70" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Image Source="{Binding Path=Row.ThumbnailBitmap,Converter={StaticResource Bitmap2ImageSourceConverter}}"></Image>
<TextBlock Grid.Row="1" TextAlignment="Center" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" HorizontalAlignment="Center"
Text="{Binding Path=Row.Name}" ToolTip="{Binding Path=Row.Name}" Margin="0,5,0,0"/>
</Grid>
</DataTemplate>
</resource:ResourceFileSelectionModeConverter.SingleDataTemplate>
<!-- 多选 -->
<resource:ResourceFileSelectionModeConverter.MultipleDataTemplate>
<DataTemplate>
<Grid Width="120" ClipToBounds="False" UseLayoutRounding="True" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="70" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Image Source="{Binding Path=Row.ThumbnailBitmap,Converter={StaticResource Bitmap2ImageSourceConverter}}"></Image>
<TextBlock Grid.Row="1" TextAlignment="Center" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" HorizontalAlignment="Center"
Text="{Binding Path=Row.Name}" ToolTip="{Binding Path=Row.Name}" Margin="0,5,0,0"/>
<CheckBox Style="{StaticResource ResourceKey=CheckBox_Resource}" Grid.RowSpan="2"
IsChecked="{Binding Path=Row.IsChecked,Mode=TwoWay}"></CheckBox>
</Grid>
</DataTemplate>
</resource:ResourceFileSelectionModeConverter.MultipleDataTemplate>
</resource:ResourceFileSelectionModeConverter>
</ResourceDictionary>
</UserControl.Resources>
......@@ -38,7 +72,8 @@
<dxg:TreeViewControl ItemsSource="{Binding Path=FolderModels}" Margin="0,0,10,0"
SelectedItem="{Binding Path=SelectedFolderModel,Mode=TwoWay}"
ContextMenu="{Binding Path=FolderContextMenu,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:GHResourcePanel}}}"
SelectionMode="Row" ShowNodeImages="True" ShowSearchPanel="False"
SelectionMode="Row"
ShowNodeImages="True" ShowSearchPanel="False"
ExpandStateFieldName="IsExpand"
AllowEditing="False" TreeViewFieldName="Name" ChildNodesPath="Children">
<dxmvvm:Interaction.Behaviors>
......@@ -56,26 +91,13 @@
<dxg:GridControl x:Name="fileGrid" Grid.Column="1" ShowBorder="False"
ContextMenu="{Binding Path=FileContextMenu,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:GHResourcePanel}}}"
SelectionMode="Row"
CustomRowFilterCommand="{Binding Path=FileRowFilterCommand}"
ItemsSource="{Binding Path=FileModels}"
SelectedItem="{Binding Path=SelectedFileModel,Mode=TwoWay}">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="MouseDoubleClick" Command="{Binding Path=FileDoubleClickCommand}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
<dxg:GridControl.Resources>
<!-- 定义Card模板 -->
<DataTemplate x:Key="CardTemplate">
<Grid Width="120" ClipToBounds="False" UseLayoutRounding="True" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="70" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Image Source="{Binding Path=Row.ThumbnailBitmap,Converter={StaticResource Bitmap2ImageSourceConverter}}"></Image>
<TextBlock Grid.Row="1" TextAlignment="Center" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" HorizontalAlignment="Center"
Text="{Binding Path=Row.Name}" ToolTip="{Binding Path=Row.Name}" Margin="0,5,0,0"/>
</Grid>
</DataTemplate>
</dxg:GridControl.Resources>
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="Name" AllowColumnFiltering="False" AllowEditing="False" ReadOnly="True"></dxg:GridColumn>
</dxg:GridControl.Columns>
......@@ -93,9 +115,7 @@
ShowSearchPanelMode="Never"
SearchColumns="Name"
NavigationStyle="Row"
CardTemplate="{StaticResource CardTemplate}"/>
CardTemplate="{Binding Path=FileSelectionMode,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:GHResourcePanel}},Converter={StaticResource ResourceFileSelectionModeConverter}}"/>
</dxg:GridControl.View>
</dxg:GridControl>
......
using System;
using DevExpress.Xpf.Grid;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
......@@ -13,6 +14,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
namespace VIZ.Package.Module
{
......@@ -63,5 +65,24 @@ namespace VIZ.Package.Module
DependencyProperty.Register("FileContextMenu", typeof(ContextMenu), typeof(GHResourcePanel), new PropertyMetadata(null));
#endregion
#region FileSelectionMode -- 文件选择模式
/// <summary>
/// 文件选择模式
/// </summary>
public ResourceFileSelectionMode FileSelectionMode
{
get { return (ResourceFileSelectionMode)GetValue(FileSelectionModeProperty); }
set { SetValue(FileSelectionModeProperty, value); }
}
/// <summary>
/// Using a DependencyProperty as the backing store for FileSelectionMode. This enables animation, styling, binding, etc...
/// </summary>
public static readonly DependencyProperty FileSelectionModeProperty =
DependencyProperty.Register("FileSelectionMode", typeof(ResourceFileSelectionMode), typeof(GHResourcePanel), new PropertyMetadata(ResourceFileSelectionMode.Single));
#endregion
}
}
......@@ -8,7 +8,7 @@
d:DesignHeight="450" d:DesignWidth="800">
<Grid Background="Transparent">
<!-- GH资源面板 -->
<local:GHResourcePanel>
<local:GHResourcePanel FileSelectionMode="Multiple">
<local:GHResourcePanel.FolderContextMenu>
<ContextMenu>
<MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFolderCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
......@@ -17,6 +17,7 @@
<local:GHResourcePanel.FileContextMenu>
<ContextMenu>
<MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="取消选择" Command="{Binding Path=PlacementTarget.DataContext.CancelFileSelectedCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<Separator/>
<MenuItem Header="添加场景模板" Command="{Binding Path=PlacementTarget.DataContext.AddSceneTemplateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
......
......@@ -27,6 +27,7 @@ namespace VIZ.Package.Module
private void InitCommand()
{
this.AddSceneTemplateCommand = new VCommand(this.AddSceneTemplate);
this.CancelFileSelectedCommand = new VCommand(this.CancelFileSelected);
}
// ===========================================================================
......@@ -45,14 +46,43 @@ namespace VIZ.Package.Module
/// </summary>
private void AddSceneTemplate()
{
if (this.SelectedFileModel == null)
if (this.SelectedFolderModel == null)
return;
IPageTemplateService service = ApplicationDomainEx.ServiceManager.GetService<IPageTemplateService>(ViewServiceKeys.PAGE_TEMPLATE_SERVICE);
if (service == null)
return;
service.AddSceneTemplate(this.SelectedFileModel);
foreach (GHResourceFileModel file in this.SelectedFolderModel.Files)
{
if (!file.IsChecked)
continue;
service.AddSceneTemplate(file);
}
}
#endregion
#region CancelFileSelectedCommand -- 取消文件选择命令
/// <summary>
/// 取消文件选择命令
/// </summary>
public VCommand CancelFileSelectedCommand { get; set; }
/// <summary>
/// 取消文件选择
/// </summary>
private void CancelFileSelected()
{
if (this.SelectedFolderModel == null)
return;
foreach (GHResourceFileModel file in this.SelectedFolderModel.Files)
{
file.IsChecked = false;
}
}
#endregion
......
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