Exemplo n.º 1
0
 /// <summary>
 /// Deserializes workflow markup into an RibbonButtonUIData object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output RibbonButtonUIData object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out RibbonButtonUIData obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(RibbonButtonUIData);
     try
     {
         obj = Deserialize(xml);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
Exemplo n.º 2
0
        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;
            }
        }
Exemplo n.º 3
0
 public static bool LoadFromFile(string fileName, out RibbonButtonUIData obj)
 {
     System.Exception exception = null;
     return(LoadFromFile(fileName, out obj, out exception));
 }
Exemplo n.º 4
0
 public static bool LoadFromFile(string fileName, out RibbonButtonUIData obj, out System.Exception exception)
 {
     return(LoadFromFile(fileName, Encoding.UTF8, out obj, out exception));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Deserializes xml markup from file into an RibbonButtonUIData object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output RibbonButtonUIData object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, System.Text.Encoding encoding, out RibbonButtonUIData obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(RibbonButtonUIData);
     try
     {
         obj = LoadFromFile(fileName, encoding);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
Exemplo n.º 6
0
 public static bool Deserialize(string xml, out RibbonButtonUIData obj)
 {
     System.Exception exception = null;
     return(Deserialize(xml, out obj, out exception));
 }