コード例 #1
0
        public override void RecordSetting(BaseItem item)
        {
            if (this.SettingsRecorded)
                return;
            
            ButtonItem button = item as ButtonItem;
            m_ButtonStyle = button.ButtonStyle;
            m_ImagePosition = button.ImagePosition;
            m_ImageFixedSize = button.ImageFixedSize;
            if (button.TextMarkupBody != null && button.TextMarkupBody.HasExpandElement)
                m_Text = button.Text;

            base.RecordSetting(item);
        }
コード例 #2
0
        /// <summary>
        /// Overloaded. Deserializes the Item from the XmlElement.
        /// </summary>
        /// <param name="ItemXmlSource">Source XmlElement.</param>
        public override void Deserialize(ItemSerializationContext context)
        {
            base.Deserialize(context);

            System.Xml.XmlElement ItemXmlSource = context.ItemXmlElement;
            m_ImagePosition = (eImagePosition)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("ImagePosition"));
            m_ButtonStyle = (eButtonStyle)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("ButtonStyle"));
            m_Checked = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("Checked"));
            m_VerticalPadding = System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("VerticalPadding"));
            m_HorizontalPadding = System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("HorizontalPadding"));

            m_MenuVisibility = (eMenuVisibility)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("MenuVisibility"));
            m_RecentlyUsed = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("RecentlyUsed"));

            if (ItemXmlSource.HasAttribute("forecolor"))
                m_ForeColor = BarFunctions.ColorFromString(ItemXmlSource.GetAttribute("forecolor"));
            else
                m_ForeColor = System.Drawing.Color.Empty;

            if (ItemXmlSource.HasAttribute("hottrack"))
                m_HotTrackingStyle = (eHotTrackingStyle)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("hottrack"));
            else
                m_HotTrackingStyle = eHotTrackingStyle.Default;

            if (ItemXmlSource.HasAttribute("hotclr"))
                m_HotForeColor = BarFunctions.ColorFromString(ItemXmlSource.GetAttribute("hotclr"));
            else
                m_HotForeColor = System.Drawing.Color.Empty;

            if (ItemXmlSource.HasAttribute("hotfb"))
                m_HotFontBold = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("hotfb"));
            else
                m_HotFontBold = false;
            if (ItemXmlSource.HasAttribute("hotfu"))
                m_HotFontUnderline = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("hotfu"));
            else
                m_HotFontUnderline = false;

            if (ItemXmlSource.HasAttribute("optiongroup"))
                m_OptionGroup = ItemXmlSource.GetAttribute("optiongroup");
            else
                m_OptionGroup = "";

            if (ItemXmlSource.HasAttribute("fontbold"))
                m_FontBold = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("fontbold"));
            else
                m_FontBold = false;
            if (ItemXmlSource.HasAttribute("fontitalic"))
                m_FontItalic = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("fontitalic"));
            else
                m_FontItalic = false;
            if (ItemXmlSource.HasAttribute("fontunderline"))
                m_FontUnderline = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("fontunderline"));
            else
                m_FontUnderline = false;

            if (ItemXmlSource.HasAttribute("AlternateShortcutText"))
                m_AlternateShortcutText = ItemXmlSource.GetAttribute("AlternateShortcutText");
            else
                m_AlternateShortcutText = "";

            if (ItemXmlSource.HasAttribute("autoexpandclick"))
                m_AutoExpandOnClick = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("autoexpandclick"));
            else
                m_AutoExpandOnClick = false;

            if (ItemXmlSource.HasAttribute("CustomColorName"))
                m_CustomColorName = ItemXmlSource.GetAttribute("CustomColorName");
            else
                m_CustomColorName = "";

            if (ItemXmlSource.HasAttribute("ColorTable"))
                m_ColorTable = (eButtonColor)Enum.Parse(m_ColorTable.GetType(), ItemXmlSource.GetAttribute("ColorTable"));
            else
                m_ColorTable = eButtonColor.Orange;

            m_ImageIndex = -1;
            m_HoverImageIndex = -1;
            m_DisabledImageIndex = -1;
            m_PressedImageIndex = -1;
            m_Icon = null;
            m_Image = null;
            m_ImageSmall = null;
            m_HoverImage = null;
            m_DisabledImage = null;
            m_DisabledImageCustom = false;
            m_PressedImage = null;

            // Load Images
            foreach (System.Xml.XmlElement xmlElem in ItemXmlSource.ChildNodes)
            {
                if (xmlElem.Name == "images")
                {
                    if (xmlElem.HasAttribute("imageindex"))
                        m_ImageIndex = System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("imageindex"));
                    if (xmlElem.HasAttribute("hoverimageindex"))
                        m_HoverImageIndex = System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("hoverimageindex"));
                    if (xmlElem.HasAttribute("disabledimageindex"))
                        m_DisabledImageIndex = System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("disabledimageindex"));
                    if (xmlElem.HasAttribute("pressedimageindex"))
                        m_PressedImageIndex = System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("pressedimageindex"));

                    foreach (System.Xml.XmlElement xmlElem2 in xmlElem.ChildNodes)
                    {
                        switch (xmlElem2.GetAttribute("type"))
                        {
                            case "default":
                                {
                                    m_Image = BarFunctions.DeserializeImage(xmlElem2);
                                    m_ImageIndex = -1;
                                    break;
                                }
                            case "icon":
                                {
                                    m_Icon = BarFunctions.DeserializeIcon(xmlElem2);
                                    m_ImageIndex = -1;
                                    break;
                                }
                            case "hover":
                                {
                                    m_HoverImage = BarFunctions.DeserializeImage(xmlElem2);
                                    m_HoverImageIndex = -1;
                                    break;
                                }
                            case "disabled":
                                {
                                    m_DisabledImage = BarFunctions.DeserializeImage(xmlElem2);
                                    m_DisabledImageIndex = -1;
                                    m_DisabledImageCustom = true;
                                    break;
                                }
                            case "pressed":
                                {
                                    m_PressedImage = BarFunctions.DeserializeImage(xmlElem2);
                                    m_PressedImageIndex = -1;
                                    break;
                                }
                            case "small":
                                {
                                    m_ImageSmall = BarFunctions.DeserializeImage(xmlElem2);
                                    break;
                                }
                        }
                    }
                    break;
                }
            }
            this.OnImageChanged();
        }
コード例 #3
0
 /// <summary>
 /// Creates new instance of ButtonItem and assigns the name and text to it.
 /// </summary>
 /// <param name="sItemName">Item name.</param>
 /// <param name="ItemText">item text.</param>
 public ButtonItem(string sItemName, string ItemText)
     : base(sItemName, ItemText)
 {
     m_IsContainer = false;
     m_Image = null;
     m_ImageIndex = -1;
     m_HoverImage = null;
     m_HoverImageIndex = -1;
     m_DisabledImage = null;
     m_DisabledImageIndex = -1;
     m_PressedImage = null;
     m_PressedImageIndex = -1;
     m_MouseOver = false;
     m_MouseDown = false;
     m_ButtonStyle = eButtonStyle.Default;
     m_ImagePosition = eImagePosition.Left;
     m_Font = null;
     m_ImageDrawRect = Rectangle.Empty;
     m_TextDrawRect = Rectangle.Empty;
     m_SubItemsRect = Rectangle.Empty;
     m_VerticalPadding = 0;
     m_HorizontalPadding = 0;
     m_AlternateShortcutText = "";
 }
コード例 #4
0
        public static Size MeasureItemText(BaseItem item, Graphics g, int containerWidth, Font font, eTextFormat stringFormat, bool rightToLeft, bool ribbonBarButton, eImagePosition imagePosition)
        {
            if (item.Text == "" && item.TextMarkupBody == null) return Size.Empty;

            Size textSize = Size.Empty;

            if (item.TextMarkupBody == null)
            {
                textSize = TextDrawing.MeasureString(g, ButtonItemPainter.GetDrawText(item.Text), font, containerWidth, stringFormat);
            }
            else
            {
                Size availSize = new Size(containerWidth, 1);
                if (containerWidth == 0)
                    availSize.Width = 1600;
                TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, Color.Empty, false);
                item.TextMarkupBody.Measure(availSize, d);
                availSize = item.TextMarkupBody.Bounds.Size;
                if (containerWidth != 0 && !(ribbonBarButton && imagePosition == eImagePosition.Top))
                    availSize.Width = containerWidth;
                d.RightToLeft = rightToLeft;
                item.TextMarkupBody.Arrange(new Rectangle(0, 0, availSize.Width, availSize.Height), d);

                textSize = item.TextMarkupBody.Bounds.Size;
            }

            return textSize;
        }