/// <summary> /// Creates a new instance /// </summary> public RibbonControlSizeDefinition(RibbonControlSize large, RibbonControlSize middle, RibbonControlSize small) : this() { this.Large = large; this.Middle = middle; this.Small = small; }
/// <summary> /// Gets value of the attached property SizeDefinition of the given element /// </summary> /// <param name="element">The given element</param> public static RibbonControlSize[] GetThreeSizeDefinition(UIElement element) { string[] splitted = ((element as IRibbonControl).SizeDefinition).Split(new char[] { ' ', ',', ';', '-', '>' }, StringSplitOptions.RemoveEmptyEntries); int count = Math.Min(splitted.Length, 3); if (count == 0) { return new RibbonControlSize[] { RibbonControlSize.Large, RibbonControlSize.Large, RibbonControlSize.Large } } ; RibbonControlSize[] sizes = new RibbonControlSize[3]; for (int i = 0; i < count; i++) { switch (splitted[i]) { case "Large": sizes[i] = RibbonControlSize.Large; break; case "Middle": sizes[i] = RibbonControlSize.Middle; break; case "Small": sizes[i] = RibbonControlSize.Small; break; default: sizes[i] = RibbonControlSize.Large; break; } } for (int i = count; i < 3; i++) { sizes[i] = sizes[count - 1]; } return(sizes); }
/// <summary> /// Handles size property changing /// </summary> /// <param name="previous">Previous value</param> /// <param name="current">Current value</param> public void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current) { foreach (var frameworkElement in actualChildren) { RibbonAttachedProperties.SetRibbonSize(frameworkElement, current); } rebuildVisualAndLogicalChildren = true; InvalidateMeasure(); }
private void AddBackstageTabItem(IBaseCommand command, IList itemCollection, RibbonControlSize size = RibbonControlSize.Large) { if (command != null && itemCollection != null) { var item = command.ToBackstageTabItem(size); if (item != null) { itemCollection.Add(item); } } }
private void AddButton(IBaseCommand command, IList itemCollection, RibbonControlSize size = RibbonControlSize.Large) { if (command != null && itemCollection != null) { var item = command.ToFluentButton(size); if (item != null) { itemCollection.Add(item); } } }
/// <summary> /// Gets value of the attached property SizeDefinition of the given element /// </summary> /// <param name="element">The given element</param> public static RibbonControlSize[] GetThreeRibbonSizeDefinition(DependencyObject element) { var sizeDefinition = GetRibbonSizeDefinition(element); if (string.IsNullOrEmpty(sizeDefinition)) { return(new[] { RibbonControlSize.Large, RibbonControlSize.Large, RibbonControlSize.Large }); } var splitted = sizeDefinition.Split(new[] { ' ', ',', ';', '-', '>' }, StringSplitOptions.RemoveEmptyEntries); var count = Math.Min(splitted.Length, 3); if (count == 0) { return(new[] { RibbonControlSize.Large, RibbonControlSize.Large, RibbonControlSize.Large }); } var sizes = new RibbonControlSize[3]; for (var i = 0; i < count; i++) { switch (splitted[i]) { case "Large": sizes[i] = RibbonControlSize.Large; break; case "Middle": sizes[i] = RibbonControlSize.Middle; break; case "Small": sizes[i] = RibbonControlSize.Small; break; default: sizes[i] = RibbonControlSize.Large; break; } } for (var i = count; i < 3; i++) { sizes[i] = sizes[count - 1]; } return(sizes); }
/// <summary> /// 获取快速访问菜单按钮 /// </summary> /// <param name="command">命令</param> /// <param name="size">尺寸</param> /// <returns>快速访问菜单按钮</returns> public static BackstageTabItem ToBackstageTabItem(this IBaseCommand command, RibbonControlSize size = RibbonControlSize.Large) { BackstageTabItem item = null; if (command != null) { item = new BackstageTabItem() { Header = command.Header, Icon = command.Icon, Content = command.ToFluentButton(size, false) }; } return(item); }
/// <summary> /// Gets the appropriate <see cref="RibbonControlSize"/> from <see cref="Large"/>, <see cref="Middle"/> or <see cref="Small"/> depending on <paramref name="ribbonControlSize"/> /// </summary> public RibbonControlSize GetSize(RibbonControlSize ribbonControlSize) { switch (ribbonControlSize) { case RibbonControlSize.Large: return(this.Large); case RibbonControlSize.Middle: return(this.Middle); case RibbonControlSize.Small: return(this.Small); default: return(RibbonControlSize.Large); } }
/// <summary> /// 获取按钮 /// </summary> /// <param name="command">命令</param> /// <param name="size">尺寸</param> /// <param name="useIcon">使用图标</param> /// <returns>按钮</returns> public static Fluent.Button ToFluentButton(this IBaseCommand command, RibbonControlSize size = RibbonControlSize.Large, bool useIcon = true) { Button button = null; if (command != null) { button = new Button() { Header = command.Header, Name = command.Name, ToolTip = command.ToolTip, Size = size, Command = command }; if (useIcon) { button.Icon = command.Icon; button.LargeIcon = command.LargeIcon; } } return(button); }
private static RibbonControlSize CoerceSize(IAvaloniaObject obj, RibbonControlSize val) { if (obj is IRibbonControl ctrl) { if ((int)(ctrl.MinSize) > (int)val) { return(ctrl.MinSize); } else if ((int)(ctrl.MaxSize) < (int)val) { return(ctrl.MaxSize); } else { return(val); } } else { throw new Exception("obj must be an IRibbonControl!"); } }
private RibbonGroupBox GetNavigateRibbonGoupBox() { RibbonGroupBox ribbonGroupBox = new RibbonGroupBox() { Header = "导航" }; RibbonControlSize size = RibbonControlSize.Middle; var command = AppManager.CommandFactory.GetActivePanToolCommand(Map); AddButton(command, ribbonGroupBox.Items); command = AppManager.CommandFactory.GetZoomToMaxExtentCommand(Map); AddButton(command, ribbonGroupBox.Items, size); command = AppManager.CommandFactory.GetActiveZoomInToolCommand(Map); AddButton(command, ribbonGroupBox.Items, size); command = AppManager.CommandFactory.GetZoomToPreviousViewCommand(Map); AddButton(command, ribbonGroupBox.Items, size); command = AppManager.CommandFactory.GetActiveIdentifyToolCommand(Map); AddButton(command, ribbonGroupBox.Items, size); command = AppManager.CommandFactory.GetActiveZoomOutToolCommand(Map); AddButton(command, ribbonGroupBox.Items, size); command = AppManager.CommandFactory.GetZoomToNextViewCommand(Map); AddButton(command, ribbonGroupBox.Items, size); return(ribbonGroupBox); }
override public void GenerateUI(CompositeRemoteCommand command) { try { Argument.IsNotNull(() => command.UIData); string uiType = command.UIType; if (string.IsNullOrEmpty(command.UIType)) { uiType = typeof(RibbonButtonUIData).Name; _log.Warning("Command Type is not valid, but generate UI for Command:" + command.ID + "using command type RibbonButtonUIData"); } if (typeof(RibbonButtonUIData).Name.Equals(uiType)) { RibbonUIPositionRibbonTab ribbonTabData; RibbonButtonUIData ribbonUiData; command.DeserializedUIData = ribbonUiData = RibbonButtonUIData.Deserialize(command.UIData); ribbonTabData = ribbonUiData.UiPosition.RibbonTab; var groupBox = GetUiPosition(command); if (groupBox == null) { return; } var button = new Fluent.Button(); button.Name = command.ID; if (!string.IsNullOrEmpty(ribbonUiData.ShortCutKeys)) { button.SetValue(KeyTip.KeysProperty, ribbonUiData.ShortCutKeys); } if (!string.IsNullOrEmpty(ribbonUiData.LocalizedHeader)) { button.BindToLoc(Fluent.Button.HeaderProperty, ribbonUiData.LocalizedHeader); } else { button.Header = command.ID; } if (string.IsNullOrEmpty(ribbonUiData.IconURI)) { button.Icon = new BitmapImage(new Uri("pack://application:,,,/Metaseed.ShellBase;component/Resources/Images/No.png", UriKind.RelativeOrAbsolute)); button.LargeIcon = new BitmapImage(new Uri("pack://application:,,,/Metaseed.ShellBase;component/Resources/Images/No.png", UriKind.RelativeOrAbsolute)); } else { button.Icon = GetBitmap(ribbonUiData.IconURI); button.LargeIcon = GetBitmap(ribbonUiData.IconURI); } RibbonControlSize size; button.SetValue(Fluent.Button.SizeProperty, RibbonControlSize.TryParse(ribbonUiData.Size, out size) ? size : RibbonControlSize.Large); var toolTip = new Fluent.ScreenTip(); toolTip.BindToLoc(ScreenTip.TitleProperty, ribbonUiData.ScreenTip.LocalizedTitle); toolTip.BindToLoc(ScreenTip.TextProperty, ribbonUiData.ScreenTip.LocalizedText); toolTip.Image = string.IsNullOrEmpty(ribbonUiData.ScreenTip.IconURI) ? new BitmapImage(new Uri("pack://application:,,,/Metaseed.ShellBase;component/Resources/Images/No.png", UriKind.RelativeOrAbsolute)) : GetBitmap(ribbonUiData.ScreenTip.IconURI); //toolTip.HelpTopic = "FunctionBlock_CreatNewDoc"; toolTip.BindToLoc(ScreenTip.DisableReasonProperty, ribbonUiData.ScreenTip.LocalizedDisableReason); button.ToolTip = toolTip; groupBox.Items.Add(button); var binding = new Binding() { Source = command }; button.SetBinding(ButtonBase.CommandProperty, binding); } } catch (Exception e) { System.Windows.MessageBox.Show("Can not parse the command config data: " + e.Messages()); return; } }
private QuickAccessMenuItem GetQuickAccessMenuItem(object header, ICommand command, string iconPath, string largeIconPath, object toolTip = null, RibbonControlSize size = RibbonControlSize.Large) { QuickAccessMenuItem quickAccessMenuItem = new QuickAccessMenuItem() { IsChecked = true, Target = ControlExtensions.GetFluentButton(header, command, iconPath, largeIconPath, toolTip, size) }; return(quickAccessMenuItem); }
private void AddQuickAccessMenuItem(IBaseCommand command, IList itemCollection, RibbonControlSize size = RibbonControlSize.Large) { if (command != null && itemCollection != null) { var button = command.ToQuickAccessMenuItem(size); if (button != null) { var item = command.ToQuickAccessMenuItem(size); if (item != null) { itemCollection.Add(item); } } } }
/// <summary> /// Handles size property changing /// </summary> /// <param name="previous">Previous value</param> /// <param name="current">Current value</param> public void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current) { if (this.CanCollapseToButton) { if (current == RibbonControlSize.Large && this.galleryPanel.MinItemsInRow > this.MinItemsInRow) { this.IsCollapsed = false; } else { this.IsCollapsed = true; } } else { this.IsCollapsed = false; } }
/// <summary> /// Handles size property changing /// </summary> /// <param name="previous">Previous value</param> /// <param name="current">Current value</param> protected override void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current) { rebuildVisualAndLogicalChildren = true; InvalidateMeasure(); }
/// <summary> /// Sets appropriate size of the control according to the /// given ribbon control size and control's size definition /// </summary> /// <param name="element">UI Element</param> /// <param name="size">Ribbon control size before applying SizeDefinition</param> public static void SetAppropriateSize(DependencyObject element, RibbonControlSize size) { SetSize(element, GetSizeDefinition(element).GetSize(size)); }
/// <summary> /// Handles size property changing /// </summary> /// <param name="previous">Previous value</param> /// <param name="current">Current value</param> protected virtual void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current) { }
/// <summary> /// Sets SizeDefinition for element /// </summary> public static void SetRibbonSize(DependencyObject element, RibbonControlSize value) { element.SetValue(RibbonSizeProperty, value); }
/// <summary> /// Gets value of the attached property SizeDefinition of the given element /// </summary> /// <param name="element">The given element</param> public static RibbonControlSize[] GetThreeSizeDefinition(UIElement element) { string[] splitted = ((element as IRibbonControl).SizeDefinition).Split(new char[] { ' ', ',', ';', '-', '>' }, StringSplitOptions.RemoveEmptyEntries); int count = Math.Min(splitted.Length, 3); if (count == 0) return new RibbonControlSize[] { RibbonControlSize.Large, RibbonControlSize.Large, RibbonControlSize.Large }; RibbonControlSize[] sizes = new RibbonControlSize[3]; for (int i = 0; i < count; i++) { switch (splitted[i]) { case "Large": sizes[i] = RibbonControlSize.Large; break; case "Middle": sizes[i] = RibbonControlSize.Middle; break; case "Small": sizes[i] = RibbonControlSize.Small; break; default: sizes[i] = RibbonControlSize.Large; break; } } for (int i = count; i < 3; i++) { sizes[i] = sizes[count - 1]; } return sizes; }
/// <summary> /// Sets SizeDefinition for element /// </summary> public static void SetSize(DependencyObject element, RibbonControlSize value) { element.SetValue(SizeProperty, value); }
/// <inheritdoc /> public void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current) { // todo: do we really need this? Size is a DependencyProperty. this.OnPropertyChanged(nameof(this.Size)); }
public void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current) { this.Invalidate("Size"); }
/// <summary> /// Gets value of the attached property SizeDefinition of the given element /// </summary> /// <param name="element">The given element</param> public static RibbonControlSize[] GetThreeRibbonSizeDefinition(DependencyObject element) { var sizeDefinition = GetRibbonSizeDefinition(element); if (string.IsNullOrEmpty(sizeDefinition)) { return new[] { RibbonControlSize.Large, RibbonControlSize.Large, RibbonControlSize.Large }; } var splitted = sizeDefinition.Split(new[] { ' ', ',', ';', '-', '>' }, StringSplitOptions.RemoveEmptyEntries); var count = Math.Min(splitted.Length, 3); if (count == 0) { return new[] { RibbonControlSize.Large, RibbonControlSize.Large, RibbonControlSize.Large }; } var sizes = new RibbonControlSize[3]; for (var i = 0; i < count; i++) { switch (splitted[i]) { case "Large": sizes[i] = RibbonControlSize.Large; break; case "Middle": sizes[i] = RibbonControlSize.Middle; break; case "Small": sizes[i] = RibbonControlSize.Small; break; default: sizes[i] = RibbonControlSize.Large; break; } } for (var i = count; i < 3; i++) { sizes[i] = sizes[count - 1]; } return sizes; }
private static bool ValidateSize(RibbonControlSize arg) { return(true); }
/// <summary> /// 获取快速访问菜单按钮 /// </summary> /// <param name="command">命令</param> /// <param name="size">尺寸</param> /// <returns>快速访问菜单按钮</returns> public static QuickAccessMenuItem ToQuickAccessMenuItem(this IBaseCommand command, RibbonControlSize size = RibbonControlSize.Large) { QuickAccessMenuItem item = null; if (command != null) { item = new QuickAccessMenuItem() { IsChecked = true, Icon = command.Icon, Target = command.ToFluentButton(size, false) }; } return(item); }
/// <summary> /// Handles size property changing /// </summary> /// <param name="previous">Previous value</param> /// <param name="current">Current value</param> public void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current) { foreach (var frameworkElement in this.actualChildren) { RibbonProperties.SetSize(frameworkElement, current); } this.rebuildVisualAndLogicalChildren = true; this.InvalidateMeasure(); }
/// <summary> /// Handles size property changing /// </summary> /// <param name="previous">Previous value</param> /// <param name="current">Current value</param> public void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current) { if (CanCollapseToButton) { if ((current == RibbonControlSize.Large) && (galleryPanel.MinItemsInRow > MinItemsInRow)) { IsCollapsed = false; } else { IsCollapsed = true; } } else { IsCollapsed = false; } }
/// <summary> /// Handles size property changing /// </summary> /// <param name="previous">Previous value</param> /// <param name="current">Current value</param> protected override void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current) { if (CanCollapseToButton) { if ((current == RibbonControlSize.Large) && ((CurrentItemsInRow > MinItemsInRow))) IsCollapsed = false; else IsCollapsed = true; } else IsCollapsed = false; base.OnSizePropertyChanged(previous, current); }