예제 #1
0
 /// <summary>
 /// Set ColumnHeader Appearance
 /// </summary>
 /// <param name="gv"></param>
 /// <param name="hAlignment"></param>
 /// <param name="vAligment"></param>
 /// <param name="fontName"></param>
 /// <param name="fontSize"></param>
 /// <param name="fontStyle"></param>
 public static void SetColumnHeaderAppearance(
     this GridView gv
     , HorzAlignment hAlignment           = HorzAlignment.Center
     , VertAlignment vAligment            = VertAlignment.Center
     , string fontName                    = "Tahoma"
     , float fontSize                     = 9F
     , System.Drawing.FontStyle fontStyle = System.Drawing.FontStyle.Bold)
 {
     foreach (GridColumn column in gv.Columns)
     {
         column.AppearanceHeader.TextOptions.HAlignment = hAlignment;
         column.AppearanceHeader.TextOptions.VAlignment = vAligment;
         column.AppearanceHeader.Font = new System.Drawing.Font(fontName, fontSize, fontStyle);
     }
 }
예제 #2
0
        XlVerticalAlignment ConvertAlignment(VertAlignment verticalAlignment)
        {
            switch (verticalAlignment)
            {
            case VertAlignment.Top:
                return(XlVerticalAlignment.Top);

            case VertAlignment.Center:
                return(XlVerticalAlignment.Center);

            case VertAlignment.Bottom:
                return(XlVerticalAlignment.Bottom);
            }
            return(XlVerticalAlignment.Bottom);
        }
예제 #3
0
        public override void Assign(BaseOptions options)
        {
            this.BeginUpdate();
            try
            {
                base.Assign(options);

                MyOptionsView optView = options as MyOptionsView;
                if (optView == null)
                {
                    return;
                }

                this.detailButtonsVAlignment = optView.DetailButtonsVAlignment;
            } finally
            {
                this.EndUpdate();
            }
        }
예제 #4
0
        // Draw text at the indicated location.
        public static void DrawString(this DrawingContext drawing_context,
                                      string text, string font_name, double em_size, Brush brush,
                                      Point origin, VertAlignment valign, TextAlignment halign)
        {
            Typeface      typeface       = new Typeface(font_name);
            FormattedText formatted_text = new FormattedText(
                text, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight,
                typeface, em_size, brush);

            formatted_text.TextAlignment = halign;

            if (valign == VertAlignment.Middle)
            {
                origin.Y -= formatted_text.Height / 2;
            }
            else if (valign == VertAlignment.Bottom)
            {
                origin.Y -= formatted_text.Height;
            }

            drawing_context.DrawText(formatted_text, origin);
        }
예제 #5
0
        public MaskInfo()
        {
            _TitleFont      = new Font(AppearanceObject.DefaultFont.FontFamily, 10f);
            _TitleTextColor = Color.Black;
            _TitleBackColor = Color.Transparent;
            _Title          = string.Empty;
            _TitleAlignment = HorzAlignment.Center;
            _MaskedField    = string.Empty;
            _MaskedFont     = new Font(AppearanceObject.DefaultFont.FontFamily, 10f);
            _MaskedWidth    = 55;
            _ShowTitle      = true;
            _TitleWidth     = 55;

            _MaskedTextColor = Color.Black;
            _MaskedBackColor = Color.Transparent;
            _MaskedAlignment = HorzAlignment.Center;

            _ShowUnderLine     = true;
            _VerticalAlignment = VertAlignment.Bottom;
            _BrotherMaskInfos  = new MaskInfoCollection();
            _DateFormat        = @"M/d/yy";
        }
예제 #6
0
 public MyOptionsView()
 {
     this.detailButtonsVAlignment = VertAlignment.Default;
 }
예제 #7
0
        private void Configure(UIElement ui)
        {
            if (ui is FrameworkElement fe)
            {
                if (contextMenuChildren.Any())
                {
                    fe.ContextMenu = new System.Windows.Controls.ContextMenu();
                    foreach (var contextMenuItem in contextMenuChildren)
                    {
                        fe.ContextMenu.Items.Add(contextMenuItem.GetWPFElement());
                    }
                }

                if (!string.IsNullOrEmpty(ToolTipText))
                {
                    // Use a TextBlock so that the tooltip text can be dynamically updated
                    var toolTipLabel = new TextBlock()
                    {
                        Text = ToolTipText
                    };

                    var toolTip = new System.Windows.Controls.ToolTip()
                    {
                        Content = toolTipLabel
                    };

                    fe.ToolTip = toolTip;

                    if (UpdateToolTip != null)
                    {
                        toolTip.ToolTipOpening += (sender, args) => toolTipLabel.Text = UpdateToolTip();
                    }
                }

                var horizAlignment = HorizAlignment.ToLower();
                if (horizAlignment == "left")
                {
                    fe.HorizontalAlignment = HorizontalAlignment.Left;
                }
                else if (horizAlignment == "right")
                {
                    fe.HorizontalAlignment = HorizontalAlignment.Right;
                }
                else if (horizAlignment == "middle")
                {
                    fe.HorizontalAlignment = HorizontalAlignment.Center;
                }
                else
                {
                    fe.HorizontalAlignment = HorizontalAlignment.Stretch;
                }

                var vertAlignment = VertAlignment.ToLower();
                if (vertAlignment == "top")
                {
                    fe.VerticalAlignment = VerticalAlignment.Top;
                }
                else if (vertAlignment == "bottom")
                {
                    fe.VerticalAlignment = VerticalAlignment.Bottom;
                }
                else if (vertAlignment == "middle")
                {
                    fe.VerticalAlignment = VerticalAlignment.Center;
                }
                else
                {
                    fe.VerticalAlignment = VerticalAlignment.Stretch;
                }

                if (!double.IsNaN(Height))
                {
                    fe.Height = Height;
                }
                if (!double.IsNaN(Width))
                {
                    fe.Width = Width;
                }
                if (!double.IsNaN(MinHeight))
                {
                    fe.MinHeight = MinHeight;
                }
                if (!double.IsNaN(MinWidth))
                {
                    fe.MinWidth = MinWidth;
                }
                if (!double.IsNaN(MaxHeight))
                {
                    fe.MaxHeight = MaxHeight;
                }
                if (!double.IsNaN(MaxWidth))
                {
                    fe.MaxWidth = MaxWidth;
                }
                if (!double.IsNaN(ToolTipShowDuration))
                {
                    ToolTipService.SetShowDuration(fe, (int)Math.Round(ToolTipShowDuration * 1000));
                }

                if (double.IsNaN(UniformMargin))
                {
                    var margin = new double[] { 0, 0, 0, 0 };
                    if (!double.IsNaN(LeftMargin))
                    {
                        margin[0] = LeftMargin;
                    }
                    if (!double.IsNaN(TopMargin))
                    {
                        margin[1] = TopMargin;
                    }
                    if (!double.IsNaN(RightMargin))
                    {
                        margin[2] = RightMargin;
                    }
                    if (!double.IsNaN(BottomMargin))
                    {
                        margin[3] = BottomMargin;
                    }
                    if (margin.Any(d => d > 0 || d < 0))
                    {
                        fe.Margin = new Thickness(margin[0], margin[1], margin[2], margin[3]);
                    }
                }
                else
                {
                    fe.Margin = new Thickness(UniformMargin);
                }

                fe.Visibility = Visible ? Visibility.Visible : Visibility.Collapsed;
            }

            ui.AllowDrop = AllowDrop;

            foreach (var eventHandler in eventHandlers)
            {
                eventHandler.Sender = ui;
            }
        }
예제 #8
0
 protected virtual void SetFieldName(LayoutControlItem item, string fieldName, HorzAlignment horzAlign, VertAlignment vertAlign)
 {
     item.Text = DomainUtils.GetFieldName(fieldName) + ":";
 }
예제 #9
0
 protected virtual void SetFieldName(LayoutControlItem item, string fieldName, VertAlignment vertAlign)
 {
     SetFieldName(item, fieldName, HorzAlignment.Far, vertAlign);
 }
예제 #10
0
        private void AlignAndSetText(string t_text, float t_fontSpacing, HorzAlignment t_horizontalAlignment, VertAlignment t_verticalAlignment)
        {
            _horizontalAlignment = t_horizontalAlignment;
            _verticalAlignment   = t_verticalAlignment;
            SetVerticalAligment(t_verticalAlignment);
            _fontSpacing = t_fontSpacing;

            SetText(t_text, true);
        }
예제 #11
0
        // Draw rotated text at the indicated location.
        public static void DrawRotatedString(this DrawingContext drawing_context,
                                             string text, double angle, string font_name, double em_size, Brush brush,
                                             Point origin, TextAlignment text_align, VertAlignment valign, TextAlignment halign)
        {
            Typeface      typeface       = new Typeface(font_name);
            FormattedText formatted_text = new FormattedText(
                text, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight,
                typeface, em_size, brush);

            formatted_text.TextAlignment = text_align;

            // Make a transformation to center the text.
            double             width      = formatted_text.Width - formatted_text.OverhangLeading;
            double             height     = formatted_text.Height;
            TranslateTransform translate1 = new TranslateTransform();

            translate1.Y = -height / 2;
            if ((text_align == TextAlignment.Left) ||
                (text_align == TextAlignment.Justify))
            {
                translate1.X = -width / 2;
            }
            else if (text_align == TextAlignment.Right)
            {
                translate1.X = width / 2;
            }
            else
            {
                translate1.X = 0;
            }

            // Make a transformation to rotate the text.
            RotateTransform rotate = new RotateTransform(angle);

            // Get the text's bounding rectangle.
            Rect rect = new Rect(0, 0, width, height);

            if (text_align == TextAlignment.Center)
            {
                rect.X -= width / 2;
            }
            else if (text_align == TextAlignment.Right)
            {
                rect.X -= width;
            }

            // Get the rotated bounding rectangle.
            Rect rotated_rect = rotate.TransformBounds(rect);

            // Make a transformation to center the
            // bounding rectangle at the destination.
            TranslateTransform translate2 = new TranslateTransform(origin.X, origin.Y);

            // Adjust the translation for the desired alignment.
            if (halign == TextAlignment.Left)
            {
                translate2.X += rotated_rect.Width / 2;
            }
            else if (halign == TextAlignment.Right)
            {
                translate2.X -= rotated_rect.Width / 2;
            }
            if (valign == VertAlignment.Top)
            {
                translate2.Y += rotated_rect.Height / 2;
            }
            else if (valign == VertAlignment.Bottom)
            {
                translate2.Y -= rotated_rect.Height / 2;
            }

            // Push transformations in reverse order.
            drawing_context.PushTransform(translate2);
            drawing_context.PushTransform(rotate);
            drawing_context.PushTransform(translate1);

            // Draw.
            drawing_context.DrawText(formatted_text, new Point(0, 0));

            // Draw a rectangle around the text. (For debugging.)
            drawing_context.DrawRectangle(null, new Pen(Brushes.Red, 1), rect);

            // Remove the transformations.
            drawing_context.Pop();
            drawing_context.Pop();
            drawing_context.Pop();

            // Draw the rotated bounding rectangle. (For debugging.)
            Rect transformed_rect =
                translate2.TransformBounds(
                    rotate.TransformBounds(
                        translate1.TransformBounds(rect)));
            Pen custom_pen = new Pen(Brushes.Blue, 1);

            custom_pen.DashStyle = new DashStyle(
                new double[] { 5, 5 }, 0);
            drawing_context.DrawRectangle(null, custom_pen, transformed_rect);
        }
예제 #12
0
 /// <summary>
 /// Draws a string to screen
 /// </summary>
 /// <param name="text"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 /// <param name="color"></param>
 /// <param name="halign"></param>
 /// <param name="valign"></param>
 public void Draw(string text, float x, float y, float width, float height, Color color, SizeF scale, HoriAlignment halign, VertAlignment valign, float leading, int tracking, float skewAngle, GUILabel.TextFitMode textFit, int dropShadow, int maskID)
 {
     Otter.Interface.Graphics.Instance.DrawString(mFontID, text, x, y, width, height, color.ToArgb(), scale.Width, scale.Height, (int)halign, (int)valign, leading, tracking, skewAngle, (UInt32)textFit, dropShadow, maskID);
 }
예제 #13
0
 public void Draw(string text, float x, float y, float width, float height, Color color, SizeF scale, HoriAlignment halign, VertAlignment valign)
 {
     Otter.Interface.Graphics.Instance.DrawString(mFontID, text, x, y, width, height, color.ToArgb(), scale.Width, scale.Height, (int)halign, (int)valign, 0.5f, 0, 0.0f, (int)GUILabel.TextFitMode.Wrap, 0, -1);
 }
예제 #14
0
 /// <summary>
 /// Draws a string to screen
 /// </summary>
 /// <param name="text"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 /// <param name="color"></param>
 /// <param name="halign"></param>
 /// <param name="valign"></param>
 public void Draw(string text, float x, float y, float width, float height, Color color, SizeF scale, HoriAlignment halign, VertAlignment valign, float leading, int tracking, float skewAngle, GUILabel.TextFitMode textFit, int dropShadow, int maskID)
 {
     Otter.Interface.Graphics.Instance.DrawString(mFontID, text, x, y, width, height, color.ToArgb(), scale.Width, scale.Height, (int)halign, (int)valign, leading, tracking, skewAngle, (UInt32)textFit, dropShadow, maskID);
 }
예제 #15
0
 public void Draw(string text, float x, float y, float width, float height, Color color, SizeF scale, HoriAlignment halign, VertAlignment valign)
 {
     Otter.Interface.Graphics.Instance.DrawString(mFontID, text, x, y, width, height, color.ToArgb(), scale.Width, scale.Height, (int)halign, (int)valign, 0.5f, 0, 0.0f, (int)GUILabel.TextFitMode.Wrap, 0, -1);
 }
예제 #16
0
 public MaskInfo(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
 {
     try
     {
         this._VerticalAlignment = (DevExpress.Utils.VertAlignment)info.GetValue("_VerticalAlignment", typeof(DevExpress.Utils.VertAlignment));
     }
     catch
     {
         _VerticalAlignment = VertAlignment.Bottom;
     }
     try
     {
         _TitleFont = (System.Drawing.Font)info.GetValue("_TitleFont", typeof(System.Drawing.Font));
     }
     catch
     {
         _TitleFont = new Font(AppearanceObject.DefaultFont.FontFamily, 10f);
     }
     try
     {
         _TitleTextColor = (System.Drawing.Color)info.GetValue("_TitleTextColor", typeof(System.Drawing.Color));
     }
     catch
     {
         _TitleTextColor = Color.Black;
     }
     try
     {
         _TitleBackColor = (System.Drawing.Color)info.GetValue("_TitleBackColor", typeof(System.Drawing.Color));
     }
     catch
     {
         _TitleBackColor = Color.Transparent;
     }
     try
     {
         _Title = info.GetString("_Title");
     }
     catch
     {
         _Title = string.Empty;
     }
     try
     {
         _DateFormat = info.GetString("_DateFormat");
     }
     catch
     {
         _DateFormat = @"M/d/yy";
     }
     try
     {
         _TitleAlignment = (DevExpress.Utils.HorzAlignment)info.GetValue("_TitleAlignment", typeof(DevExpress.Utils.HorzAlignment));
     }
     catch
     {
         _TitleAlignment = HorzAlignment.Center;
     }
     try
     {
         _MaskedField = info.GetString("_MaskedField");
     }
     catch
     {
         _MaskedField = string.Empty;
     }
     try
     {
         _MaskedFont = (System.Drawing.Font)info.GetValue("_MaskedFont", typeof(System.Drawing.Font));
     }
     catch
     {
         _MaskedFont = new Font(AppearanceObject.DefaultFont.FontFamily, 10f);
     }
     try
     {
         _MaskedWidth = info.GetInt32("_MaskedWidth");
     }
     catch
     {
         _MaskedWidth = 55;
     }
     try
     {
         this._MaskedTextColor = (System.Drawing.Color)info.GetValue("_MaskedTextColor", typeof(System.Drawing.Color));
     }
     catch
     {
         _MaskedTextColor = Color.Black;
     }
     try
     {
         this._MaskedBackColor = (System.Drawing.Color)info.GetValue("_MaskedBackColor", typeof(System.Drawing.Color));
     }
     catch
     {
         _MaskedBackColor = Color.Transparent;
     }
     try
     {
         this._MaskedAlignment = (DevExpress.Utils.HorzAlignment)info.GetValue("_MaskedAlignment", typeof(DevExpress.Utils.HorzAlignment));
     }
     catch
     {
         _MaskedAlignment = HorzAlignment.Center;
     }
     try
     {
         this._TitleWidth = info.GetInt32("_TitleWidth");
     }
     catch
     {
         _TitleWidth = 55;
     }
     try
     {
         this._ShowTitle = info.GetBoolean("_ShowTitle");
     }
     catch
     {
         _ShowTitle = true;
     }
     try
     {
         this._ShowUnderLine = info.GetBoolean("_ShowUnderLine");
     }
     catch
     {
         this._ShowUnderLine = true;
     }
     try
     {
         this._BrotherMaskInfos = (MaskInfoCollection)info.GetValue("_BrotherMaskInfos", typeof(MaskInfoCollection));
     }
     catch
     {
         _BrotherMaskInfos = new MaskInfoCollection();
     }
 }