void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.DocBox = ((TabHeader)(target)); return; case 2: this.Docker = ((System.Windows.Controls.DockPanel)(target)); return; case 3: this.HeaderMenu = ((Fluent.ContextMenu)(target)); return; case 4: this.SaveMenuItem = ((Fluent.MenuItem)(target)); return; case 5: this.SaveAsMenuItem = ((Fluent.MenuItem)(target)); return; case 6: this.SaveAllMenuItem = ((Fluent.MenuItem)(target)); return; case 7: this.CloseMenuItem = ((Fluent.MenuItem)(target)); return; case 8: this.CloseAllMenuItem = ((Fluent.MenuItem)(target)); return; case 9: this.FileTypeImage = ((System.Windows.Controls.Image)(target)); return; case 10: this.TabTitle = ((System.Windows.Controls.TextBlock)(target)); return; case 11: this.TabToolTip = ((Fluent.ScreenTip)(target)); return; case 12: this.CloseButton = ((Fluent.Button)(target)); return; } this._contentLoaded = true; }
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; } }