主题还得完善下

This commit is contained in:
kwai
2023-03-20 20:23:20 +08:00
parent 07ac28965e
commit 2c6b3cc285
3 changed files with 91 additions and 22 deletions

View File

@@ -19,12 +19,19 @@ using AIStudio.Wpf.DiagramDesigner.Additionals;
using AIStudio.Wpf.DiagramDesigner.Additionals.Commands;
using AIStudio.Wpf.DiagramDesigner.ViewModels;
using AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel;
using AIStudio.Wpf.Mind;
namespace AIStudio.Wpf.DiagramApp.ViewModels
{
public class MainWindowViewModel : BindableBase
{
private IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } }
private IDiagramServiceProvider _service
{
get
{
return DiagramServicesProvider.Instance.Provider;
}
}
private string _history = System.AppDomain.CurrentDomain.BaseDirectory + "history.json";
public MainWindowViewModel()
@@ -50,7 +57,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
#region
public ToolBoxViewModel ToolBoxViewModel { get; private set; }
public ToolBoxViewModel ToolBoxViewModel
{
get; private set;
}
private ObservableCollection<PageViewModel> _diagramsViewModels;
public ObservableCollection<PageViewModel> DiagramsViewModels
@@ -118,7 +128,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
}
public Color[] StandardColor { get; set; }
public Color[] StandardColor
{
get; set;
}
public IDrawModeViewModel DrawModeViewModel
{
@@ -222,8 +235,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
get
{
return
() =>
{
() => {
return new PageViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", DiagramType.Normal);
};
}
@@ -239,6 +251,15 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
}
private ICommand _newMindCommand;
public ICommand NewMindCommand
{
get
{
return this._newMindCommand ?? (this._newMindCommand = new DelegateCommand<string>(para => this.NewMind_Executed(para)));
}
}
private ICommand _openCommand;
public ICommand OpenCommand
{
@@ -650,7 +671,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
public ItemActionCallback ClosingTabItemHandler
{
get { return ClosingTabItemHandlerImpl; }
get
{
return ClosingTabItemHandlerImpl;
}
}
/// <summary>
@@ -723,11 +747,11 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
var para = e.KeyboardDevice.Modifiers == ModifierKeys.None ? e.Key.ToString() : e.KeyboardDevice.Modifiers.ToString() + "+" + e.Key.ToString();
bool executed = true;
switch (para)
switch (para)
{
case "Control+O": OpenExecuted(); break;
case "Control+N": New_Executed(); break;
case "Control+S": SaveExecuted(); break;
case "Control+S": SaveExecuted(); break;
default: executed = false; break;
}
@@ -746,7 +770,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
private void SelectedAllExecuted()
{
PageViewModel?.DiagramViewModel?.SelectAllCommand.Execute(null);
PageViewModel?.DiagramViewModel?.SelectAllCommand.Execute(null);
}
private void OpenExecuted(string para = null)
@@ -911,10 +935,6 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
{
PageViewModel = new SFCViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
}
else if (type == DiagramType.Mind.ToString())
{
PageViewModel = new MindViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
}
else
{
PageViewModel = new PageViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
@@ -923,6 +943,16 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
DiagramsViewModels.Add(PageViewModel);
}
private void NewMind_Executed(string mindtype = "Mind")
{
IsOpenBackstage = false;
PageViewModel = new MindViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", DiagramType.Mind, (MindType)Enum.Parse(typeof(MindType), mindtype));
DiagramsViewModels.Add(PageViewModel);
}
private void ExitExecuted()
{
throw new NotImplementedException();
@@ -948,11 +978,11 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
PageViewModel?.DiagramViewModel?.AlignVerticalCentersCommand.Execute(para);
}
private void AlignBottomExecuted(object para)
{
{
PageViewModel?.DiagramViewModel?.AlignBottomCommand.Execute(para);
}
private void AlignLeftExecuted(object para)
{
{
PageViewModel?.DiagramViewModel?.AlignLeftCommand.Execute(para);
}
private void AlignHorizontalCentersExecuted(object para)

View File

@@ -18,9 +18,9 @@ namespace AIStudio.Wpf.Flowchart
{
public class MindViewModel : PageViewModel
{
public MindViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
public MindViewModel(string title, string status, DiagramType diagramType, MindType mindType) : base(title, status, diagramType)
{
MindType = mindType;
}
public MindViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
{
@@ -28,6 +28,11 @@ namespace AIStudio.Wpf.Flowchart
{
vm.Init();
}
if (MindDiagramViewModel != null)
{
MindType = MindDiagramViewModel.MindType;
}
}
protected override void InitDiagramViewModel()
@@ -35,7 +40,7 @@ namespace AIStudio.Wpf.Flowchart
base.InitDiagramViewModel();
DiagramViewModel.GridCellSize = new Size(100, 100);
DiagramViewModel.ShowGrid= false;
DiagramViewModel.ShowGrid = false;
DiagramViewModel.AllowDrop = false;
}
@@ -44,7 +49,26 @@ namespace AIStudio.Wpf.Flowchart
get
{
return DiagramViewModel as IMindDiagramViewModel;
}
}
}
private MindType _mindType = Mind.MindType.Mind;
public MindType MindType
{
get
{
return _mindType;
}
set
{
if (SetProperty(ref _mindType, value))
{
foreach (var vm in DiagramViewModels.OfType<IMindDiagramViewModel>())
{
vm.MindType = MindType; ;
}
}
}
}
protected override void Init()
@@ -65,7 +89,7 @@ namespace AIStudio.Wpf.Flowchart
MindDiagramViewModel.AddChildCommand.Execute(new MindNode[] { level2node1_1, level2node1_1_1 });
MindNode level2node1_1_2 = new MindNode(DiagramViewModel) { Text = "分支主题1_2" };
MindDiagramViewModel.AddChildCommand.Execute(new MindNode[] { level2node1_1, level2node1_1_2 });;
MindDiagramViewModel.AddChildCommand.Execute(new MindNode[] { level2node1_1, level2node1_1_2 }); ;
MindNode level2node1_1_3 = new MindNode(DiagramViewModel) { Text = "分支主题1_3" };
MindDiagramViewModel.AddChildCommand.Execute(new MindNode[] { level2node1_1, level2node1_1_3 });
@@ -82,7 +106,7 @@ namespace AIStudio.Wpf.Flowchart
protected override DiagramViewModel GetDiagramViewModel(string name, DiagramType diagramType)
{
var viewmodel = new MindDiagramViewModel() { Name = name ?? NewNameHelper.GetNewName(DiagramViewModels.Select(p => p.Name), "页-"), DiagramType = diagramType };
var viewmodel = new MindDiagramViewModel() { Name = name ?? NewNameHelper.GetNewName(DiagramViewModels.Select(p => p.Name), "页-"), DiagramType = diagramType, MindType = MindType };
viewmodel.Init();
return viewmodel;

View File

@@ -95,7 +95,22 @@
<Button Margin="5" ToolTip="顺序控制图" Command="{Binding NewCommand}" CommandParameter="SFC" Width="80" Height="80" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="{DynamicResource BlackBrush}">
<Path Stretch="Fill" Margin="20" Fill="{DynamicResource GrayBrush2}" Data="M10.984 13.836a.5.5 0 0 1-.353-.146l-.745-.743a.5.5 0 1 1 .706-.708l.392.391 1.181-1.18a.5.5 0 0 1 .708.707l-1.535 1.533a.504.504 0 0 1-.354.146zm9.353-.147l1.534-1.532a.5.5 0 0 0-.707-.707l-1.181 1.18-.392-.391a.5.5 0 1 0-.706.708l.746.743a.497.497 0 0 0 .706-.001zM4.527 7.452l2.557-1.585A1 1 0 0 0 7.09 4.17L4.533 2.56A1 1 0 0 0 3 3.406v3.196a1.001 1.001 0 0 0 1.527.85zm2.03-2.436L4 6.602V3.406l2.557 1.61zM24 12.5c0 1.93-1.57 3.5-3.5 3.5a3.503 3.503 0 0 1-3.46-3h-2.08a3.503 3.503 0 0 1-3.46 3 3.502 3.502 0 0 1-3.46-3h-.558c-.972 0-1.85-.399-2.482-1.042V17c0 1.654 1.346 3 3 3h.04c.244-1.693 1.7-3 3.46-3 1.93 0 3.5 1.57 3.5 3.5S13.43 24 11.5 24a3.502 3.502 0 0 1-3.46-3H8c-2.206 0-4-1.794-4-4V9.899A5.008 5.008 0 0 1 0 5c0-2.757 2.243-5 5-5s5 2.243 5 5a5.005 5.005 0 0 1-4.952 4.998A2.482 2.482 0 0 0 7.482 12h.558c.244-1.693 1.7-3 3.46-3a3.502 3.502 0 0 1 3.46 3h2.08a3.503 3.503 0 0 1 3.46-3c1.93 0 3.5 1.57 3.5 3.5zm-15 8c0 1.378 1.122 2.5 2.5 2.5s2.5-1.122 2.5-2.5-1.122-2.5-2.5-2.5S9 19.122 9 20.5zM5 9c2.206 0 4-1.794 4-4S7.206 1 5 1 1 2.794 1 5s1.794 4 4 4zm9 3.5c0-1.378-1.122-2.5-2.5-2.5S9 11.122 9 12.5s1.122 2.5 2.5 2.5 2.5-1.122 2.5-2.5zm9 0c0-1.378-1.122-2.5-2.5-2.5S18 11.122 18 12.5s1.122 2.5 2.5 2.5 2.5-1.122 2.5-2.5zm-13 8a.5.5 0 1 0 1 0 .5.5 0 0 0-1 0zm2 0a.5.5 0 1 0 1 0 .5.5 0 0 0-1 0zm12 0c0 1.93-1.57 3.5-3.5 3.5a3.503 3.503 0 0 1-3.46-3.002c-.007.001-.013.005-.021.005l-.506.017h-.017a.5.5 0 0 1-.016-.999l.506-.017c.018-.002.035.006.052.007A3.503 3.503 0 0 1 20.5 17c1.93 0 3.5 1.57 3.5 3.5zm-1 0c0-1.378-1.122-2.5-2.5-2.5S18 19.122 18 20.5s1.122 2.5 2.5 2.5 2.5-1.122 2.5-2.5z" ></Path>
</Button>
<Button Margin="5" ToolTip="思维导图" Command="{Binding NewCommand}" CommandParameter="Mind" Width="80" Height="80" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="{DynamicResource BlackBrush}">
<Button Margin="5" ToolTip="思维导图" Command="{Binding NewMindCommand}" CommandParameter="Mind" Width="80" Height="80" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="{DynamicResource BlackBrush}">
<Path Stretch="Fill" Margin="20" Fill="{DynamicResource GrayBrush2}" Data="M768 128a128 128 0 1 1 0 256h-128a128 128 0 0 1-120.704-85.333333H469.333333c-46.933333 0-85.333333 38.4-85.333333 85.333333v7.296a128 128 0 0 1 0 241.408V640c0 46.933333 38.4 85.333333 85.333333 85.333333h49.92A128.128 128.128 0 0 1 640 640h128a128 128 0 1 1 0 256h-128a128 128 0 0 1-120.704-85.333333H469.333333c-94.293333 0-170.666667-76.373333-170.666666-170.666667H213.333333a128 128 0 1 1 0-256h85.333334c0-94.293333 76.373333-170.666667 170.666666-170.666667h49.92A128.128 128.128 0 0 1 640 128h128z m0 597.333333h-128a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334zM341.333333 469.333333H213.333333a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334z m426.666667-256h-128a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334z" ></Path>
</Button>
<Button Margin="5" ToolTip="目录组织图" Command="{Binding NewMindCommand}" CommandParameter="Directory" Width="80" Height="80" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="{DynamicResource BlackBrush}">
<Path Stretch="Fill" Margin="20" Fill="{DynamicResource GrayBrush2}" Data="M768 128a128 128 0 1 1 0 256h-128a128 128 0 0 1-120.704-85.333333H469.333333c-46.933333 0-85.333333 38.4-85.333333 85.333333v7.296a128 128 0 0 1 0 241.408V640c0 46.933333 38.4 85.333333 85.333333 85.333333h49.92A128.128 128.128 0 0 1 640 640h128a128 128 0 1 1 0 256h-128a128 128 0 0 1-120.704-85.333333H469.333333c-94.293333 0-170.666667-76.373333-170.666666-170.666667H213.333333a128 128 0 1 1 0-256h85.333334c0-94.293333 76.373333-170.666667 170.666666-170.666667h49.92A128.128 128.128 0 0 1 640 128h128z m0 597.333333h-128a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334zM341.333333 469.333333H213.333333a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334z m426.666667-256h-128a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334z" ></Path>
</Button>
<Button Margin="5" ToolTip="鱼骨头图" Command="{Binding NewMindCommand}" CommandParameter="FishBone" Width="80" Height="80" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="{DynamicResource BlackBrush}">
<Path Stretch="Fill" Margin="20" Fill="{DynamicResource GrayBrush2}" Data="M768 128a128 128 0 1 1 0 256h-128a128 128 0 0 1-120.704-85.333333H469.333333c-46.933333 0-85.333333 38.4-85.333333 85.333333v7.296a128 128 0 0 1 0 241.408V640c0 46.933333 38.4 85.333333 85.333333 85.333333h49.92A128.128 128.128 0 0 1 640 640h128a128 128 0 1 1 0 256h-128a128 128 0 0 1-120.704-85.333333H469.333333c-94.293333 0-170.666667-76.373333-170.666666-170.666667H213.333333a128 128 0 1 1 0-256h85.333334c0-94.293333 76.373333-170.666667 170.666666-170.666667h49.92A128.128 128.128 0 0 1 640 128h128z m0 597.333333h-128a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334zM341.333333 469.333333H213.333333a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334z m426.666667-256h-128a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334z" ></Path>
</Button>
<Button Margin="5" ToolTip="逻辑结构图" Command="{Binding NewMindCommand}" CommandParameter="Logical" Width="80" Height="80" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="{DynamicResource BlackBrush}">
<Path Stretch="Fill" Margin="20" Fill="{DynamicResource GrayBrush2}" Data="M768 128a128 128 0 1 1 0 256h-128a128 128 0 0 1-120.704-85.333333H469.333333c-46.933333 0-85.333333 38.4-85.333333 85.333333v7.296a128 128 0 0 1 0 241.408V640c0 46.933333 38.4 85.333333 85.333333 85.333333h49.92A128.128 128.128 0 0 1 640 640h128a128 128 0 1 1 0 256h-128a128 128 0 0 1-120.704-85.333333H469.333333c-94.293333 0-170.666667-76.373333-170.666666-170.666667H213.333333a128 128 0 1 1 0-256h85.333334c0-94.293333 76.373333-170.666667 170.666666-170.666667h49.92A128.128 128.128 0 0 1 640 128h128z m0 597.333333h-128a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334zM341.333333 469.333333H213.333333a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334z m426.666667-256h-128a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334z" ></Path>
</Button>
<Button Margin="5" ToolTip="组织结构图" Command="{Binding NewMindCommand}" CommandParameter="Organizational" Width="80" Height="80" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="{DynamicResource BlackBrush}">
<Path Stretch="Fill" Margin="20" Fill="{DynamicResource GrayBrush2}" Data="M768 128a128 128 0 1 1 0 256h-128a128 128 0 0 1-120.704-85.333333H469.333333c-46.933333 0-85.333333 38.4-85.333333 85.333333v7.296a128 128 0 0 1 0 241.408V640c0 46.933333 38.4 85.333333 85.333333 85.333333h49.92A128.128 128.128 0 0 1 640 640h128a128 128 0 1 1 0 256h-128a128 128 0 0 1-120.704-85.333333H469.333333c-94.293333 0-170.666667-76.373333-170.666666-170.666667H213.333333a128 128 0 1 1 0-256h85.333334c0-94.293333 76.373333-170.666667 170.666666-170.666667h49.92A128.128 128.128 0 0 1 640 128h128z m0 597.333333h-128a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334zM341.333333 469.333333H213.333333a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334z m426.666667-256h-128a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334z" ></Path>
</Button>
<Button Margin="5" ToolTip="天盘图" Command="{Binding NewMindCommand}" IsEnabled="False" CommandParameter="Celestial" Width="80" Height="80" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="{DynamicResource BlackBrush}">
<Path Stretch="Fill" Margin="20" Fill="{DynamicResource GrayBrush2}" Data="M768 128a128 128 0 1 1 0 256h-128a128 128 0 0 1-120.704-85.333333H469.333333c-46.933333 0-85.333333 38.4-85.333333 85.333333v7.296a128 128 0 0 1 0 241.408V640c0 46.933333 38.4 85.333333 85.333333 85.333333h49.92A128.128 128.128 0 0 1 640 640h128a128 128 0 1 1 0 256h-128a128 128 0 0 1-120.704-85.333333H469.333333c-94.293333 0-170.666667-76.373333-170.666666-170.666667H213.333333a128 128 0 1 1 0-256h85.333334c0-94.293333 76.373333-170.666667 170.666666-170.666667h49.92A128.128 128.128 0 0 1 640 128h128z m0 597.333333h-128a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334zM341.333333 469.333333H213.333333a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334z m426.666667-256h-128a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334z" ></Path>
</Button>
</WrapPanel>