Ejemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Rectangle rect = new Rectangle(e.ClipRectangle.X, e.ClipRectangle.Y + 1, e.ClipRectangle.Width - 32, e.ClipRectangle.Height - 2);

            rect.Offset(30, 0);
            if (Selected)
            {
                e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(184, 191, 211)), rect);
                DefaultGroupGUI.DrawHeaderContent(Text, e.Graphics, Font, rect, false, SystemBrushes.HighlightText);
                //DataGridParameterView.DrawHeaderContent(((ToolStripItem)sender).Text, e.Graphics, ((ToolStripItem)sender).Font, rect, false, SystemBrushes.HighlightText);
            }
            else
            {
                e.Graphics.FillRectangle(new SolidBrush(System.Drawing.Color.WhiteSmoke), rect);
                DefaultGroupGUI.DrawHeaderContent(Text, e.Graphics, Font, rect, false, SystemBrushes.ControlText);
            }
        }
Ejemplo n.º 2
0
        private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }
            ListBoxParameterItem item = (ListBoxParameterItem)((ListBox)sender).Items[e.Index];
            IParameter           p = item.parameter;
            string compId, doc, group, spectrumName;

            //string info = DefaultGroupGUI.getParameterInfo(p, out compId);
            Evel.engine.ProjectBase.getParameterInfo(p, out doc, out group, out compId);
            ParameterLocation location = project.GetParameterLocation(p);

            compId       = (location.compId + 1).ToString();
            spectrumName = (p.ReferenceGroup > 0) ? String.Format("{0} ref{1}", project.Containers[location.docId].Spectra[location.specId].Name, p.ReferenceGroup) : "";
            doc          = (sender == lbBinding) ? project.Containers[location.docId].Name : "";
            group        = project.Containers[location.docId].Spectra[location.specId].Parameters[location.groupId].Definition.name;

            string s = DefaultGroupGUI.BuildFormatedString(p.Definition.Header, DefaultGroupGUI.StringFormatTarget.ParameterDataGrid, compId, group, doc, spectrumName);

            //if (sender == lbBinding)
            //    s = DefaultGroupGUI.BuildFormatedString(p.Definition.Header, DefaultGroupGUI.StringFormatTarget.ParameterDataGrid, compId, group, doc);
            //else
            //    s = DefaultGroupGUI.BuildFormatedString(p.Definition.Header, DefaultGroupGUI.StringFormatTarget.ParameterDataGrid, compId, group);
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                if (item.inBinding && sender != lbBinding)
                {
                    e.Graphics.FillRectangle((e.Index % 2 == 0) ? regWindowBrush : altWindowBrush, e.Bounds);
                    e.Graphics.DrawRectangle(SystemPens.Highlight, new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width - 1, e.Bounds.Height - 1));
                }
                else
                {
                    e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
                }
                DefaultGroupGUI.DrawHeaderContent(s, e.Graphics, e.Font, e.Bounds, false, (item.inBinding && sender != lbBinding) ? SystemBrushes.InactiveCaptionText : SystemBrushes.HighlightText);
            }
            else
            {
                e.Graphics.FillRectangle((e.Index % 2 == 0) ? regWindowBrush : altWindowBrush, e.Bounds);
                DefaultGroupGUI.DrawHeaderContent(s, e.Graphics, e.Font, e.Bounds, false, (item.inBinding && sender != lbBinding) ? SystemBrushes.InactiveCaptionText : SystemBrushes.WindowText);
            }
        }
Ejemplo n.º 3
0
        void parameterSelector_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index == -1)
            {
                return;
            }
            e.DrawBackground();
            ComboBox comboBox = (ComboBox)sender;

            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            string item;

            if (comboBox.Items[e.Index] is ParameterDefinition)
            {
                item = ((ParameterDefinition)comboBox.Items[e.Index]).Header;
            }
            else
            {
                item = comboBox.Items[e.Index].ToString();
            }
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                DefaultGroupGUI.DrawHeaderContent(

                    item,
                    //comboBox.GetItemText(comboBox.Items[e.Index]),
                    e.Graphics,
                    e.Font,
                    e.Bounds,
                    false, SystemBrushes.HighlightText);
            }
            else
            {
                DefaultGroupGUI.DrawHeaderContent(
                    item,
                    //comboBox.GetItemText(comboBox.Items[e.Index]),
                    e.Graphics,
                    e.Font,
                    e.Bounds,
                    false, SystemBrushes.WindowText);
            }
        }
Ejemplo n.º 4
0
        //public static void DrawHeaderContent(string s, Graphics g, Font font, Rectangle rect, bool center, Brush brush) {
        //    //if (e.Value == null) return;
        //    string[] subs = s.Split(new char[] { '\0' }); //, StringSplitOptions.RemoveEmptyEntries);
        //    int[] xOffset = new int[subs.Length];
        //    int[] yOffset = new int[subs.Length];
        //    Font[] fonts = new Font[subs.Length];
        //    int stringWidth = 0;
        //    int topPadding = 3;
        //    for (int i = 0; i < subs.Length; i++) {
        //        //switch (subs[i][0]) {
        //        if (subs[i].IndexOf("greek:") == 0) {
        //            //case '@':
        //            subs[i] = subs[i].Substring(6);
        //            fonts[i] = new Font("Symbol", font.Size, FontStyle.Bold);
        //            yOffset[i] = topPadding;
        //        } else {
        //            if (subs[i].IndexOf("sub:") == 0) {
        //                subs[i] = subs[i].Substring(4);
        //                fonts[i] = (i == 0) ? font : new Font(font.FontFamily, font.Size - 2, FontStyle.Bold);
        //                yOffset[i] = topPadding + 5;
        //            } else {
        //                yOffset[i] = topPadding;
        //                fonts[i] = new Font(font, FontStyle.Bold);
        //            }
        //        }

        //        xOffset[i] = stringWidth - i * 2;
        //        stringWidth += (int)g.MeasureString(subs[i], fonts[i], 1000, new StringFormat(StringFormatFlags.MeasureTrailingSpaces)).Width;
        //    }
        //    int x0;
        //    if (center) {
        //        x0 = rect.Left + (rect.Width - stringWidth) / 2;
        //    } else {
        //        x0 = rect.Left;
        //    }
        //    g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
        //    for (int i = 0; i < subs.Length; i++) {
        //        //g.DrawString(subs[i], fonts[i], brush, x0 + xOffset[i], rect.Top + yOffset[i]);
        //        g.DrawString("R", SystemFonts.CaptionFont, SystemBrushes.ControlText, x0 + xOffset[i], rect.Top + yOffset[i]);
        //    }
        //}

        protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e)
        {
            if (e.ColumnIndex == -1)
            {
                return;
            }
            //e.Graphics.SmoothingMode = SmoothingMode.HighSpeed;
            //headers
            if ((e.RowIndex == -1) || this[e.ColumnIndex, e.RowIndex].FormattedValue.ToString().Contains("[p"))
            {
                e.Paint(e.ClipBounds, DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.Border | DataGridViewPaintParts.Background);
                DefaultGroupGUI.DrawHeaderContent(e.Value.ToString(), e.Graphics, e.CellStyle.Font, e.CellBounds, e.CellStyle.Alignment == DataGridViewContentAlignment.MiddleCenter, Brushes.Black);
                e.Handled = true;
            }
            else
            {
                if (this[e.ColumnIndex, e.RowIndex] is DataGridViewParameterCell)
                {
                    DataGridViewParameterCell cell = (DataGridViewParameterCell)this[e.ColumnIndex, e.RowIndex];
                    if ((cell.Parameter.Definition.Properties & ParameterProperties.KeyValue) == 0)
                    {
                        Rectangle newRect = new Rectangle(e.CellBounds.X,
                                                          e.CellBounds.Y, e.CellBounds.Width - 2,
                                                          e.CellBounds.Height - 2);
                        Color backColor;
                        //if (cell.Parameter.Expression != null) {
                        //    backColor = SystemColors.ButtonFace;
                        //} else {
                        if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected)
                        {
                            backColor = System.Drawing.SystemColors.Highlight;
                        }
                        else
                        {
                            backColor = (cell.ReadOnly) ? readonlyColor : e.CellStyle.BackColor;
                        }
                        //}
                        using (
                            Brush gridBrush = new SolidBrush(GridColor),
                            backColorBrush = new SolidBrush(backColor)) {
                            IParameter referencedParameter = (cell.Parameter.HasReferenceValue) ? cell.Parameter.ReferencedParameter : cell.Parameter;
                            using (Pen gridLinePen = new Pen(gridBrush), rectPen = new Pen(MainForm.GetColor(referencedParameter.Status))) {
                                // Erase the cell.
                                e.Graphics.FillRectangle(backColorBrush, newRect);

                                //if partially referenced parameter draw a reference sign
                                if (cell.Parameter.ReferenceGroup > 0)
                                {
                                    e.Graphics.FillRectangle(ReferenceBrushes[(cell.Parameter.ReferenceGroup - 1) % ReferenceBrushes.Length],
                                                             newRect.Right - 6,
                                                             newRect.Top + 3,
                                                             4,
                                                             newRect.Height - 5);
                                }

                                //min max lines
                                if (!cell.Parameter.HasReferenceValue)
                                {
                                    if (!double.IsPositiveInfinity(cell.Parameter.Maximum))
                                    {
                                        e.Graphics.DrawLine(Pens.Black,
                                                            newRect.Left + 3, newRect.Top + 3, newRect.Right - 3, newRect.Top + 3);
                                    }
                                    if (!double.IsNegativeInfinity(cell.Parameter.Minimum))
                                    {
                                        e.Graphics.DrawLine(Pens.Black,
                                                            newRect.Left + 3, newRect.Bottom - 3, newRect.Right - 3, newRect.Bottom - 3);
                                    }
                                }
                                // Draw the grid lines (only the right and bottom lines;
                                // DataGridView takes care of the others).
                                e.Graphics.DrawLine(Pens.White, e.CellBounds.Left,
                                                    e.CellBounds.Bottom - 1, e.CellBounds.Right - 1,
                                                    e.CellBounds.Bottom - 1);
                                e.Graphics.DrawLine(Pens.White, e.CellBounds.Right - 1,
                                                    e.CellBounds.Top, e.CellBounds.Right - 1,
                                                    e.CellBounds.Bottom);

                                // Draw the inset highlight box.
                                e.Graphics.DrawRectangle(rectPen, newRect);

                                // Draw the text content of the cell
                                e.PaintContent(e.CellBounds);
                                e.Handled = true;
                            }
                        }
                    }
                }
            }
        }