Beispiel #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            AdjustSize();
            var ed = GetEditor();

            if (ed.Width != PreferredEditorWidth || editor.Buffer == null)
            {
                Visible = false;
                return;
            }

            var g = e.Graphics;

            //e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            var bounds = ClientRectangle;
            var cs     = editor.Theme.GetStyle(StandardStyle.CommandBar);
            var acs    = editor.Theme.GetStyle(StandardStyle.CommandBarCaption);

            g.FillRectangle(cs.BackColor.Brush(), bounds);
            var shift = Dpi.GetHeight(2);
            var rect  = new Rectangle(ed.Left - editor.Info.SmallCharWidth, shift,
                                      ed.Width + editor.Info.SmallCharWidth * 2, bounds.Height - shift * 2);

            g.FillRectangle(ed.BackColor.Brush(), rect);

            var ds = editor.Theme.GetStyle(StandardStyle.Default);

            g.FillRectangle(ControlPaint.Dark(ds.BackColor, .05f).Brush(),
                            new RectangleF(bounds.X, bounds.Y + bounds.Height - BorderHeight, bounds.Width, BorderHeight));
        }
Beispiel #2
0
        private void MarkOccurences(Graphics g, Style hl, Rectangle bounds, IEnumerable <SearchResult> seq)
        {
            var markHeight = bounds.Height / Editor.Lines.Count;
            var min        = Dpi.GetHeight(6);

            markHeight = markHeight < min ? min : markHeight;
            var lastLine = -1;

            foreach (var f in seq)
            {
                if (f.Line == lastLine)
                {
                    continue;
                }

                var linePos = f.Line / (Editor.Lines.Count / 100f);
                var markY   = Editor.Info.TextTop + linePos * (bounds.Height / 100f);
                var w       = Dpi.GetWidth(5);

                g.FillRectangle((hl.AdornmentColor.IsEmpty ? hl.BackColor : hl.AdornmentColor).Brush(), new RectangleF(
                                    bounds.X + (bounds.Width - w) / 2f,
                                    markY,
                                    w,
                                    Dpi.GetHeight(markHeight)));
                lastLine = f.Line;
            }
        }
Beispiel #3
0
        private void ShowTip()
        {
            lastTipClientWidth = ClientSize.Width;
            var  font   = ((IView)FindForm()).Settings.Get <EnvironmentSettings>().Font;
            var  eWidth = editor.Info.TextWidth / 2;
            Size size;
            var  err = "M " + error;

            error = null;

            using (var g = CreateGraphics())
                size = g.MeasureString(err, font, eWidth).ToSize();

            var ovl  = GetMessageOverlay();
            var xpad = Dpi.GetWidth(8);
            var ypad = Dpi.GetHeight(4);

            ovl.Padding  = new Padding(xpad, ypad, xpad, ypad);
            ovl.Width    = size.Width + xpad * 2 + ovl.BorderWidth * 2;
            ovl.Height   = size.Height + ypad * 2 + ovl.BorderWidth * 2;
            ovl.Location = new Point(FindForm().ClientRectangle.Width - ovl.Width, ClientSize.Height + editor.Info.TextTop);
            ovl.Font     = font;
            ovl.Text     = err;
            ovl.Visible  = true;
        }
Beispiel #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            var view   = App.Component <IViewManager>().ActiveView;
            var theme  = App.Component <ITheme>();
            var bag    = view.Settings.Get <EnvironmentSettings>();
            var style  = theme.GetStyle(StandardStyle.Popup);
            var style1 = theme.GetStyle(StandardStyle.PopupSelected);
            var style2 = theme.GetStyle(StandardStyle.PopupBorder);

            var g = e.Graphics;

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            var xPad   = Dpi.GetHeight(3);
            var yPad   = Dpi.GetHeight(3);
            var x      = xPad;
            var y      = yPad;
            var height = (int)Math.Round(bag.Font.Height() * 1.1, MidpointRounding.AwayFromZero);

            if (SelectedIndex >= 10)
            {
                y -= height * (SelectedIndex - 9);
            }

            g.FillRectangle(style.BackColor.Brush(), e.ClipRectangle);
            var pen = style2.ForeColor.Pen();

            g.DrawRectangle(pen, new Rectangle(e.ClipRectangle.Location,
                                               new Size(e.ClipRectangle.Width - pen.Size(), e.ClipRectangle.Height - pen.Size())));
            var ws = App.Component <IViewManager>().ActiveView.Workspace;

            for (var i = 0; i < Buffers.Count; i++)
            {
                if (y > 0 && y < ClientSize.Height - yPad)
                {
                    var b  = Buffers[i];
                    var ic = style.ForeColor;

                    if (i == SelectedIndex)
                    {
                        g.FillRectangle(style1.BackColor.Brush(), new Rectangle(x - xPad + Dpi.GetWidth(1), y,
                                                                                ClientSize.Width - 2 * Dpi.GetWidth(1), height));
                        ic = style1.ForeColor.IsEmpty ? style.ForeColor : style1.ForeColor;
                    }

                    var font = bag.Font;
                    var size = g.MeasureString(b.File.Name, font.Get(FontStyle.Bold));
                    g.DrawString(b.File.Name, font.Get(FontStyle.Bold), ic.Brush(), x, y);

                    x += (int)size.Width;
                    var dirName = GetDirectoryName(ws, b.File.Directory);
                    g.DrawString(dirName, font, ic.Brush(),
                                 new RectangleF(x, y, ClientSize.Width - xPad * 2 - x, bag.Font.Height()), TextFormats.Path);
                    x = xPad;
                }

                y += height;
            }
        }
Beispiel #5
0
        internal int CalculateHeight()
        {
            var max    = Buffers.Count > 10 ? 10 : Buffers.Count;
            var bag    = App.Component <IViewManager>().ActiveView.Settings.Get <EnvironmentSettings>();
            var height = (int)Math.Round(bag.Font.Height() * 1.1, MidpointRounding.AwayFromZero);

            return(max * height + Dpi.GetHeight(3) * 2);
        }
Beispiel #6
0
 public MessageWindow()
 {
     DoubleBuffered = true;
     SetStyle(ControlStyles.FixedHeight | ControlStyles.FixedWidth, true);
     ShowInTaskbar   = ControlBox = MinimizeBox = MaximizeBox = false;
     FormBorderStyle = FormBorderStyle.None;
     StartPosition   = FormStartPosition.CenterParent;
     Padding         = new Padding(Dpi.GetWidth(3), Dpi.GetHeight(10), Dpi.GetWidth(3), Dpi.GetWidth(3));
     Width           = Dpi.GetWidth(420);
     KeyPreview      = true;
 }
Beispiel #7
0
        private void AdjustHeight()
        {
            var h = (int)Math.Round(
                (double)((IView)FindForm()).Settings.Get <EnvironmentSettings>().Font.Height()
                + Dpi.GetHeight(4), MidpointRounding.AwayFromZero);

            if (Height != h)
            {
                Height = h;
            }
        }
Beispiel #8
0
        private void InternalShowSearch(int width, bool update = false)
        {
            var ovl = GetOverlay();

            if (!ovl.Visible || update)
            {
                if (width > editor.Info.TextWidth)
                {
                    width = editor.Info.TextWidth;
                }

                var size = new Size(width, editor.Info.LineHeight + Dpi.GetHeight(8));
                var rect = new Rectangle(new Point(
                                             editor.Info.TextRight - size.Width - editor.Info.CharWidth,
                                             editor.Info.TextTop + editor.Info.CharWidth),
                                         size);
                ovl.Size     = size;
                ovl.Location = rect.Location;
                ovl.Visible  = true;
                ovl.Invalidate();
            }

            if (!editor.Buffer.Selections.Main.IsEmpty)
            {
                var txt = CopyCommand.GetTextRange(editor, editor.Buffer.Selections.Main);
                ovl.SearchBox.Text = txt;
                ovl.SearchBox.Buffer.Selections.Set(
                    new Selection(new Pos(0, 0), new Pos(0, txt.Length)));
            }

            if (!string.IsNullOrEmpty(ovl.SearchBox.Text))
            {
                Search();
            }

            ovl.SearchBox.Redraw();
            ovl.SearchBox.Focus();
        }
Beispiel #9
0
 private int GetCaretHeight(Graphics g)
 {
     return(BlockCaret ? Dpi.GetHeight(ThinCaret ? 1 : 2) : editor.Info.LineHeight);
 }
Beispiel #10
0
        protected override void OnPaint(PaintEventArgs e)
        {
            AdjustHeight();
            var g      = e.Graphics;
            var bounds = e.ClipRectangle;
            var theme  = App.Component <ITheme>();
            var style  = theme.GetStyle(StandardStyle.StatusBar);
            var astyle = theme.GetStyle(StandardStyle.ActiveStatusBar);
            var font   = ((IView)FindForm()).Settings.Get <EnvironmentSettings>().SmallFont;

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            g.FillRectangle(style.BackColor.Brush(), bounds);

            var ys = Dpi.GetHeight(2);

            g.FillRectangle(style.BackColor.Brush(),
                            new Rectangle(bounds.X, bounds.Y, bounds.Width, ys));
            var pad   = Dpi.GetWidth(6);
            var space = Editor.Info.SmallCharWidth;

            var lefts = Tiles.Where(t => t.Alignment == TileAlignment.Left);
            var x     = bounds.X + pad;

            foreach (var tile in lefts)
            {
                var foreColor = style.ForeColor;
                tile.Font = font;
                var width = tile.MeasureWidth(g);

                if (x + width > bounds.Width)
                {
                    break;
                }

                var rect = new Rectangle(x, bounds.Y + ys, width, bounds.Height - ys * 2);

                if (tile.Hover)
                {
                    g.FillRectangle(astyle.BackColor.Brush(), rect);
                    foreColor = astyle.ForeColor;
                }

                tile.Draw(g, foreColor, rect);
                tile.Left  = x;
                tile.Right = x + width;
                x         += width + space;
            }

            var maxx   = x;
            var rights = Tiles.Where(t => t.Alignment == TileAlignment.Right);

            x = bounds.X + bounds.Width - pad;

            foreach (var tile in rights)
            {
                var foreColor = style.ForeColor;
                tile.Font = font;
                var width = tile.MeasureWidth(g);
                x -= width;

                if (x < maxx)
                {
                    break;
                }

                var rect = new Rectangle(x, bounds.Y + ys, width, bounds.Height - ys * 2);

                if (tile.Hover)
                {
                    g.FillRectangle(astyle.BackColor.Brush(), rect);
                    foreColor = astyle.ForeColor;
                }

                tile.Left  = x;
                tile.Right = x + width;
                tile.Draw(g, foreColor, rect);
                x -= space;
            }
        }