Beispiel #1
0
 /// <summary>
 /// Creates a border line with a specified theme color and style type.
 /// </summary>
 /// <param name="themeColor">The theme color name.</param>
 /// <param name="styleType">The border style type.</param>
 public BorderLine(string themeColor, BorderLineStyle styleType)
 {
     this._context    = null;
     this._themeColor = themeColor;
     this._style      = styleType;
     this._builtIn    = false;
 }
Beispiel #2
0
        public void PaintText(IThemeSupport ts, Graphics graphics, Rectangle rectangle, string text, Font font, Padding padding, HorizontalAlignment textAlign, Color forecolor, bool is3D)
        {
            Brush brush = new SolidBrush(forecolor);

            // Drawing
            float left = 0, top = 0;

            if (textAlign == HorizontalAlignment.Left)
            {
                if (padding != null)
                {
                    SizeF sizeF = graphics.MeasureString(text, font);
                    left = rectangle.Left + padding.Left;
                    top  = rectangle.Top + padding.Top + (rectangle.Height - sizeF.Height) / 2;
                }
            }
            else if (textAlign == HorizontalAlignment.Center)
            {
                SizeF sizeF = graphics.MeasureString(text, font);
                left = rectangle.Left + padding.Left + (rectangle.Width - sizeF.Width) / 2 + 2;
                top  = rectangle.Top + padding.Top + (rectangle.Height - sizeF.Height) / 2;
            }

            if (is3D)
            {
                graphics.DrawString(text, font, new SolidBrush(Color.Gray), left - 1, top - 1);
            }

            graphics.DrawString(text, font, brush, left, top);
        }
Beispiel #3
0
 internal void SetContext(IThemeSupport context)
 {
     if (this.Line != null)
     {
         ((IThemeContextSupport)this.Line).SetContext(context);
     }
     if (this.PreviousLine != null)
     {
         ((IThemeContextSupport)this.PreviousLine).SetContext(context);
     }
     if (this.NextLine != null)
     {
         ((IThemeContextSupport)this.NextLine).SetContext(context);
     }
     if (this.PreviousBreaker1 != null)
     {
         ((IThemeContextSupport)this.PreviousBreaker1).SetContext(context);
     }
     if (this.PreviousBreaker2 != null)
     {
         ((IThemeContextSupport)this.PreviousBreaker2).SetContext(context);
     }
     if (this.NextBreaker1 != null)
     {
         ((IThemeContextSupport)this.NextBreaker1).SetContext(context);
     }
     if (this.NextBreaker2 != null)
     {
         ((IThemeContextSupport)this.NextBreaker2).SetContext(context);
     }
 }
Beispiel #4
0
 public void PaintBackground(IThemeSupport ts, Graphics graphics, Rectangle rectangle)
 {
     if ((ts.WidgetState == WidgetState.Normal) || (ts.WidgetState == WidgetState.MouseLeave))
     {
         DrawBackground_OutlookStyle(
             graphics,
             rectangle,
             ts.BackColor,
             ts.BackColor2,
             ts.ThemePart.BackcolorNormalGlow,
             ts.ThemePart.BorderColor,
             ts.ThemePart.BackcolorAngle);
     }
     else if (ts.WidgetState == WidgetState.MouseEnter)
     {
         DrawBackground_OutlookStyle(
             graphics,
             rectangle,
             ts.BackHighlightColor1,
             ts.BackHighlightColor2,
             ts.ThemePart.BackcolorHighlightGlow,
             ts.ThemePart.BorderColor,
             ts.ThemePart.BackcolorAngle);
     }
 }
Beispiel #5
0
 /// <summary>
 /// Sets the theme context.
 /// </summary>
 /// <param name="context">The theme context object.</param>
 void IThemeContextSupport.SetContext(IThemeSupport context)
 {
     if (this._context != context)
     {
         this._context = context;
     }
 }
Beispiel #6
0
 internal static int GetPaletteColorIndex(IThemeSupport themeSupport, IExcelColor excelColor, int startIndex = 0x40)
 {
     if (excelColor.IsThemeColor)
     {
         return(GetCloestColorIndex(GetRGBColor(themeSupport, new ExcelColor(ExcelColorType.Theme, excelColor.Value, 0.0)), 0x40));
     }
     return(GetCloestColorIndex(GetRGBColor(themeSupport, excelColor), startIndex));
 }
Beispiel #7
0
 /// <summary>
 /// Creates a border line with a specified color and style.
 /// </summary>
 /// <param name="color">The border color.</param>
 /// <param name="styleType">The border style type.</param>
 public BorderLine(Windows.UI.Color color, BorderLineStyle styleType)
 {
     this._context    = null;
     this._themeColor = null;
     this._color      = color;
     this._style      = styleType;
     this._builtIn    = false;
 }
Beispiel #8
0
 /// <summary>
 /// Caution, only use for built-in borders creating.
 /// </summary>
 internal BorderLine(Windows.UI.Color color, BorderLineData style)
 {
     this._context   = null;
     this._style     = BorderLineStyle.None;
     this._color     = color;
     this._styleData = style;
     this._builtIn   = true;
 }
Beispiel #9
0
        /// <summary>
        /// Sets the theme context.
        /// </summary>
        /// <param name="context">The theme context object.</param>
        void IThemeContextSupport.SetContext(IThemeSupport context)
        {
            IThemeContextSupport setting = this.Setting;

            if ((setting != null) && (setting.GetContext() != context))
            {
                setting.SetContext(context);
            }
        }
Beispiel #10
0
        public void PaintText(IThemeSupport ts, Graphics graphics, Rectangle rectangle, string text, Font font, Padding padding, HorizontalAlignment textAlign)
        {
            // Find Brush
            Color forecolor = Color.Navy;

            if ((ts.WidgetState == WidgetState.Normal) || (ts.WidgetState == WidgetState.MouseLeave))
            {
                forecolor = ts.ForeColor;
            }

            else if (ts.WidgetState == WidgetState.MouseEnter)
            {
                forecolor = ts.ForecolorHighlight;
            }

            PaintText(ts, graphics, rectangle, text, font, padding, textAlign, forecolor, false);
        }
Beispiel #11
0
 void Init()
 {
     this._fontTheme                 = null;
     this._fontFamily                = null;
     this._fontSize                  = -1.0;
     this._fontStretch               = Windows.UI.Text.FontStretch.Normal;
     this._fontStyle                 = Windows.UI.Text.FontStyle.Normal;
     this._fontWeight                = FontWeights.Normal;
     this._fill                      = null;
     this._fillThemeColor            = null;
     this._foreground                = null;
     this._foregroundThemeColor      = null;
     this._strokeThickness           = 1.0;
     this._stroke                    = null;
     this._strokeDashType            = Dt.Cells.Data.StrokeDashType.None;
     this._strokeThemeColor          = null;
     this._cornerRadius              = -1.0;
     this._themeContext              = null;
     this._cornerRadiusSet           = false;
     this._fillSet                   = false;
     this._fillThemeColorSet         = false;
     this._fontFamilySet             = false;
     this._fontSizeSet               = false;
     this._fontStretchSet            = false;
     this._fontStyleSet              = false;
     this._fontThemeSet              = false;
     this._fontWeightSet             = false;
     this._foregroundSet             = false;
     this._foregroundThemeColorSet   = false;
     this._strokeDashTypeSet         = false;
     this._strokeSet                 = false;
     this._strokeThemeColorSet       = false;
     this._strokeThicknessSet        = false;
     this._formatter                 = null;
     this._formatterSet              = false;
     this._lineCapType               = PenLineCap.Flat;
     this._lineCapTypeSet            = false;
     this._lineJoinType              = PenLineJoin.Round;
     this._lineJoinTypeSet           = false;
     this._lineBeginArrowSettings    = null;
     this._lineBeginArrowSettingsSet = false;
     this._lineEndArrowSettings      = null;
     this._lineEndArrowSettingsSet   = false;
 }
Beispiel #12
0
        /// <summary>
        /// Generates an object from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader" /> stream from which the object is deserialized.</param>
        void IXmlSerializable.ReadXml(XmlReader reader)
        {
            Serializer.InitReader(reader);
            this._context    = null;
            this._color      = Colors.Transparent;
            this._themeColor = null;
            this._style      = BorderLineStyle.None;
            this._styleData  = null;
            while (reader.Read())
            {
                string str;
                if ((reader.NodeType == XmlNodeType.Element) && ((str = reader.Name) != null))
                {
                    if (str != "Type")
                    {
                        if (str == "Color")
                        {
                            goto Label_008E;
                        }
                        if (str == "Theme")
                        {
                            goto Label_00AB;
                        }
                    }
                    else
                    {
                        this._style = (BorderLineStyle)Serializer.DeserializeObj(typeof(BorderLineStyle), reader);
                    }
                }
                continue;
Label_008E:
                this._color = (Windows.UI.Color)Serializer.DeserializeObj(typeof(Windows.UI.Color), reader);
                continue;
Label_00AB:
                this._themeColor = (string)(Serializer.DeserializeObj(typeof(string), reader) as string);
            }
        }
Beispiel #13
0
 internal static Windows.UI.Color GetRGBColor(IThemeSupport themeSupport, IExcelColor excelColor)
 {
     if (excelColor != null)
     {
         if (excelColor.IsAutoColor)
         {
             return(SystemColors.WindowTextColor);
         }
         if (excelColor.IsIndexedColor)
         {
             return(UpdateTint(ColorFromIndex((int)excelColor.Value), (float)excelColor.Tint));
         }
         if (excelColor.IsRGBColor)
         {
             uint num = excelColor.Value | 0xff000000;
             return(UpdateTint(FromArgb(num), (float)excelColor.Tint));
         }
         if (excelColor.IsThemeColor && (themeSupport != null))
         {
             return(UpdateTint(themeSupport.GetThemeColor(excelColor.GetThemeColorName()), (float)excelColor.Tint));
         }
     }
     return(Colors.Transparent);
 }
Beispiel #14
0
        void ApplyEditorStyle(StyleInfo p_info, bool p_isFormula)
        {
            var cell = _editingCell.BindingCell;

            if (p_info.FontSize > 0.0)
            {
                Editor.FontSize = p_info.FontSize * _ownPanel.Excel.ZoomFactor;
            }
            else
            {
                Editor.ClearValue(TextBlock.FontSizeProperty);
            }

            Editor.FontStyle   = p_info.FontStyle;
            Editor.FontWeight  = p_info.FontWeight;
            Editor.FontStretch = p_info.FontStretch;

            if (p_info.IsFontFamilySet() && (p_info.FontFamily != null))
            {
                Editor.FontFamily = p_info.FontFamily;
            }
            else if (p_info.IsFontThemeSet())
            {
                string        fontTheme = p_info.FontTheme;
                IThemeSupport worksheet = cell.Worksheet;
                if (worksheet != null)
                {
                    Editor.FontFamily = worksheet.GetThemeFont(fontTheme);
                }
            }
            else
            {
                Editor.ClearValue(Control.FontFamilyProperty);
            }

            Brush foreground = null;

            if (p_info.IsForegroundSet())
            {
                foreground = p_info.Foreground;
            }
            else if (p_info.IsForegroundThemeColorSet())
            {
                string fname = p_info.ForegroundThemeColor;
                if ((!string.IsNullOrEmpty(fname) && (cell.Worksheet != null)) && (cell.Worksheet.Workbook != null))
                {
                    foreground = new SolidColorBrush(cell.Worksheet.Workbook.GetThemeColor(fname));
                }
            }
            if (foreground != null)
            {
                Editor.Foreground = foreground;
            }
            else
            {
                Editor.Foreground = BrushRes.BlackBrush;
            }

            Editor.VerticalContentAlignment = p_info.VerticalAlignment.ToVerticalAlignment();
            if (p_isFormula)
            {
                Editor.TextAlignment = Windows.UI.Xaml.TextAlignment.Left;
            }
            else if (!cell.ActualWordWrap)
            {
                switch (cell.ToHorizontalAlignment())
                {
                case HorizontalAlignment.Left:
                case HorizontalAlignment.Stretch:
                    Editor.TextAlignment = Windows.UI.Xaml.TextAlignment.Left;
                    break;

                case HorizontalAlignment.Center:
                    Editor.TextAlignment = Windows.UI.Xaml.TextAlignment.Center;
                    break;

                case HorizontalAlignment.Right:
                    Editor.TextAlignment = Windows.UI.Xaml.TextAlignment.Right;
                    break;
                }
            }
            else
            {
                Editor.TextAlignment = Windows.UI.Xaml.TextAlignment.Left;
            }

            Editor.SelectionStart = Editor.Text.Length;
            Editor.SelectAll();
        }
Beispiel #15
0
 void IThemeContextSupport.SetContext(IThemeSupport context)
 {
     this.SetContext(context);
 }
Beispiel #16
0
 /// <summary>
 /// Sets the theme context.
 /// </summary>
 /// <param name="context">The theme context.</param>
 void IThemeContextSupport.SetContext(IThemeSupport context)
 {
     ((IThemeContextSupport)_viewInfo).SetContext(context);
 }
Beispiel #17
0
 internal void CopyFromInternal(object o, bool clone)
 {
     if ((o is FloatingObjectStyleInfo) && !object.ReferenceEquals(o, this))
     {
         FloatingObjectStyleInfo info = (FloatingObjectStyleInfo)o;
         this._fontTheme      = info._fontTheme;
         this._fontThemeSet   = info._fontThemeSet;
         this._fontFamily     = info._fontFamily;
         this._fontFamilySet  = info._fontFamilySet;
         this._fontSize       = info._fontSize;
         this._fontSizeSet    = info._fontSizeSet;
         this._fontStretch    = info._fontStretch;
         this._fontStretchSet = info._fontStretchSet;
         this._fontStyle      = info._fontStyle;
         this._fontStyleSet   = info._fontStyleSet;
         this._fontWeight     = info._fontWeight;
         this._fontWeightSet  = info._fontWeightSet;
         if (info._fillSet)
         {
             ICloneable cloneable = info._fill as ICloneable;
             if (cloneable != null)
             {
                 this._fill = cloneable.Clone() as Brush;
             }
             else
             {
                 this._fill = info._fill;
             }
             this._fillSet = true;
         }
         else
         {
             this._fill    = null;
             this._fillSet = false;
         }
         if (info._foregroundSet)
         {
             ICloneable cloneable2 = info._foreground as ICloneable;
             if (cloneable2 != null)
             {
                 this._foreground = cloneable2.Clone() as Brush;
             }
             else
             {
                 this._foreground = info._foreground;
             }
             this._foregroundSet = true;
         }
         else
         {
             this._foreground    = null;
             this._foregroundSet = false;
         }
         this._fillThemeColor          = info._fillThemeColor;
         this._fillThemeColorSet       = info._fillThemeColorSet;
         this._foregroundThemeColor    = info._foregroundThemeColor;
         this._foregroundThemeColorSet = info._foregroundThemeColorSet;
         if (info._strokeSet)
         {
             ICloneable cloneable3 = info._stroke as ICloneable;
             if (cloneable3 != null)
             {
                 this._stroke = cloneable3.Clone() as Brush;
             }
             else
             {
                 this._stroke = info._stroke;
             }
             this._strokeSet = true;
         }
         else
         {
             this._stroke    = null;
             this._strokeSet = false;
         }
         this._strokeDashType      = info._strokeDashType;
         this._strokeDashTypeSet   = info._strokeDashTypeSet;
         this._strokeThemeColor    = info._strokeThemeColor;
         this._strokeThemeColorSet = info._strokeThemeColorSet;
         this._strokeThickness     = info._strokeThickness;
         this._strokeThicknessSet  = info._strokeThicknessSet;
         this._cornerRadius        = info._cornerRadius;
         this._cornerRadiusSet     = info._cornerRadiusSet;
         this._themeContext        = info._themeContext;
         if (info._formatterSet)
         {
             ICloneable cloneable4 = info._formatter as ICloneable;
             if (cloneable4 != null)
             {
                 this._formatter = cloneable4.Clone() as IFormatter;
             }
             else
             {
                 this._formatter = info._formatter;
             }
             this._formatterSet = true;
         }
         else
         {
             this._formatter    = null;
             this._formatterSet = false;
         }
         this._lineCapType               = info._lineCapType;
         this._lineCapTypeSet            = info._lineCapTypeSet;
         this._lineJoinType              = info.LineJoinType;
         this._lineJoinTypeSet           = info._lineJoinTypeSet;
         this._lineBeginArrowSettings    = info._lineBeginArrowSettings;
         this._lineBeginArrowSettingsSet = info._lineBeginArrowSettingsSet;
         this._lineEndArrowSettings      = info._lineEndArrowSettings;
         this._lineEndArrowSettingsSet   = info._lineEndArrowSettingsSet;
     }
 }
Beispiel #18
0
 /// <summary>
 /// Sets the theme context.
 /// </summary>
 /// <param name="context">The theme context.</param>
 void IThemeContextSupport.SetContext(IThemeSupport context)
 {
     ((IThemeContextSupport)this.info).SetContext(context);
 }