コード例 #1
0
        private void DeleteSelectedItemExec()
        {
            var isFind = false;
            var item   = SelectedItem;

            foreach (var tab in Tabs)
            {
                foreach (var panel in tab.Panels)
                {
                    if (panel.Items.Contains(item))
                    {
                        isFind = true;
                        panel.Items.Remove(item);
                    }
                }
            }

            if (isFind)
            {
                FreeItems.Add(item);
            }
            else
            {
                FreeItems.Remove(item);
            }
        }
コード例 #2
0
        private void DeletePanelExec(RibbonPanelDataVM panel)
        {
            foreach (var item in panel.Items)
            {
                FreeItems.Add(item);
            }

            SelectedTab.Panels.Remove(panel);
        }
コード例 #3
0
        public RibbonVM()
        {
            ribbonVm   = this;
            UserGroups = new List <string> {
                PikSettings.UserGroup, Commands.GroupCommon
            };
            if (!PikSettings.AdditionalUserGroup.IsNullOrEmpty())
            {
                UserGroups.Add(PikSettings.AdditionalUserGroup);
            }
            UserGroup  = PikSettings.UserGroup;
            BlockFiles = BlockFile.GetFiles();
            this.WhenAnyValue(v => v.UserGroup).Subscribe(s =>
            {
                userGroup   = UserGroup;
                RibbonGroup = LoadRibbonGroup(UserGroup);
                Tabs        = new ObservableCollection <RibbonTabDataVM>(RibbonGroup.Tabs?.Select(t => new RibbonTabDataVM
                {
                    Name   = t.Name,
                    Panels = new ObservableCollection <RibbonPanelDataVM>(t.Panels.Select(p => new RibbonPanelDataVM
                    {
                        Name  = p.Name,
                        Items = new ObservableCollection <RibbonItemDataVM>(p.Items?.Select(GetItemVM) ?? new List <RibbonItemDataVM>())
                    }))
                }));
                FreeItems = new ObservableCollection <RibbonItemDataVM>(
                    RibbonGroup.FreeItems?.Select(GetItemVM) ?? new List <RibbonItemDataVM>());
            });

            var iconConverter = new NetLib.WPF.Converters.PackIconImageSourceConverter();

            iconConverter.Convert(PackIconMaterialKind.FormatListBulleted, null, null,
                                  CultureInfo.CurrentCulture);
            Save               = new RelayCommand(SaveExec);
            SelectImage        = new RelayCommand(SelectImageExec);
            DeleteSelectedItem = new RelayCommand(DeleteSelectedItemExec);
            DeletePanel        = new RelayCommand <RibbonPanelDataVM>(DeletePanelExec, e => ShowMessage(e.Message));
            NewPanel           = new RelayCommand(() => SelectedTab.Panels.Add(new RibbonPanelDataVM {
                Name = "Панель"
            }));
            AddTab = new RelayCommand(() => Tabs.Add(new RibbonTabDataVM {
                Name = "Вкладка" + Tabs.Count
            }));
            AddCommandItem = new RelayCommand(() =>
            {
                FreeItems.Add(new RibbonCommandVM(new RibbonCommand())
                {
                    Image = iconConverter.Convert(PackIconFontAwesomeKind.TerminalSolid, null, null, null) as ImageSource
                });
            });
            AddSplitItem = new RelayCommand(() =>
            {
                FreeItems.Add(new RibbonSplitVM(new RibbonSplit())
                {
                    Image = iconConverter.Convert(PackIconMaterialKind.FormatListBulleted, null, null, null) as ImageSource
                });
            });
            AddInsertBlockItem = new RelayCommand(() =>
            {
                FreeItems.Add(new RibbonInsertBlockVM(new RibbonInsertBlock(), BlockFiles)
                {
                    Image = iconConverter.Convert(PackIconFontAwesomeKind.ObjectGroupRegular, null, null, null) as ImageSource
                });
            });
            AddVisualInsertBlockItem = new RelayCommand(() =>
            {
                FreeItems.Add(new RibbonVisualInsertBlockVM(new RibbonVisualInsertBlock(), BlockFiles)
                {
                    Image = iconConverter.Convert(PackIconFontAwesomeKind.WindowsBrands, null, null, null) as ImageSource
                });
            });
            AddToggleItem = new RelayCommand(() =>
            {
                FreeItems.Add(new RibbonToggleVM(new RibbonToggle())
                {
                    Image = iconConverter.Convert(PackIconMaterialKind.Check, null, null, null) as ImageSource
                });
            });
        }