public void Edit() { if (!General.IsBimUser) { "Только для BIM".WriteToCommandLine(); return; } var ribbonVm = new RibbonVM(); var ribbonView = new RibbonView(ribbonVm); Application.ShowModelessWindow(ribbonView); }
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 }); }); }
public RibbonView(RibbonVM vm) : base(vm) { InitializeComponent(); }