public override void Draw(System.Drawing.Graphics gr, System.Drawing.Point position, FastColoredTextBoxNS.Range range)
        {
            base.Draw(gr, position, range);
            const int size = 2;
            var end = Math.Max(((range.End.iChar - range.Start.iChar) * range.tb.CharWidth) / size, size);

            position.Offset(0, range.tb.CharHeight - size);

            for (int i = 0; i < end; i++)
            {
                var start = position;
                position.Offset(size, size * (int)Math.Pow(-1, i));
                gr.DrawLine(_pen, start, position);
            }
        }
Esempio n. 2
0
            public override void DrawColLabel(System.Drawing.Graphics g, System.Drawing.Rectangle rect, string sDay)
            {
                StringFormat m_Format = new StringFormat();
                m_Format.Alignment = StringAlignment.Center;
                m_Format.FormatFlags = StringFormatFlags.NoWrap;
                m_Format.LineAlignment = StringAlignment.Center;

                if(HasVerticalLine)
                {
                    using (Pen aPen = new Pen(HeaderTitleSplitLineColor))
                        g.DrawLine(aPen, rect.Right, rect.Top, rect.Right, rect.Bottom);
                }

                rect.Offset(2, 1);

                g.DrawString(sDay, HeaderTitleFont, SystemBrushes.WindowText, rect, m_Format);
            }
        public override void DrawDayHeader(System.Drawing.Graphics g, System.Drawing.Rectangle rect, DateTime date)
        {
            if (g == null)
                throw new ArgumentNullException("g");

            using (StringFormat format = new StringFormat())
            {
                format.Alignment = StringAlignment.Center;
                format.FormatFlags = StringFormatFlags.NoWrap;
                format.LineAlignment = StringAlignment.Center;

                using (StringFormat formatdd = new StringFormat())
                {
                    formatdd.Alignment = StringAlignment.Near;
                    formatdd.FormatFlags = StringFormatFlags.NoWrap;
                    formatdd.LineAlignment = StringAlignment.Center;

                    using (SolidBrush brush = new SolidBrush(this.BackColor))
                        g.FillRectangle(brush, rect);

                    using (Pen aPen = new Pen(Color.FromArgb(205, 219, 238)))
                        g.DrawLine(aPen, rect.Left, rect.Top + (int)rect.Height / 2, rect.Right, rect.Top + (int)rect.Height / 2);

                    using (Pen aPen = new Pen(Color.FromArgb(141, 174, 217)))
                        g.DrawRectangle(aPen, rect);

                    rect.X += 1;
                    rect.Width -= 1;
                    using (Pen aPen = new Pen(Color.FromArgb(141, 174, 217)))
                        g.DrawRectangle(aPen, rect);

                    Rectangle topPart = new Rectangle(rect.Left + 1, rect.Top + 1, rect.Width - 2, (int)(rect.Height / 2) - 1);
                    Rectangle lowPart = new Rectangle(rect.Left + 1, rect.Top + (int)(rect.Height / 2) + 1, rect.Width - 1, (int)(rect.Height / 2) - 1);

                    using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(228, 236, 246), Color.FromArgb(214, 226, 241), LinearGradientMode.Vertical))
                        g.FillRectangle(aGB, topPart);

                    using (LinearGradientBrush aGB = new LinearGradientBrush(lowPart, Color.FromArgb(194, 212, 235), Color.FromArgb(208, 222, 239), LinearGradientMode.Vertical))
                        g.FillRectangle(aGB, lowPart);

                    if (date.Date.Equals(DateTime.Now.Date))
                    {
                        topPart.Inflate((int)(-topPart.Width / 4 + 1), 1); //top left orange area
                        topPart.Offset(rect.Left - topPart.Left + 1, 1);
                        topPart.Inflate(1, 0);
                        using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(247, 207, 114), Color.FromArgb(251, 230, 148), LinearGradientMode.Horizontal))
                        {
                            topPart.Inflate(-1, 0);
                            g.FillRectangle(aGB, topPart);
                        }

                        topPart.Offset(rect.Right - topPart.Right, 0);        //top right orange
                        topPart.Inflate(1, 0);
                        using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(251, 230, 148), Color.FromArgb(247, 207, 114), LinearGradientMode.Horizontal))
                        {
                            topPart.Inflate(-1, 0);
                            g.FillRectangle(aGB, topPart);
                        }

                        using (Pen aPen = new Pen(Color.FromArgb(128, 240, 154, 30))) //center line
                            g.DrawLine(aPen, rect.Left, topPart.Bottom - 1, rect.Right, topPart.Bottom - 1);

                        topPart.Inflate(0, -1);
                        topPart.Offset(0, topPart.Height + 1); //lower right
                        using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(240, 157, 33), Color.FromArgb(250, 226, 142), LinearGradientMode.BackwardDiagonal))
                            g.FillRectangle(aGB, topPart);

                        topPart.Offset(rect.Left - topPart.Left + 1, 0); //lower left
                        using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(240, 157, 33), Color.FromArgb(250, 226, 142), LinearGradientMode.ForwardDiagonal))
                            g.FillRectangle(aGB, topPart);
                        using (Pen aPen = new Pen(Color.FromArgb(238, 147, 17)))
                            g.DrawRectangle(aPen, rect);
                    }

                    g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

                    //get short dayabbr. if narrow dayrect
                    string sTodaysName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(date.DayOfWeek);
                    if (rect.Width < 105)
                        sTodaysName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(date.DayOfWeek);

                    rect.Offset(2, 1);

                    using (Font fntDay = new Font("Segoe UI", 8))
                        g.DrawString(sTodaysName, fntDay, SystemBrushes.WindowText, rect, format);

                    rect.Offset(-2, -1);

                    using (Font fntDayDate = new Font("Segoe UI", 9, FontStyle.Bold))
                        g.DrawString(date.ToString(" d"), fntDayDate, SystemBrushes.WindowText, rect, formatdd);
                }
            }
        }
        private System.Windows.Point ScreenToCanvasPosition(System.Windows.Point screenPoint)
        {
            // We won't attempt to offset the cursor position when it falls within the 
            // line number column. The relative offset of mouse only matters when the 
            // cursor is actually within the source code region.
            // 
            double horzOffset = 0;
            if (screenPoint.X > Configurations.LineNumberColumnEnd)
                horzOffset = textCanvas.FirstVisibleColumn * Configurations.FormatFontWidth;

            screenPoint.Offset(horzOffset, textCanvas.FirstVisibleLine * Configurations.FontDisplayHeight);
            return screenPoint;
        }
Esempio n. 5
0
        /// <summary>Draw a rectangle</summary>
        public void DrawRectangle(System.Drawing.Rectangle rect, ColorValue color)
        {
            // Offset the rectangle
            rect.Offset(dialogX, dialogY);

            // If caption is enabled, offset the Y position by its height
            if (hasCaption)
                rect.Offset(0, captionHeight);

            // Get the integer value of the color
            int realColor = color.ToArgb();
            // Create some vertices
            CustomVertex.TransformedColoredTextured[] verts = {
                new CustomVertex.TransformedColoredTextured((float)rect.Left - 0.5f, (float)rect.Top -0.5f, 0.5f, 1.0f, realColor, 0, 0),
                new CustomVertex.TransformedColoredTextured((float)rect.Right - 0.5f, (float)rect.Top -0.5f, 0.5f, 1.0f, realColor, 0, 0),
                new CustomVertex.TransformedColoredTextured((float)rect.Right - 0.5f, (float)rect.Bottom -0.5f, 0.5f, 1.0f, realColor, 0, 0),
                new CustomVertex.TransformedColoredTextured((float)rect.Left - 0.5f, (float)rect.Bottom -0.5f, 0.5f, 1.0f, realColor, 0, 0),
            };

            // Get the device
            Device device = SampleFramework.Device;

            // Since we're doing our own drawing here, we need to flush the sprites
            DialogResourceManager.GetGlobalInstance().Sprite.Flush();
            // Preserve the devices current vertex declaration
            using (VertexDeclaration decl = device.VertexDeclaration)
            {
                // Set the vertex format
                device.VertexFormat = CustomVertex.TransformedColoredTextured.Format;

                // Set some texture states
                device.TextureState[0].ColorOperation = TextureOperation.SelectArg2;
                device.TextureState[0].AlphaOperation = TextureOperation.SelectArg2;

                // Draw the rectangle
                device.DrawUserPrimitives(PrimitiveType.TriangleFan, 2, verts);

                // Reset some texture states
                device.TextureState[0].ColorOperation = TextureOperation.Modulate;
                device.TextureState[0].AlphaOperation = TextureOperation.Modulate;

                // Restore the vertex declaration
                device.VertexDeclaration = decl;
            }
        }
Esempio n. 6
0
            /// <summary>
            /// The real work of drawing the tree is done in this method
            /// </summary>
            /// <param name="g"></param>
            /// <param name="r"></param>
            public override void Render(System.Drawing.Graphics g, System.Drawing.Rectangle r) {
                this.DrawBackground(g, r);

                Branch br = this.Branch;

                if (this.IsShowLines)
                    this.DrawLines(g, r, this.LinePen, br);

                if (br.CanExpand) {
                    Rectangle r2 = r;
                    r2.Offset((br.Level - 1) * PIXELS_PER_LEVEL, 0);
                    r2.Width = PIXELS_PER_LEVEL;

                    this.DrawExpansionGlyph(g, r2, br.IsExpanded);
                }

                int indent = br.Level * PIXELS_PER_LEVEL;
                r.Offset(indent, 0);
                r.Width -= indent;

                this.DrawImageAndText(g, r);
            }
        protected override void Edit(System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible)
        {
            try
            {
                bool enabled = true;

                if(CheckCellEnabled != null)
                {
                    DataGridEnableEventArgs et = new DataGridEnableEventArgs(rowNum, _col, enabled);
                    CheckCellEnabled(this, et);
                    enabled = et.EnableValue;
                }

                if(enabled)
                {
                    base.Edit(source,rowNum, bounds, readOnly, instantText , cellIsVisible);

                    _rowNum = rowNum;
                    _source = source;

                    bounds.Offset(xMargin,yMargin);
                    bounds.Width -= xMargin * 2;
                    bounds.Height -= yMargin;

                    this.TextBox.TabStop = true;
                    ColumnComboBox.Bounds = bounds;
                    ColumnComboBox.TabStop = true;
                    ColumnComboBox.Enabled = true;
                    ColumnComboBox.Parent = this.TextBox.Parent;
                    Rectangle rect = this.DataGridTableStyle.DataGrid.GetCurrentCellBounds();
                    ColumnComboBox.Location = rect.Location;
                    ColumnComboBox.Size = new Size(this.TextBox.Size.Width, ColumnComboBox.Size.Height);
                    //ColumnComboBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
                    ColumnComboBox.SelectedIndex = ColumnComboBox.FindStringExact(this.TextBox.Text);
                    ColumnComboBox.Text =  this.TextBox.Text;
                    this.TextBox.Visible = false;
                    ColumnComboBox.Visible = true;

                    ColumnComboBox.ReadOnly = this.TextBox.ReadOnly;

                    this.DataGridTableStyle.DataGrid.Scroll += new EventHandler(HandleScroll);

                    ColumnComboBox.BringToFront();
                    ColumnComboBox.Focus();
                }
                else
                {
                    ColumnComboBox.Enabled = false;
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message + " - " + ex.Source);
            }
        }
        public override void DrawDayHeader(System.Drawing.Graphics g, System.Drawing.Rectangle rect, DateTime date)
        {
            if (g == null)
                throw new ArgumentNullException("g");

            System.Drawing.Rectangle rHeader = rect;
            rHeader.Height += 2;

            if (date.Date.Equals(DateTime.Now.Date))
            {
                rHeader.Width += 1;
                HeaderHot.DrawBackground(g, rHeader);
            }
            else
            {
                rHeader.X += 1;
                HeaderNormal.DrawBackground(g, rHeader);
            }

            using (StringFormat format = new StringFormat())
            {
                format.Alignment = StringAlignment.Center;
                format.FormatFlags = StringFormatFlags.NoWrap;
                format.LineAlignment = StringAlignment.Center;

                using (StringFormat formatdd = new StringFormat())
                {
                    formatdd.Alignment = StringAlignment.Near;
                    formatdd.FormatFlags = StringFormatFlags.NoWrap;
                    formatdd.LineAlignment = StringAlignment.Center;

                    g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

                    //get short dayabbr. if narrow dayrect
                    string sTodaysName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(date.DayOfWeek);
                    if (rect.Width < 105)
                        sTodaysName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(date.DayOfWeek);

                    rect.Offset(2, 1);

                    using (Font fntDay = new Font("Tahoma", 8))
                        g.DrawString(sTodaysName, fntDay, SystemBrushes.WindowText, rect, format);

                    rect.Offset(-2, -1);

                    using (Font fntDayDate = new Font("Tahoma", 9, FontStyle.Bold))
                        g.DrawString(date.ToString(" d"), fntDayDate, SystemBrushes.WindowText, rect, formatdd);
                }
            }
        }
    SquareFromCenterAndHalfWidth
    (
        System.Windows.Point center,
        Double halfWidth
    )
    {
        Debug.Assert(halfWidth >= 0);

        center.Offset(-halfWidth, -halfWidth);
        Double dWidth = 2 * halfWidth;

        return ( new System.Windows.Rect( center,
            new System.Windows.Size(dWidth, dWidth) ) );
    }
Esempio n. 10
0
            public override void DrawRowLabel(System.Drawing.Graphics g, System.Drawing.Rectangle rect, String sLabel)
            {
                StringFormat m_Format = new StringFormat();
                m_Format.Alignment = StringAlignment.Center;
                m_Format.FormatFlags = StringFormatFlags.NoWrap;
                m_Format.LineAlignment = StringAlignment.Center;

                Rectangle r = rect;
                r.Inflate(1,1);

                if (HeaderBgGradient)
                {
                    using (LinearGradientBrush aGB = new LinearGradientBrush(rect, HeaderBgColor, HeaderBgColor2, LinearGradientMode.ForwardDiagonal))
                        g.FillRectangle(aGB, r);
                }
                else
                {
                    using (SolidBrush backBrush = new SolidBrush(HeaderBgColor))
                        g.FillRectangle(backBrush, r);
                }

                using (Pen backBrush = new Pen(HorisontalLineColor))
                {
                    g.DrawLine(backBrush, rect.Left, rect.Bottom, rect.Right, rect.Bottom);
                }

                rect.Offset(2, 1);

                g.DrawString(sLabel, WeekLabelFont, SystemBrushes.WindowText, rect, m_Format);
            }
Esempio n. 11
0
            public override void DrawCell(System.Drawing.Graphics g, System.Drawing.Rectangle rect, CellInfo ci)
            {
                StringFormat m_fTitle = new StringFormat();
                m_fTitle.Alignment = StringAlignment.Center;
                m_fTitle.FormatFlags = StringFormatFlags.FitBlackBox;
                m_fTitle.LineAlignment = StringAlignment.Center;

                StringFormat m_fTip = new StringFormat();
                m_fTip.Alignment = StringAlignment.Near;

                g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

                Color bg = MonthColorMap[ci.date.Month];
                if (ci.bCurMonth)
                {
                    bg = MonthColorMap[0];
                }

                using (SolidBrush backBrush = new SolidBrush(bg))
                    g.FillRectangle(backBrush, rect);

                using (Pen vLineClr = new Pen(VerticalLineColor))
                {
                    g.DrawLine(vLineClr, rect.Left, rect.Top, rect.Left, rect.Bottom);
                }

                using (Pen hLineClr = new Pen(HorisontalLineColor))
                {
                    g.DrawLine(hLineClr, rect.Left, rect.Bottom, rect.Right, rect.Bottom);
                }

                Rectangle rTitle = rect;
                rTitle.Offset(2, 1);

                Rectangle rText = rect;
                rText.Offset(2, 1);

                Size textSize = g.MeasureString(ci.sTitle, CellDataBoldFont, rTitle.Width).ToSize();
                rTitle.Height = textSize.Height;
                rText.Height -= textSize.Height;
                rText.Y += textSize.Height;

                rect.Inflate(1, 1);
                rect.Offset(1, 0);

                Brush bText = SystemBrushes.WindowText;
                if (ci.bSelected)
                {
                    using (SolidBrush backBrush = new SolidBrush(SelectionColor))
                        g.FillRectangle(backBrush, rect);

                    using (Pen borderPen = new Pen(SelectionBorderColor))
                        g.DrawRectangle(borderPen, rect);

                    bText = SystemBrushes.HighlightText;
                }

                g.DrawString(ci.sTitle, CellDataBoldFont, bText, rTitle, m_fTitle);
                g.DrawString(ci.sTip, CellDataFont, bText, rText, m_fTip);

                g.TextRenderingHint = TextRenderingHint.SystemDefault;
            }