Exemplo n.º 1
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();
        }