Ejemplo n.º 1
0
        private void btnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FormatCondition condtion = new FormatCondition();

            condtion.Name = "Untitled";
            GridView gridView = _currentView as GridView;

            if (gridView != null)
            {
                condtion.Size     = gridView.PaintAppearance.Row.Font.Size.ToString();
                condtion.FontName = gridView.PaintAppearance.Row.Font.Name;
            }
            int position = formatConditionBindingSource.Add(condtion);

            formatConditionBindingSource.Position = position;
            SetFontSizeAndName();
        }
        public static StyleFormatCondition CreateStyleFormatCondition(FormatCondition conditionSetting)
        {
            StyleFormatCondition condition = new StyleFormatCondition();
            var fontStyle = FontStyle.Regular;

            if (conditionSetting.Underline)
            {
                fontStyle |= FontStyle.Underline;
            }
            if (conditionSetting.Italic)
            {
                fontStyle |= FontStyle.Italic;
            }
            if (conditionSetting.Bold)
            {
                fontStyle |= FontStyle.Bold;
            }
            FontFamily fontFamily = new FontFamily(System.Drawing.SystemFonts.DefaultFont.Name);
            float      size       = System.Drawing.SystemFonts.DefaultFont.Size;

            if (!string.IsNullOrEmpty(conditionSetting.FontName))
            {
                fontFamily = new FontFamily(conditionSetting.FontName);
            }
            if (!string.IsNullOrEmpty(conditionSetting.Size))
            {
                size = float.Parse(conditionSetting.Size);
            }
            System.Drawing.Font font = new Font(fontFamily, size, fontStyle);
            condition.Appearance.Font                 = font;
            condition.Condition                       = FormatConditionEnum.Expression;
            condition.Expression                      = conditionSetting.Conditions;
            condition.Appearance.BackColor            = conditionSetting.Backcolor;
            condition.Appearance.ForeColor            = conditionSetting.Forecolor;
            condition.Appearance.Options.UseFont      = conditionSetting.UseFont;
            condition.Appearance.Options.UseForeColor = conditionSetting.UseForeColor;
            condition.Appearance.Options.UseBackColor = conditionSetting.UseBackColor;
            return(condition);
        }