Example #1
0
 private void GetPayoffButton()
 {
     foreach (PayoffWay payoff in ConstantValuePool.PayoffWayList)
     {
         CrystalButton btn = new CrystalButton();
         btn.Name      = payoff.PayoffID.ToString();
         btn.Text      = payoff.PayoffName;
         btn.Width     = m_Width;
         btn.Height    = m_Height;
         btn.BackColor = btn.DisplayColor = Color.Blue;
         btn.Font      = new Font("Microsoft YaHei", 12F, FontStyle.Regular);
         btn.ForeColor = Color.White;
         foreach (ButtonStyle btnStyle in ConstantValuePool.ButtonStyleList)
         {
             if (payoff.ButtonStyleID.Equals(btnStyle.ButtonStyleID))
             {
                 float     emSize = (float)btnStyle.FontSize;
                 FontStyle style  = FontStyle.Regular;
                 btn.Font      = new Font(btnStyle.FontName, emSize, style);
                 btn.ForeColor = ColorConvert.RGB(btnStyle.ForeColor);
                 btn.BackColor = btn.DisplayColor = ColorConvert.RGB(btnStyle.BackColor);
                 break;
             }
         }
         btn.Tag    = payoff;
         btn.Click += new System.EventHandler(this.btnPayoff_Click);
         payoffButtonList.Add(btn);
     }
 }
Example #2
0
        /// <summary>
        /// Generates a texture consisting of a gradient between all hues (a rainbow) in the HSV
        /// color system, with maximum saturation and value.
        /// </summary>
        /// <param name="resolution">Number of pixels for the gradient longest' side.
        /// Small values like 16 are usually precise enough with bilinear filtering.
        /// The smallest side will always be 1 pixel long.</param>
        /// <param name="vertical">Will the texture be generated vertically?</param>
        /// <returns></returns>
        public static Texture GenerateRainbowGradient(int resolution = 16, bool vertical = true)
        {
            int width  = vertical ? 1 : resolution;
            int height = vertical ? resolution : 1;

            Texture2D texture = new Texture2D(width, height);

            texture.hideFlags = HideFlags.DontSave;
            texture.wrapMode  = TextureWrapMode.Clamp;

            //TODO: Use SetPixels instead of SetPixel, for better performance.
            for (int i = 0; i < resolution; i++)
            {
                float hue   = (i / (float)resolution);
                Color color = ColorConvert.HSVtoRGB(new HSVValues(hue, 1f, 1f, 1f));
                if (vertical)
                {
                    texture.SetPixel(0, i, color);
                }
                else
                {
                    texture.SetPixel(i, 0, color);
                }
            }

            texture.Apply();
            return(texture);
        }
Example #3
0
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if (value is long bytes && bytes > 0)
     {
         return(new SolidColorBrush(ColorConvert.GetSpeedColor(bytes)));
     }
     return(DependencyProperty.UnsetValue);
 }
    public Color RandomSaturated(Color rgbColor)
    {
        float myH, myS, myV;

        ColorConvert.RGBToHSV(rgbColor, out myH, out myS, out myV);
        Color returnColor = ColorConvert.HSVToRGB(myH, Random.Range(.5f, 1f), Random.Range(.5f, 1f));

        return(returnColor);
    }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is double percent && percent > 0)
            {
                return(new SolidColorBrush(ColorConvert.GetErrorPercentColor(percent)));
            }

            return(DependencyProperty.UnsetValue);
        }
    public Color Desaturate(Color rgbColor, float saturation)
    {
        float myH, myS, myV;

        ColorConvert.RGBToHSV(rgbColor, out myH, out myS, out myV);

        Color returnColor = ColorConvert.HSVToRGB(myH, myS * saturation, myV);

        return(returnColor);
    }
Example #7
0
        private void RegenerateTexture()
        {
            Color currentColor = colorPicker.ColorRGB;

            //Currently only supports Saturation x Value
            if (fieldX == Field.HSV_Saturation && fieldY == Field.HSV_Value)
            {
                HSLValues hsla = ColorConvert.RGBtoHSL(currentColor);
                sliderBackground.texture = TextureGenerator.GenerateHSVBox(hsla.h);
            }
        }
    public Color GoldenRatioColor(Color rgbColor)
    {
        float myH, myS, myV;

        ColorConvert.RGBToHSV(rgbColor, out myH, out myS, out myV);
        float goldH = myH + 0.618033988749895f;

        goldH = (goldH % 1f);
        Color returnColor = ColorConvert.HSVToRGB(goldH, myS, myV);

        return(returnColor);
    }
Example #9
0
        /// <summary>
        /// Generates a two-dimensional gradient for visualizing all color possibilities
        /// in a specific HSV hue. Similar to those used in color pickers.
        /// </summary>
        /// <param name="hue">The hue for the colors.</param>
        /// <param name="resolution">Number of pixels for the gradient sides.
        /// Small values like 8 are usually precise enough with bilinear filtering.
        /// Be careful, this increases the complexity exponentially.</param>
        /// <returns></returns>
        public static Texture2D GenerateHSVBox(float hue, int resolution = 8)
        {
            Texture2D texture = new Texture2D(resolution, resolution);

            texture.hideFlags = HideFlags.DontSave;
            texture.wrapMode  = TextureWrapMode.Clamp;

            //TODO: Use SetPixels instead of SetPixel, for better performance.
            for (int x = 0; x < resolution; x++)
            {
                for (int y = 0; y < resolution; y++)
                {
                    float saturation = x / (float)(resolution - 1);
                    float value      = y / (float)(resolution - 1);
                    texture.SetPixel(x, y, ColorConvert.HSVtoRGB(new HSVValues(hue, saturation, value)));
                }
            }

            texture.Apply();
            return(texture);
        }
Example #10
0
        //used to initialize the custom styles to the GridGroupingControl
        private void buttonAdv1_Click(object sender, EventArgs e)
        {
            this.gridGroupingControl1.Appearance.AnyCell.ImageSizeMode = GridImageSizeMode.CenterImage;
            this.gridGroupingControl1.IntelliMousePanning = true;

            GridTable           employeeTable           = this.gridGroupingControl1.Table;
            GridTableDescriptor employeeTableDescriptor = this.gridGroupingControl1.TableDescriptor;

            RecordFieldStylesCollection employee = TableRecordFieldStyles.GetObject(this.gridGroupingControl1.TableDescriptor.Name);

            employee.GetObject(2).GetObject("LastName").BackColor = ColorConvert.ColorFromString("#84A1C3");
            employee.GetObject(2).GetObject("LastName").Font.Bold = true;
            employee.GetObject(1).GetObject("City").BackColor     = ColorConvert.ColorFromString("#FF9933");;
            employee.GetObject(1).GetObject("City").Font.Italic   = true;
            employee.GetObject(1).GetObject("Address").Interior   = new BrushInfo(PatternStyle.OutlinedDiamond, ColorConvert.ColorFromString("#84A1C3"), ColorConvert.ColorFromString("#2a437e"));
            employee.GetObject(1).GetObject("Address").TextColor  = Color.White;
            employee.GetObject(1).GetObject("Address").Font.Bold  = true;
            employee.GetObject(1).GetObject("Address").Font.Size += 2;

            // see also gridGroupingControl1_QueryCellStyleInfo handler,
            //	case GridTableCellType.AlternateRecordFieldCell:
            //	case GridTableCellType.AddNewRecordFieldCell:
            //	case GridTableCellType.RecordFieldCell:
        }
Example #11
0
 /// <summary>
 /// Переводит значения цветовой модели RGBA в HSLA.
 /// </summary>
 /// <param name="Value"></param>
 /// <returns></returns>
 public static (Int32 Hue, Double Saturation, Double Lightness, Double Alpha) ToHsla(this Color Value)
 {
     return(ColorConvert.ToHsla(Value));
 }
Example #12
0
 private HSLValues GetHSL()
 {
     return(ColorConvert.RGBtoHSL(rgb));
 }
Example #13
0
        private void InitializeRegionDeskButton()
        {
            //禁止引发Layout事件
            this.pnlRegion.SuspendLayout();
            this.pnlDesk.SuspendLayout();
            this.SuspendLayout();
            //动态加载区域控件
            foreach (BizRegion region in ConstantValuePool.RegionList)
            {
                CrystalButton btn = new CrystalButton();
                btn.Name     = region.RegionID.ToString();
                btn.Text     = region.RegionName;
                btn.Width    = region.Width;
                btn.Height   = region.Height;
                btn.Location = new Point(region.PX, region.PY);
                btn.Tag      = region;
                foreach (ButtonStyle btnStyle in ConstantValuePool.ButtonStyleList)
                {
                    if (region.ButtonStyleID.Equals(btnStyle.ButtonStyleID))
                    {
                        btn.Font      = new Font(btnStyle.FontName, (float)btnStyle.FontSize, FontStyle.Regular);
                        btn.ForeColor = ColorConvert.RGB(btnStyle.ForeColor);
                        btn.BackColor = btn.DisplayColor = ColorConvert.RGB(btnStyle.BackColor);
                        break;
                    }
                }
                btn.Click += new System.EventHandler(this.btnRegion_Click);
                if (_prevRegionButton == null)
                {
                    _prevRegionButton           = btn;
                    _prevRegionButton.BackColor = ConstantValuePool.PressedColor;
                }
                this.pnlRegion.Controls.Add(btn);
            }
            //动态加载第一区域的桌况信息
            BizRegion firstRegion = ConstantValuePool.RegionList[0];

            _currentRegionId = firstRegion.RegionID;
            if (!_dicDeskInRegion.ContainsKey(_currentRegionId))
            {
                List <CrystalButton> btnList = new List <CrystalButton>();
                foreach (BizDesk desk in firstRegion.BizDeskList)
                {
                    CrystalButton btn = new CrystalButton();
                    btn.Name      = desk.DeskID.ToString();
                    btn.Text      = desk.DeskName;
                    btn.Width     = desk.Width;
                    btn.Height    = desk.Height;
                    btn.Location  = new Point(desk.PX, desk.PY);
                    btn.Tag       = desk;
                    btn.Font      = new Font("Arial", ConstantValuePool.BizSettingConfig.FontSize, FontStyle.Regular);
                    btn.ForeColor = Color.White;
                    btn.BackColor = GetColorByStatus(desk.Status, desk.DeviceNo);
                    btn.Click    += new System.EventHandler(this.btnDesk_Click);
                    btnList.Add(btn);
                }
                _dicDeskInRegion.Add(firstRegion.RegionID, btnList);
            }
            foreach (CrystalButton btn in _dicDeskInRegion[firstRegion.RegionID])
            {
                this.pnlDesk.Controls.Add(btn);
            }
            //恢复引发Layout事件
            this.pnlRegion.ResumeLayout(false);
            this.pnlRegion.PerformLayout();
            this.pnlDesk.ResumeLayout(false);
            this.pnlDesk.PerformLayout();
            this.ResumeLayout(false);
        }
Example #14
0
        private void InitializeReasonButton()
        {
            int reasonCount = 0;

            foreach (Reason item in ConstantValuePool.ReasonList)
            {
                if (item.ReasonType == (int)ReasonItemType.Reminder)
                {
                    reasonCount++;
                }
            }
            if (reasonCount > 0)
            {
                //判断每行显示多少列
                int maxColumn = Convert.ToInt32(Math.Sqrt(Convert.ToDouble(reasonCount)));
                if (maxColumn * maxColumn < reasonCount)
                {
                    maxColumn++;
                }
                //显示多少行
                int perLine = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(reasonCount) / maxColumn));
                //计算button长宽
                int space  = 6;
                int width  = (this.pnlReason.Width - space * (maxColumn - 1)) / maxColumn;
                int height = (this.pnlReason.Height - space * (perLine - 1)) / perLine;

                int           count = 1;
                int           px = 0, py = 0;
                CrystalButton btn;
                foreach (Reason item in ConstantValuePool.ReasonList)
                {
                    if (item.ReasonType == (int)ReasonItemType.Reminder)
                    {
                        btn          = new CrystalButton();
                        btn.Name     = item.ReasonID.ToString();
                        btn.Tag      = item;
                        btn.Text     = item.ReasonName;
                        btn.Width    = width;
                        btn.Height   = height;
                        btn.Location = new Point(px, py);
                        foreach (ButtonStyle btnStyle in ConstantValuePool.ButtonStyleList)
                        {
                            if (item.ButtonStyleID.Equals(btnStyle.ButtonStyleID))
                            {
                                float     emSize = (float)btnStyle.FontSize;
                                FontStyle style  = FontStyle.Regular;
                                btn.Font      = new Font(btnStyle.FontName, emSize, style);
                                btn.ForeColor = ColorConvert.RGB(btnStyle.ForeColor);
                                btn.BackColor = btn.DisplayColor = ColorConvert.RGB(btnStyle.BackColor);
                                break;
                            }
                        }
                        btn.Click += new System.EventHandler(this.btnReason_Click);
                        this.pnlReason.Controls.Add(btn);

                        count++;
                        if (count > maxColumn)
                        {
                            px    = 0;
                            py   += height + space;
                            count = 1;
                        }
                        else
                        {
                            px += width + space;
                        }
                    }
                }
            }
        }
Example #15
0
        public void SetField(Field field, float value)
        {
            Color newRgb = rgb;

            //Avoids true internal blacks, whites and grays.
            //This prevents those colors from "locking" saturation and hue.
            //The change won't be enough to modify HTML/255/359 values.
            if (value < 0.0010f)
            {
                value = 0.0010f;
            }
            if (value > 0.9990f)
            {
                value = 0.9990f;
            }

            switch (field)
            {
            case Field.Red:
                //This prevents internal grays through RGB. Check note above.
                if (value.EqualsAll(RGB.g, RGB.b))
                {
                    value += 0.0001f;
                }
                newRgb = ColorConvert.ChangeRGB(RGB, newR: value);
                break;

            case Field.Green:
                //This prevents internal grays through RGB. Check note above.
                if (value.EqualsAll(RGB.r, RGB.b))
                {
                    value += 0.0001f;
                }
                newRgb = ColorConvert.ChangeRGB(RGB, newG: value);
                break;

            case Field.Blue:
                //This prevents internal grays through RGB. Check note above.
                if (value.EqualsAll(RGB.g, RGB.r))
                {
                    value += 0.0001f;
                }
                newRgb = ColorConvert.ChangeRGB(RGB, newB: value);
                break;

            case Field.Alpha:
                newRgb = ColorConvert.ChangeRGB(RGB, newA: value);
                break;

            case Field.Hue:
                newRgb = ColorConvert.ChangeHSV(RGB, newH: value);
                break;

            case Field.HSV_Saturation:
                newRgb = ColorConvert.ChangeHSV(RGB, newS: value);
                break;

            case Field.HSV_Value:
                newRgb = ColorConvert.ChangeHSV(RGB, newV: value);
                break;

            case Field.HSL_Saturation:
                newRgb = ColorConvert.ChangeHSL(RGB, newS: value);
                break;

            case Field.HSL_Lightness:
                newRgb = ColorConvert.ChangeHSL(RGB, newL: value);
                break;
            }

            SetRGB(newRgb, checkValues: false);
        }
Example #16
0
 private void SetHSL(HSLValues hsl)
 {
     SetRGB(ColorConvert.HSLtoRGB(hsl));
 }
Example #17
0
        private void InitializeGrid()
        {
            #region CellStyleGridControl

            gridControl1.Model.Options.FloatCellsMode = GridFloatCellsMode.OnDemandCalculation;

            GridFontInfo boldFont = new GridFontInfo();
            boldFont.Bold      = true;
            boldFont.Size      = 11;
            boldFont.Underline = true;

            int rowIndex = 2;
            int colIndex = 1;

            gridControl1.Rows.DefaultSize += 2;
            int boldfontRowHeight = gridControl1.Rows.DefaultSize + 6;

            gridControl1.Model.Options.ControllerOptions         = GridControllerOptions.All;
            gridControl1.Model.Options.DataObjectConsumerOptions = GridDataObjectConsumerOptions.All;

            GridStyleInfo standard  = gridControl1.BaseStylesMap["Standard"].StyleInfo;
            GridStyleInfo header    = gridControl1.BaseStylesMap["Header"].StyleInfo;
            GridStyleInfo rowHeader = gridControl1.BaseStylesMap["Row Header"].StyleInfo;
            GridStyleInfo colHeader = gridControl1.BaseStylesMap["Column Header"].StyleInfo;

            header.Interior    = new BrushInfo(SystemColors.Control);
            rowHeader.Interior = new BrushInfo(SystemColors.Control);

            standard.Font.Facename = "Arial"; //"Helvetica";
            header.Enabled         = false;

            gridControl1.Model.Options.FloatCellsMode = GridFloatCellsMode.OnDemandCalculation;

            gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            gridControl1[rowIndex, 1].Text = "Interior";
            gridControl1[rowIndex, 1].Font = boldFont;

            boldfontRowHeight = gridControl1.RowHeights[rowIndex];
            rowIndex++;

            colIndex = 1;
            foreach (Color color in new Color[] {
                Color.Black,
                Color.Red,
                Color.Blue,
                Color.Green,
                Color.Yellow,
                Color.DimGray
            })
            {
                gridControl1[rowIndex, colIndex].Interior = new BrushInfo(color);
                colIndex++;
            }
            rowIndex++;
            colIndex = 1;
            foreach (PatternStyle pattern in new PatternStyle[] {
                PatternStyle.LightVertical,
                PatternStyle.DarkDownwardDiagonal,
                PatternStyle.DashedHorizontal,
                PatternStyle.DottedDiamond,
                PatternStyle.SmallCheckerBoard,
                PatternStyle.SmallGrid
            })
            {
                gridControl1[rowIndex, colIndex].Interior = new BrushInfo(pattern, Color.Black, Color.White);
                colIndex++;
            }
            rowIndex++;
            colIndex = 1;
            foreach (GradientStyle pattern in new GradientStyle[]
            {
                GradientStyle.BackwardDiagonal,
                GradientStyle.ForwardDiagonal,
                GradientStyle.PathEllipse,
                GradientStyle.PathRectangle,
                GradientStyle.Vertical,
                GradientStyle.Horizontal
            })
            {
                gridControl1[rowIndex, colIndex].Interior           = new BrushInfo(pattern, Color.FromArgb(0xde, 0x64, 0x13), Color.Black); //Color.Yellow, Color.Blue);
                gridControl1[rowIndex, colIndex].CellAppearance     = GridCellAppearance.Raised;
                gridControl1[rowIndex + 1, colIndex].Interior       = new BrushInfo(pattern, Color.FromArgb(0x82, 0x2e, 0x1b), Color.White); //Color.Red, Color.White);
                gridControl1[rowIndex + 1, colIndex].CellAppearance = GridCellAppearance.Sunken;
                colIndex++;
            }

            rowIndex++;
            rowIndex++;
            rowIndex++;
            colIndex = 1;

            gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            gridControl1[rowIndex, 1].Text    = "Font";
            gridControl1[rowIndex, 1].Font    = boldFont;
            gridControl1.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            foreach (int size in new int[] {
                6,
                7,
                8,
                10,
                12,
                14
            })
            {
                gridControl1[rowIndex, colIndex].Font.Size = size;
                gridControl1[rowIndex, colIndex].Text      = size.ToString();
                colIndex++;
            }
            gridControl1.RowHeights.ResizeToFit(GridRangeInfo.Row(rowIndex));

            rowIndex++;
            colIndex = 1;
            foreach (FontStyle fontStyle in new FontStyle[]
            {
                FontStyle.Bold,
                FontStyle.Italic,
                FontStyle.Regular,
                FontStyle.Strikeout,
                FontStyle.Underline,
                FontStyle.Bold | FontStyle.Italic | FontStyle.Regular
            })
            {
                gridControl1[rowIndex, colIndex].Font.FontStyle = fontStyle;
                gridControl1[rowIndex, colIndex].Text           = System.Enum.Format(typeof(FontStyle), fontStyle, "G");
                colIndex++;
            }

            rowIndex++;
            rowIndex++;
            colIndex = 1;

            gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            gridControl1[rowIndex, 1].Text    = "TextColor";
            gridControl1[rowIndex, 1].Font    = boldFont;
            gridControl1.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            colIndex = 1;
            foreach (Color color in new Color[] {
                Color.Black,
                Color.Red,
                Color.Blue,
                Color.Green,
                Color.Yellow,
                Color.DimGray
            })
            {
                gridControl1[rowIndex, colIndex].TextColor = color;
                gridControl1[rowIndex, colIndex].Text      = ColorConvert.ColorToString(color, true);
                colIndex++;
            }

            rowIndex++;
            rowIndex++;

            gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            gridControl1[rowIndex, 1].Text    = "Borders";
            gridControl1[rowIndex, 1].Font    = boldFont;
            gridControl1.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;
            colIndex = 1;

            foreach (GridBorder border in new GridBorder[] {
                new GridBorder(GridBorderStyle.Solid, Color.Black),
                new GridBorder(GridBorderStyle.Dotted, Color.Red),
                new GridBorder(GridBorderStyle.DashDot, Color.Black),
                new GridBorder(GridBorderStyle.DashDotDot, Color.Red),
                new GridBorder(GridBorderStyle.Dashed, Color.Black, GridBorderWeight.Medium),
                new GridBorder(GridBorderStyle.Dotted, Color.Red, GridBorderWeight.Medium)
            })
            {
                gridControl1[rowIndex, colIndex].Borders.Bottom = border;
                gridControl1[rowIndex, colIndex].Borders.Right  = border;
                gridControl1[rowIndex, colIndex].Text           = border.ToString();
                colIndex++;
            }

            rowIndex++;
            colIndex = 1;
            foreach (GridBorder border in new GridBorder[] {
                new GridBorder(GridBorderStyle.Dashed, Color.Black, GridBorderWeight.Thick),
                new GridBorder(GridBorderStyle.Dotted, Color.Red, GridBorderWeight.Thick),
                new GridBorder(GridBorderStyle.DashDot, Color.Black, GridBorderWeight.Medium),
                new GridBorder(GridBorderStyle.DashDotDot, Color.Red, GridBorderWeight.Medium),
                new GridBorder(GridBorderStyle.Solid, Color.Black, GridBorderWeight.Thick),
                new GridBorder(GridBorderStyle.Solid, Color.Red, GridBorderWeight.Medium)
            })
            {
                gridControl1[rowIndex, colIndex].Borders.Bottom = border;
                gridControl1[rowIndex, colIndex].Borders.Right  = border;
                gridControl1[rowIndex, colIndex].Text           = border.ToString();
                colIndex++;
            }

            rowIndex++;
            rowIndex++;
            colIndex = 1;

            gridControl1.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            gridControl1[rowIndex, 1].Text    = "Orientation";
            gridControl1[rowIndex, 1].Font    = boldFont;
            gridControl1.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            foreach (int orientation in new int[]
            {
                0,
                45,
                60,
                90,
                180,
                -90
            })
            {
                GridStyleInfo style1 = gridControl1[rowIndex, colIndex];
                // style1 is a direct reference to gridControl1[rowIndex, colIndex];
                // changes will be propagated back to GridData
                style1.HorizontalAlignment = GridHorizontalAlignment.Center;
                style1.VerticalAlignment   = GridVerticalAlignment.Middle;
                GridFontInfo font = style1.Font;
                font.Orientation = orientation;
                font.Bold        = true;
                style1.Text      = "Angle = " + font.Orientation.ToString();
                colIndex++;
            }

            gridControl1.RowHeights.ResizeToFit(GridRangeInfo.Row(rowIndex));

            rowIndex++;
            rowIndex++;
            colIndex = 1;

            gridControl1.CurrentCell.MoveTo(2, 2);

            this.gridControl1.DefaultRowHeight = 18;
            this.gridControl1.DefaultColWidth  = 70;

            this.gridControl1.DefaultGridBorderStyle = GridBorderStyle.Solid;
            #endregion

            #region StyleObject Grid
            //change the header's BackColor
            gridControl2.BaseStylesMap["Header"].StyleInfo.BackColor     = Color.FromArgb(238, 240, 246);
            gridControl2.BaseStylesMap["Row Header"].StyleInfo.BackColor = Color.FromArgb(238, 240, 246);

            //add a new basestyle
            gridBaseStyle1 = new GridBaseStyle("BackColorTest", false);
            gridControl2.BaseStylesMap["BackColorTest"].StyleInfo.BackColor = Color.SkyBlue;


            #endregion
        }
Example #18
0
 /// <summary>
 /// Переводит значения значения Windows цвета в RGBA.
 /// </summary>
 /// <param name="Value"></param>
 /// <returns></returns>
 public static Int32 ToWin32(this Color Value)
 {
     return(ColorConvert.ToWin32(Value));
 }
Example #19
0
        public static void SetupGridModel(GridModel model)
        {
            GridFactoryProvider.Init(new GridCellModelFactory());
            model.Options.AlphaBlendSelectionColor = Color.FromArgb(64, SystemColors.Highlight);
            model.Options.AllowSelection           = GridSelectionFlags.Any;

            //model.BaseStylesMap.RegisterStandardStyles();
            model.CommandStack.Enabled      = true;
            model.QueryCellModel           += new GridQueryCellModelEventHandler(ModelQueryCellModel);
            model.OperationFeedbackListener = new DelayedStatusDialog(model);

            model.BeginInit();
            model.RowCount                          = 1000;
            model.ColCount                          = 100;
            model.Rows.DefaultSize                  = 19;
            model.Cols.DefaultSize                  = 65;
            model.RowHeights[0]                     = 21;
            model.ColWidths[0]                      = 35;
            model.ColWidths[3]                      = 85;
            model.Options.ControllerOptions         = GridControllerOptions.All;
            model.Options.DataObjectConsumerOptions = GridDataObjectConsumerOptions.All;


            GridStyleInfo standard  = model.BaseStylesMap["Standard"].StyleInfo;
            GridStyleInfo header    = model.BaseStylesMap["Header"].StyleInfo;
            GridStyleInfo rowHeader = model.BaseStylesMap["Row Header"].StyleInfo;
            GridStyleInfo colHeader = model.BaseStylesMap["Column Header"].StyleInfo;

            model.Properties.GridLineColor = Color.FromArgb(65, 57, 73, 122);

            GridFontInfo boldFont = new GridFontInfo();

            boldFont.Bold     = true;
            boldFont.Size     = 11;
            boldFont.Facename = "Helvetica";

            standard.TextColor = Color.FromArgb(0, 21, 84);

            GridStyleInfo boldFontStyle = new GridStyleInfo();

            boldFontStyle.TextColor = Color.FromArgb(238, 122, 3);
            boldFontStyle.Font      = boldFont;

            header.Interior    = new BrushInfo(GradientStyle.Vertical, Color.FromArgb(65, 238, 234, 216), Color.FromArgb(65, 203, 199, 184));
            rowHeader.Interior = new BrushInfo(GradientStyle.Horizontal, Color.FromArgb(65, 238, 234, 216), Color.FromArgb(65, 203, 199, 184));

            bool showImageList = false;

            if (showImageList)
            {
                ImageList imageList = new ImageList();
                imageList.Images.Add(SystemIcons.Warning.ToBitmap());
                imageList.Images.Add(SystemIcons.Application.ToBitmap());
                imageList.Images.Add(SystemIcons.Asterisk.ToBitmap());
                imageList.Images.Add(SystemIcons.Error.ToBitmap());
                imageList.Images.Add(SystemIcons.Exclamation.ToBitmap());
                imageList.Images.Add(SystemIcons.Hand.ToBitmap());
                imageList.Images.Add(SystemIcons.Information.ToBitmap());
                imageList.Images.Add(SystemIcons.Question.ToBitmap());
                standard.ImageList = imageList;
            }

            ArrayList USStates = new ArrayList();

            USStates.Add(new USState("Alabama", "AL", 0));
            USStates.Add(new USState("Washington", "WA", 1));
            USStates.Add(new USState("West Virginia", "WV", 2));
            USStates.Add(new USState("Wisconsin", "WI", 3));
            USStates.Add(new USState("Wyoming", "WY", 4));
            USStates.Add(new USState("XAlabama", "AAL", 5));
            USStates.Add(new USState("XWashington", "AWA", 6));
            USStates.Add(new USState("XWest Virginia", "AWV", 1));
            USStates.Add(new USState("XWisconsin", "AWI", 2));
            USStates.Add(new USState("XWyoming", "AWY", 3));
            USStates.Add(new USState("QAlabama", "BAL", 4));
            USStates.Add(new USState("QWashington", "BWA", 5));
            USStates.Add(new USState("QWest Virginia", "BWV", 6));
            USStates.Add(new USState("QWisconsin", "BWI", 0));
            USStates.Add(new USState("QWyoming", "BWY", 1));

            standard.DataSource    = USStates;
            standard.DisplayMember = "LongName";
            standard.ValueMember   = "ShortName";

            Type type = typeof(Bitmap);

            System.IO.Stream stream   = typeof(SampleGrid).Module.Assembly.GetManifestResourceStream(ApplicationMain.manifestNamespace + "logo_105_65.bmp");
            Bitmap           bm       = new Bitmap(stream);
            ImageList        logoList = new ImageList();

            logoList.Images.Add(bm);
            logoList.ImageSize  = bm.Size;
            logoList.ColorDepth = ColorDepth.Depth32Bit;

            int rowIndex = 2;
            int colIndex = 1;

            int boldfontRowHeight = 0;


            model.Options.FloatCellsMode = GridFloatCellsMode.OnDemandCalculation;


            model.CoveredRanges.Add(GridRangeInfo.Cells(2, 2, 4, 4));

            model[2, 2].Text                = "Grid Demo";
            model[2, 2].Font.Bold           = true;
            model[2, 2].Font.Size           = 16;
            model[2, 2].HorizontalAlignment = GridHorizontalAlignment.Center;
            model[2, 2].VerticalAlignment   = GridVerticalAlignment.Middle;
            model[2, 2].CellType            = "Static";
            model[2, 2].Borders.All         = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(65, 238, 122, 3));
            model[2, 2].Interior            = new BrushInfo(GradientStyle.PathEllipse, Color.FromArgb(65, 57, 73, 122), Color.FromArgb(65, 237, 240, 247));
            rowIndex += 5;

            model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            model[rowIndex, 1].Text = "Interior";
            model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle);
            model.RowHeights.ResizeToFit(GridRangeInfo.Cell(rowIndex, 1), GridResizeToFitOptions.ResizeCoveredCells | GridResizeToFitOptions.NoShrinkSize);
            boldfontRowHeight = model.RowHeights[rowIndex];
            rowIndex++;

            colIndex = 1;
            foreach (int index in new int[] {
                1,
                2,
                3,
                4,
                5,
                6,
            })
            {
                model[rowIndex, colIndex].ImageIndex = index;
                colIndex++;
            }
            rowIndex++;


            colIndex = 1;
            foreach (Color color1 in new Color[] {
                Color.FromArgb(65, 0, 0, 51),
                Color.FromArgb(65, 252, 172, 38),
                Color.FromArgb(65, 33, 67, 126),
                Color.FromArgb(65, 102, 110, 152),
                Color.FromArgb(65, 204, 212, 230),
                Color.FromArgb(65, 237, 240, 247),
            })
            {
                model[rowIndex, colIndex].Interior = new BrushInfo(color1);
                colIndex++;
            }

            rowIndex++;
            colIndex = 1;
            foreach (PatternStyle pattern in new PatternStyle[]
            {
                PatternStyle.Percent05,
                PatternStyle.Percent20,
                PatternStyle.Percent50,
                PatternStyle.Percent75,
                PatternStyle.DarkDownwardDiagonal,
                PatternStyle.LightDownwardDiagonal
            })
            {
                model[rowIndex, colIndex].Interior = new BrushInfo(pattern, Color.FromArgb(65, 237, 240, 247), Color.FromArgb(65, 57, 73, 122));
                colIndex++;
            }

            rowIndex++;
            colIndex = 1;
            foreach (GradientStyle gradient in new GradientStyle[]
            {
                GradientStyle.BackwardDiagonal,
                GradientStyle.ForwardDiagonal,
                GradientStyle.PathEllipse,
                GradientStyle.PathRectangle,
                GradientStyle.Vertical,
                GradientStyle.Horizontal,
            })
            {
                model[rowIndex, colIndex].Interior     = new BrushInfo(gradient, Color.FromArgb(65, 57, 73, 122), Color.FromArgb(65, 237, 240, 247));
                model[rowIndex + 1, colIndex].Interior = new BrushInfo(gradient, Color.FromArgb(65, 237, 240, 247), Color.FromArgb(65, 51, 51, 102));
                colIndex++;
            }

            rowIndex++;
            rowIndex++;
            rowIndex++;
            colIndex = 1;

            model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            model[rowIndex, 1].Text = "Font";
            model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle);
            model.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            foreach (int size in new int[]
            {
                6,
                7,
                8,
                10,
                12,
                14
            })
            {
                model[rowIndex, colIndex].Font.Size = size;
                model[rowIndex, colIndex].Text      = size.ToString();
                colIndex++;
            }
            model.RowHeights.ResizeToFit(GridRangeInfo.Row(rowIndex), GridResizeToFitOptions.ResizeCoveredCells | GridResizeToFitOptions.NoShrinkSize);

            rowIndex++;
            colIndex = 1;
            foreach (FontStyle fontStyle in new FontStyle[]
            {
                FontStyle.Bold,
                FontStyle.Italic,
                FontStyle.Regular,
                FontStyle.Strikeout,
                FontStyle.Underline,
                FontStyle.Bold | FontStyle.Italic | FontStyle.Regular,
            })
            {
                model[rowIndex, colIndex].Font.FontStyle = fontStyle;
                model[rowIndex, colIndex].Text           = Enum.Format(typeof(FontStyle), fontStyle, "G");
                colIndex++;
            }

            rowIndex++;
            rowIndex++;
            colIndex = 1;

            model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            model[rowIndex, 1].Text = "TextColor";
            model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle);
            model.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            colIndex = 1;
            foreach (Color color2 in new Color[] {
                Color.Black,
                Color.Red,
                Color.Blue,
                Color.Green,
                Color.Yellow,
                Color.DimGray
            })
            {
                model[rowIndex, colIndex].TextColor = color2;
                model[rowIndex, colIndex].Text      = ColorConvert.ColorToString(color2, true);
                colIndex++;
            }

            rowIndex++;
            rowIndex++;

            colIndex = 1;

            model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            model[rowIndex, 1].Text = "Number Formats";
            model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle);
            model.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            colIndex = 1;
            foreach (string format2 in new string[]
            {
                "0.00",
                "C",
                "0.00;(0.00)",
                "###0.##%",
                "#0.#E+00",
                "10:##,##0.#"
            })
            {
                model[rowIndex, colIndex].Format        = format2;
                model[rowIndex, colIndex].CellValue     = Math.PI;
                model[rowIndex, colIndex].CellValueType = typeof(double);
                colIndex++;
            }

            rowIndex++;
            rowIndex++;

            colIndex = 1;

            model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            model[rowIndex, 1].Text = "DateTime Formats";
            model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle);
            model.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            colIndex = 1;
            foreach (string format in new string[]
            {
                "d",
                "D",
                "f",
                "dddd, dd MMMM yyyy",
                "t",
                "s"
            })
            {
                model[rowIndex, colIndex].Format        = format;
                model[rowIndex, colIndex].CellValue     = DateTime.Now;
                model[rowIndex, colIndex].CellValueType = typeof(DateTime);
                colIndex++;
            }

            rowIndex++;
            rowIndex++;

            model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            model[rowIndex, 1].Text = "Validation";
            model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle);
            model.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            model[rowIndex, 1].Text = "Positive numbers";
            model.RowStyles[rowIndex].ValidateValue.NumberRequired = true;
            model.RowStyles[rowIndex].ValidateValue.Minimum        = 0;
            model.RowStyles[rowIndex].ValidateValue.Maximum        = float.NaN;
            model.RowStyles[rowIndex].ValidateValue.ErrorMessage   = "Please enter a number greater than 0!";
            rowIndex++;

            model[rowIndex, 1].Text = "Validation (1-100 valid range)";
            model.RowStyles[rowIndex].ValidateValue = new GridCellValidateValueInfo(true, 1, 100, "Please enter a number between 1 and 100!");
            rowIndex++;
            rowIndex++;

            model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            model[rowIndex, 1].Text = "Cell Types";
            model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle);
            model.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            colIndex = 1;

            model.TableStyle.CheckBoxOptions     = new GridCheckBoxCellInfo("True", "False", "", false);
            model[rowIndex, 1].Text              = "CheckBox";
            model[rowIndex, 3].CellType          = "CheckBox";
            model[rowIndex, 3].TriState          = false;
            model[rowIndex, 3].Text              = "True";
            model[rowIndex, 3].VerticalAlignment = GridVerticalAlignment.Middle;
            model[rowIndex, 3].Description       = "Enabled";
            model[rowIndex, 4].CellType          = "CheckBox";
            model[rowIndex, 4].Text              = "False";
            model[rowIndex, 4].Enabled           = false;
            model[rowIndex, 4].Description       = "Disabled";
            model[rowIndex, 4].VerticalAlignment = GridVerticalAlignment.Middle;
            model[rowIndex, 5].CellType          = "CheckBox";
            model[rowIndex, 5].TriState          = true;
            model[rowIndex, 5].Description       = "TriState";
            model[rowIndex, 5].VerticalAlignment = GridVerticalAlignment.Middle;
            rowIndex++;

            rowIndex++;
            rowIndex++;

            model[rowIndex, 1].Text     = "DragButton";
            model[rowIndex, 3].Text     = "Drag";
            model[rowIndex, 3].CellType = "DragButton";
            rowIndex++;

            model.TableStyle.NumericUpDown = new GridNumericUpDownCellInfo(0, 25, 1, 1, true);
            model[rowIndex, 1].Text        = "NumericUpDown";
            // Wrapping, Range 0-1000
            model[rowIndex, 3].CellType      = "NumericUpDown";
            model[rowIndex, 3].NumericUpDown = new GridNumericUpDownCellInfo(0, 1000, 0, 1, true);
            // Disabled
            model[rowIndex, 4].CellType = "NumericUpDown";
            model[rowIndex, 4].Enabled  = false;
            model[rowIndex, 4].Text     = "5";
            // No wrapping, Range 1-20
            model[rowIndex, 5].CellType      = "NumericUpDown";
            model[rowIndex, 5].NumericUpDown = new GridNumericUpDownCellInfo(1, 20, 1, 1, false);
            rowIndex++;

            model[rowIndex, 1].Text        = "PushButton";
            model[rowIndex, 3].CellType    = "PushButton";
            model[rowIndex, 3].Description = "Enabled";
            model[rowIndex, 4].CellType    = "PushButton";
            model[rowIndex, 4].Enabled     = false;
            model[rowIndex, 4].Clickable   = false;
            model[rowIndex, 4].Description = "Disabled";
            rowIndex++;

            StringCollection items = new StringCollection();

            items.Add("One");
            items.Add("Two");
            items.Add("Three");
            items.Add("Four");
            items.Add("Five");
            items.Add("Six");
            items.Add("Seven");
            items.Add("Eight");
            items.Add("Nine");
            items.Add("Ten");

            model[rowIndex, 1].Text = "ComboBox (Edit)";

            model[rowIndex, 3].CellType   = "ComboBox";
            model[rowIndex, 3].ChoiceList = items;
            // Disabled
            model[rowIndex, 4].CellType   = "ComboBox";
            model[rowIndex, 4].ChoiceList = items;
            model[rowIndex, 4].Enabled    = false;
            model[rowIndex, 4].CellValue  = items[5];
            rowIndex++;

            model[rowIndex, 1].Text = "ComboBox (List)";

            model[rowIndex, 3].CellType            = "ComboBox";
            model[rowIndex, 3].ChoiceList          = items;
            model[rowIndex, 3].ExclusiveChoiceList = true;              // tell combobox to behave like CBS_DROPDOWNSTYLE
            // Disabled
            model[rowIndex, 4].CellType            = "ComboBox";
            model[rowIndex, 4].ChoiceList          = items;
            model[rowIndex, 4].Enabled             = false;
            model[rowIndex, 4].ExclusiveChoiceList = true;              // tell combobox to behave like CBS_DROPDOWNSTYLE
            model[rowIndex, 4].CellValue           = items[5];
            rowIndex++;
            rowIndex++;

            model[rowIndex, 1].Text       = "GridListControl (Edit)";
            model[rowIndex, 3].CellType   = "GridListControl";
            model[rowIndex, 3].DataSource = USStates;

            // Disabled
            model[rowIndex, 4].CellType   = "GridListControl";
            model[rowIndex, 4].DataSource = USStates;
            rowIndex++;

            model[rowIndex, 1].Text = "GridListControl (List)";

            model[rowIndex, 3].CellType            = "GridListControl";
            model[rowIndex, 3].DataSource          = USStates;
            model[rowIndex, 3].ExclusiveChoiceList = true;              // tell combobox to behave like CBS_DROPDOWNSTYLE
            rowIndex++;
            rowIndex++;


            model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            model[rowIndex, 1].Text = "DropDown Cells";
            model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle);
            model.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            //
            model[rowIndex, 1].Text     = "Generic DropDown";
            model[rowIndex, 3].CellType = "DropDown";
            rowIndex++;

            model[rowIndex, 1].Text     = "MonthCalendar";
            model[rowIndex, 3].CellType = "MonthCalendar";
            rowIndex++;

            model[rowIndex, 1].Text     = "ColorEdit";
            model[rowIndex, 3].CellType = "ColorEdit";
            rowIndex++;

            model[rowIndex, 1].Text     = "DropDownGrid";
            model[rowIndex, 3].CellType = "DropDownGrid";
            rowIndex++;
            rowIndex++;

            colIndex = 1;

            model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            model[rowIndex, 1].Text = "Borders";
            model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle);
            model.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            foreach (GridBorder border2 in new GridBorder[] {
                new GridBorder(GridBorderStyle.Solid, Color.FromArgb(57, 73, 122)),
                new GridBorder(GridBorderStyle.Dotted, Color.FromArgb(238, 122, 3)),
                new GridBorder(GridBorderStyle.DashDot, Color.FromArgb(57, 73, 122)),
                new GridBorder(GridBorderStyle.DashDotDot, Color.FromArgb(238, 122, 3)),
                new GridBorder(GridBorderStyle.Dashed, Color.FromArgb(57, 73, 122), GridBorderWeight.Medium),
                new GridBorder(GridBorderStyle.Dotted, Color.FromArgb(238, 122, 3), GridBorderWeight.Medium),
            })
            {
                model[rowIndex, colIndex].Borders.Bottom = border2;
                model[rowIndex, colIndex].Borders.Right  = border2;
                model[rowIndex, colIndex].Text           = border2.ToString();
                colIndex++;
            }

            rowIndex++;
            colIndex = 1;
            foreach (GridBorder border in new GridBorder[] {
                new GridBorder(GridBorderStyle.Dashed, Color.FromArgb(57, 73, 122), GridBorderWeight.Thick),
                new GridBorder(GridBorderStyle.Dotted, Color.FromArgb(238, 122, 3), GridBorderWeight.Thick),
                new GridBorder(GridBorderStyle.DashDot, Color.FromArgb(57, 73, 122), GridBorderWeight.Medium),
                new GridBorder(GridBorderStyle.DashDotDot, Color.FromArgb(238, 122, 3), GridBorderWeight.Medium),
                new GridBorder(GridBorderStyle.Solid, Color.FromArgb(57, 73, 122), GridBorderWeight.Thick),
                new GridBorder(GridBorderStyle.Solid, Color.FromArgb(238, 122, 3), GridBorderWeight.Medium),
            })
            {
                model[rowIndex, colIndex].Borders.Bottom = border;
                model[rowIndex, colIndex].Borders.Right  = border;
                model[rowIndex, colIndex].Text           = border.ToString();
                colIndex++;
            }

            rowIndex++;
            rowIndex++;
            colIndex = 1;

            model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            model[rowIndex, 1].Text = "Orientation";
            model[rowIndex, 1].ModifyStyle(boldFontStyle, StyleModifyType.Override);
            model.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            foreach (int orientation in new int[]
            {
                0,
                45,
                60,
                90,
                180,
                -90
            })
            {
                GridStyleInfo style1 = model[rowIndex, colIndex];
                // style1 is a direct reference to model[rowIndex, colIndex];
                // changes will be propagated back to GridData
                style1.HorizontalAlignment = GridHorizontalAlignment.Center;
                style1.VerticalAlignment   = GridVerticalAlignment.Middle;
                GridFontInfo font = style1.Font;
                font.Orientation = orientation;
                font.Bold        = true;
                style1.Text      = "Angle = " + font.Orientation.ToString();
                colIndex++;
            }

            rowIndex++;
            rowIndex++;
            colIndex = 1;

            model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            model[rowIndex, 1].Text = "Enabled";
            model[rowIndex, 1].ModifyStyle(boldFontStyle, StyleModifyType.Override);
            model.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            foreach (bool enabled1 in new bool[]
            {
                true,
                false,
                true,
                false,
                false,
                true,
            })
            {
                model[rowIndex, colIndex].Text     = enabled1?"YES":"NO";
                model[rowIndex, colIndex].Interior = new BrushInfo((Color)(enabled1?Color.FromArgb(65, 57, 73, 122):Color.FromArgb(65, 238, 122, 3)));
                model[rowIndex, colIndex].Enabled  = enabled1;
                colIndex++;
            }

            colIndex = 1;
            rowIndex++;

            foreach (bool enabled2 in new bool[]
            {
                true,
                true,
                false,
                false,
                false,
                true,
            })
            {
                model[rowIndex, colIndex].Text     = enabled2?"YES":"NO";
                model[rowIndex, colIndex].Interior = new BrushInfo((Color)(enabled2?Color.FromArgb(65, 57, 73, 122):Color.FromArgb(65, 238, 122, 3)));
                model[rowIndex, colIndex].Enabled  = enabled2;
                colIndex++;
            }

            rowIndex++;
            rowIndex++;
            colIndex = 1;

            model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            model[rowIndex, 1].Text = "AutoSize";
            model[rowIndex, 1].ModifyStyle(boldFontStyle, StyleModifyType.Override);
            model.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            model.RowStyles[rowIndex].AutoSize = true;
            model.RowStyles[rowIndex].Text     = "Row height will increase while you type text";
            model.RowStyles[rowIndex].Interior = new BrushInfo(Color.Beige);

            rowIndex++;
            rowIndex++;
            colIndex = 1;

            model.CoveredRanges.Add(GridRangeInfo.Cells(rowIndex, 1, rowIndex, 2));
            model[rowIndex, 1].Text = "Read Only";
            model[rowIndex, 1].ModifyStyle(boldFontStyle, StyleModifyType.Override);
            model.RowHeights[rowIndex] = boldfontRowHeight;
            rowIndex++;

            model.RowStyles[rowIndex].ReadOnly = true;
            model.RowStyles[rowIndex].Interior = new BrushInfo(Color.LightGray);
            model.RowStyles[rowIndex].Text     = "ReadOnly";
            rowIndex++;
            rowIndex++;


            model.Options.ExcelLikeCurrentCell        = false;
            model.Options.ExcelLikeSelectionFrame     = false;
            model.Options.ActivateCurrentCellBehavior = GridCellActivateAction.ClickOnCell;
            model.Properties.MarkColHeader            = true;
            model.Properties.MarkRowHeader            = true;

            model.RowHeights.ResizeToFit(GridRangeInfo.Cells(2, 1, rowIndex, 3), GridResizeToFitOptions.ResizeCoveredCells | GridResizeToFitOptions.NoShrinkSize);
            model.EndInit();
        }
Example #20
0
        public static Texture GenerateFieldGradient(Color baseColor, Field field, int resolution = 8, bool vertical = true)
        {
            int width  = vertical ? 1 : resolution;
            int height = vertical ? resolution : 1;

            Texture2D texture = new Texture2D(width, height);

            texture.hideFlags = HideFlags.DontSave;
            texture.wrapMode  = TextureWrapMode.Clamp;

            //TODO: Use SetPixels instead of SetPixel, for better performance.
            baseColor.a = 1f;
            for (int i = 0; i < resolution; i++)
            {
                Color color = new Color();
                float perc  = i / (float)(resolution - 1);
                switch (field)
                {
                case Field.Red:
                    color = ColorConvert.ChangeRGB(baseColor, newR: perc);
                    break;

                case Field.Green:
                    color = ColorConvert.ChangeRGB(baseColor, newG: perc);
                    break;

                case Field.Blue:
                    color = ColorConvert.ChangeRGB(baseColor, newB: perc);
                    break;

                case Field.Alpha:
                    color = ColorConvert.ChangeRGB(baseColor, newA: perc);
                    break;

                case Field.Hue:
                    color = ColorConvert.ChangeHSV(baseColor, newH: perc);
                    break;

                case Field.HSV_Saturation:
                    color = ColorConvert.ChangeHSV(baseColor, newS: perc);
                    break;

                case Field.HSV_Value:
                    color = ColorConvert.ChangeHSV(baseColor, newV: perc);
                    break;

                case Field.HSL_Saturation:
                    color = ColorConvert.ChangeHSL(baseColor, newS: perc);
                    break;

                case Field.HSL_Lightness:
                    color = ColorConvert.ChangeHSL(baseColor, newL: perc);
                    break;
                }
                if (vertical)
                {
                    texture.SetPixel(0, i, color);
                }
                else
                {
                    texture.SetPixel(i, 0, color);
                }
            }

            texture.Apply();
            return(texture);
        }
Example #21
0
 /// <summary>
 /// Переводит значения цветовой модели RGBA в HSB.
 /// </summary>
 /// <param name="Value"></param>
 /// <returns></returns>
 public static (Int32 Hue, Double Saturation, Double Brightness) ToHsb(this Color Value)
 {
     return(ColorConvert.ToHsb(Value));
 }
Example #22
0
 /// <summary>
 /// Переводит значения цветовой модели RGBA в Hex.
 /// </summary>
 /// <param name="Value"></param>
 /// <exception cref="ArgumentException"></exception>
 /// <returns></returns>
 public static String ToHex(this Color Value)
 {
     return(ColorConvert.ToHex(Value));
 }
        private Traffic GetTerrain_CMD(string args)
        {
            ResponseType responseType = ResponseType.Failed;
            int          seed         = 0;
            int          width        = 0;
            int          height       = 0;
            IModule      module       = null;
            List <GradientPresets.GradientKeyData> gradient = new List <GradientPresets.GradientKeyData>();
            MapData      mdata;
            MessageTypes type = MessageTypes.None;

            string[] TextureFiles = new string[0];
            string   message      = string.Empty;

            if (_server.WorldLoaded)
            {
                if (_server.Users.SessionKeyExists(args))
                {
                    string         user    = _server.Users.GetConnectedUser(args).Name;
                    TerrainBuilder builder = _server.Worlds.CurrentWorld.Terrain;
                    responseType = ResponseType.Successfull;
                    seed         = builder.Seed;
                    width        = builder.Width;
                    height       = builder.Height;
                    module       = builder.NoiseModule;
                    gradient     = new List <GradientPresets.GradientKeyData>(builder.GradientPreset);
                    TextureFiles = new List <string>(GradientCreator.TextureFiles.Keys).ToArray();
                    message      = "success";

                    // make sure images are cleared. They will be sent seperatly.
                    for (int i = 0; i < gradient.Count; i++)
                    {
                        gradient[i].images.Clear();
                    }

                    mdata = new MapData(responseType, seed, width, height, gradient, TextureFiles, message);
                    string sendStr   = JsonConvert.SerializeObject(mdata);
                    string moduleStr = JsonConvert.SerializeObject(module, new JsonSerializerSettings {
                        TypeNameHandling = TypeNameHandling.All
                    });
                    _server.SockServ.Send(user, "setterrainmodule", moduleStr);
                    _server.SockServ.Send(user, "setterraindata", sendStr);


                    System.Threading.ManualResetEvent reset = new System.Threading.ManualResetEvent(false);
                    foreach (string imageName in GradientCreator.TextureFiles.Keys)
                    {
                        //reset.WaitOne(1);
                        Color[]       image       = ColorConvert.LibColList(GradientCreator.TextureFiles[imageName]);
                        ImageFileData imageStruct = new ImageFileData(imageName, image);
                        string        imageStr    = JsonConvert.SerializeObject(imageStruct);
                        _server.SockServ.Send(user, "setimage", imageStr);
                        //Logger.Log("sent image: {0}", imageName);
                    }
                    message = "success";
                    type    = MessageTypes.Success;
                    return(new Traffic("message", JsonConvert.SerializeObject(new Message("_server_", type, message))));
                }
                else
                {
                    message = "Invalid session key";
                    type    = MessageTypes.Not_Logged_in;
                    return(new Traffic("message", JsonConvert.SerializeObject(new Message("_server_", type, message))));
                }
            }
            message = "World not loaded";
            type    = MessageTypes.World_Not_Loaded;
            return(new Traffic("message", JsonConvert.SerializeObject(new Message("_server_", type, message))));
        }
Example #24
0
 /// <summary>
 /// Переводит значения цветовой модели RGBA в CMYK.
 /// </summary>
 /// <param name="Value"></param>
 /// <returns></returns>
 public static (Double Cyan, Double Magenta, Double Yellow, Double Key) ToCmyk(this Color Value)
 {
     return(ColorConvert.ToCmyk(Value));
 }
Example #25
0
        private void BindPayoffWay()
        {
            this.pnlPayoffWay.Controls.Clear();
            //support six buttons
            int space = 5;
            int px = 0, py = 0;
            int width  = (pnlPayoffWay.Width - 2 * space) / 3;
            int height = (pnlPayoffWay.Height - space) / 2;
            List <PayoffWay> payoffWayList = new List <PayoffWay>();

            foreach (PayoffWay item in ConstantValuePool.PayoffWayList)
            {
                if (item.AsVIPCardPayWay)
                {
                    payoffWayList.Add(item);
                }
            }
            int pageSize = 0;

            if (payoffWayList.Count > 6)
            {
                pageSize = 6;
            }
            else
            {
                pageSize = payoffWayList.Count;
            }
            for (int index = 0; index < pageSize; index++)
            {
                PayoffWay     payoff = payoffWayList[index];
                CrystalButton btn    = new CrystalButton();
                btn.Name      = payoff.PayoffID.ToString();
                btn.Text      = payoff.PayoffName;
                btn.Width     = width;
                btn.Height    = height;
                btn.BackColor = btn.DisplayColor = Color.Blue;
                btn.Font      = new Font("Microsoft YaHei", 12F, FontStyle.Regular);
                btn.ForeColor = Color.White;
                btn.Location  = new Point(px, py);
                foreach (ButtonStyle btnStyle in ConstantValuePool.ButtonStyleList)
                {
                    if (payoff.ButtonStyleID.Equals(btnStyle.ButtonStyleID))
                    {
                        float     emSize = (float)btnStyle.FontSize;
                        FontStyle style  = FontStyle.Regular;
                        btn.Font      = new Font(btnStyle.FontName, emSize, style);
                        btn.ForeColor = ColorConvert.RGB(btnStyle.ForeColor);
                        btn.BackColor = btn.DisplayColor = ColorConvert.RGB(btnStyle.BackColor);
                        break;
                    }
                }
                btn.Tag    = payoff;
                btn.Click += new System.EventHandler(this.btnPayoff_Click);
                pnlPayoffWay.Controls.Add(btn);
                px += width + space;
                if ((index + 1) % 3 == 0)
                {
                    px  = 0;
                    py += height + space;
                }
            }
        }
Example #26
0
        /// <summary>
        /// Преобразует структуру <see cref="Color"/> в удобную для восприятия строку.
        /// </summary>
        /// <param name="Value">Преобразуемый цвет</param>
        /// <param name="Model">Цветовая модель</param>
        /// <param name="CSS">Значение, указывающее будет ли отображаться CSS код</param>
        /// <returns></returns>
        public static String ToString(this Color Value, ColorModel Model, Boolean CSS = true)
        {
            if (CSS)
            {
                switch (Model)
                {
                case ColorModel.Html:
                    return(ColorConvert.ToHtml(Value));

                case ColorModel.Hex:
                    return(ColorConvert.ToHex(Value));

                case ColorModel.Rgb:
                    return($"rgb({Value.R}, {Value.G}, {Value.B})");

                case ColorModel.Rgba:
                    return($"rgba({Value.R}, {Value.G}, {Value.B}, {Math.Round((double)Value.A / 255, 2)})");

                case ColorModel.Hsb:
                    return($"{ColorConvert.ToHsb(Value).Hue}°, {ColorConvert.ToHsb(Value).Saturation * 100}%, {ColorConvert.ToHsb(Value).Brightness * 100}%");

                case ColorModel.Hsl:
                    return($"hsl({ColorConvert.ToHsla(Value).Hue}, {ColorConvert.ToHsla(Value).Saturation * 100}%, {ColorConvert.ToHsla(Value).Lightness * 100}%)");

                case ColorModel.Hsla:
                    return($"hsla({ColorConvert.ToHsla(Value).Hue}, {ColorConvert.ToHsla(Value).Saturation * 100}%, {ColorConvert.ToHsla(Value).Lightness * 100}%, {ColorConvert.ToHsla(Value).Alpha})");

                case ColorModel.Cmyk:
                    return($"{ColorConvert.ToCmyk(Value).Cyan}%, {ColorConvert.ToCmyk(Value).Magenta}%, {ColorConvert.ToCmyk(Value).Yellow}%, {ColorConvert.ToCmyk(Value).Key}%");

                default:
                    return(Value.ToString());
                }
            }
            else
            {
                switch (Model)
                {
                case ColorModel.Html:
                    return(ColorConvert.ToHtml(Value));

                case ColorModel.Hex:
                    return(ColorConvert.ToHex(Value));

                case ColorModel.Rgb:
                    return($"{Value.R}, {Value.G}, {Value.B}");

                case ColorModel.Rgba:
                    return($"{Value.R}, {Value.G}, {Value.B}, {Math.Round((double)Value.A / 255, 2)}");

                case ColorModel.Hsb:
                    return($"{ColorConvert.ToHsb(Value).Hue}°, {ColorConvert.ToHsb(Value).Saturation * 100}%, {ColorConvert.ToHsb(Value).Brightness * 100}%");

                case ColorModel.Hsl:
                    return($"{ColorConvert.ToHsla(Value).Hue}°, {ColorConvert.ToHsla(Value).Saturation * 100}%, {ColorConvert.ToHsla(Value).Lightness * 100}%");

                case ColorModel.Hsla:
                    return($"{ColorConvert.ToHsla(Value).Hue}°, {ColorConvert.ToHsla(Value).Saturation * 100}%, {ColorConvert.ToHsla(Value).Lightness * 100}%, {ColorConvert.ToHsla(Value).Alpha}");

                case ColorModel.Cmyk:
                    return($"{ColorConvert.ToCmyk(Value).Cyan}%, {ColorConvert.ToCmyk(Value).Magenta}%, {ColorConvert.ToCmyk(Value).Yellow}%, {ColorConvert.ToCmyk(Value).Key}%");

                default:
                    return(Value.ToString());
                }
            }
        }
Example #27
0
 /// <summary>
 /// Переводит значения цветовой модели RGBA в Ole.
 /// </summary>
 /// <param name="Value"></param>
 /// <returns></returns>
 public static Int32 ToOle(this Color Value)
 {
     return(ColorConvert.ToOle(Value));
 }
Example #28
0
 private void SetHSV(HSVValues hsv)
 {
     SetRGB(ColorConvert.HSVtoRGB(hsv));
 }