Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="uiControl">the inner .NET Control for the widget</param>
        public ButtonWidgetBase(Control uiControl)
            : base(uiControl)
        {
            widgetAttribute = null;
            Value = null;

            uiControl.Paint += UIControl_Paint;
        }
Beispiel #2
0
 /// <summary>
 /// Sets the WidgetAttribute for the button. Override this
 /// to set properties specific to the individual widget
 /// types
 /// </summary>
 /// <param name="attr">the WidgetAttribute object</param>
 public virtual void SetWidgetAttribute(WidgetAttribute attr)
 {
     widgetAttribute = attr;
     Value = widgetAttribute.Value;
 }
Beispiel #3
0
        /// <summary>
        /// Sets the button attribute.  Extracts font information from
        /// the button attribute and sets the font on the Uicontrol.
        /// </summary>
        /// <param name="attribute"></param>
        public override void SetWidgetAttribute(WidgetAttribute attribute)
        {
            base.SetWidgetAttribute(attribute);
            _fontFamily = Fonts.Instance.GetFontFamily(new[]
                                                        { widgetAttribute.FontName,
                                                            CoreGlobals.AppPreferences.FontName,
                                                            "Arial" });

            if (_fontFamily != null)
            {
                _font = new Font(_fontFamily,
                                    widgetAttribute.FontSize, widgetAttribute
                                    .FontBold ? FontStyle.Bold : FontStyle.Regular);
                UIControl.Font = _font;
            }

            _originalFontSize = _font.Size;
        }
Beispiel #4
0
        /// <summary>
        /// Sets the image.  The Label field in the attribute object
        /// is the name of the image file (not the full name, just the filename).
        /// The image is loaded from ACAT's Images dir
        /// </summary>
        /// <param name="attribute">WidgetAttribute object</param>
        public override void SetWidgetAttribute(WidgetAttribute attribute)
        {
            base.SetWidgetAttribute(attribute);

            // the label attribute points to the filename. Get the image,
            // resize it and prep it
            String imageFile = FileUtils.GetImagePath(attribute.Label);
            if (_cropX >= 0 && _cropY >= 0 && _cropWidth > 0 && _cropHeight > 0)
            {
                _image = ImageUtils.ImageCrop(imageFile, new Rectangle(_cropX, _cropY, _cropWidth, _cropHeight));
            }
            else
            {
                _image = Image.FromFile(imageFile);
            }

            _image = ImageUtils.ImageResize(_image, UIControl.Width, UIControl.Height);
            pictureBox.Image = _image;
        }
Beispiel #5
0
 /// <summary>
 /// Class factory to create a WidgetAttribute object from
 /// the xml node.  The xml fragment (e.g.) is as follows
 ///   <WidgetAttribute name="B44" label="&lt;w" value="@CmdMainMenu" fontname="Arial Narrow" fontsize="24"/>
 /// </summary>
 /// <param name="node">the xml node</param>
 /// <returns>button attribute object</returns>
 public static WidgetAttribute CreateWidgetAttribute(XmlNode node)
 {
     var widgetAttribute = new WidgetAttribute();
     widgetAttribute.load(node);
     return widgetAttribute;
 }
Beispiel #6
0
        /// <summary>
        ///  Sets the font and alignment of text for the button
        /// </summary>
        /// <param name="attribute">The WidgetAttribute object</param>
        public override void SetWidgetAttribute(WidgetAttribute attribute)
        {
            base.SetWidgetAttribute(attribute);

            _fontFamily = Fonts.Instance.GetFontFamily(new[]
                                                    {   widgetAttribute.FontName,
                                                        CoreGlobals.AppPreferences.FontName,
                                                        "Arial" });
            if (_fontFamily != null)
            {
                _font = new Font(_fontFamily, widgetAttribute.FontSize, widgetAttribute.FontBold ?
                                        FontStyle.Bold :
                                        FontStyle.Regular);
                UIControl.Font = _font;
            }

            _originalFontSize = _font.Size;

            SetText(widgetAttribute.Label);

            if (attribute.Alignment != null)
            {
                if (UIControl is Button)
                {
                    var button = (Button)UIControl;
                    button.TextAlign = widgetAttribute.Alignment.Value;
                }
            }
        }