コード例 #1
0
        public override void Redraw(Rect bounds)
        {
            if (Matrix is null)
            {
                return;
            }

            for (var i = 0; i < w; i++)
            {
                for (var j = 0; j < h; j++)
                {
                    Move(i, j);

                    if (Matrix.Items[i, j] == 0)
                    {
                        Driver.SetAttribute(new Terminal.Gui.Attribute(Color.DarkGray, Color.Black));
                        Driver.AddStr("░");
                    }
                    else if (Matrix.Items[i, j] == 1)
                    {
                        Driver.SetAttribute(new Terminal.Gui.Attribute(Color.BrightBlue, Color.Black));
                        Driver.AddStr("@");
                    }
                    else if (Matrix.Items[i, j] == 2)
                    {
                        Driver.SetAttribute(new Terminal.Gui.Attribute(Color.BrightRed, Color.Black));
                        Driver.AddStr("@");
                    }
                }
            }
        }
コード例 #2
0
        ///<inheritdoc/>
        public override void Redraw(Rect bounds)
        {
            if (recalcPending)
            {
                Recalc();
            }

            if (TextColor != -1)
            {
                Driver.SetAttribute(TextColor);
            }
            else
            {
                Driver.SetAttribute(ColorScheme.Normal);
            }

            Clear();
            for (int line = 0; line < lines.Count; line++)
            {
                if (line < bounds.Top || line > bounds.Bottom)
                {
                    continue;
                }
                var str = lines [line];
                int x;
                switch (textAlignment)
                {
                case TextAlignment.Left:
                    x = 0;
                    break;

                case TextAlignment.Justified:
                    Recalc();
                    x = Bounds.Left;
                    break;

                case TextAlignment.Right:
                    x = Bounds.Right - str.Length;
                    break;

                case TextAlignment.Centered:
                    x = Bounds.Left + (Bounds.Width - str.Length) / 2;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                Move(x, line);
                Driver.AddStr(str);
            }
        }
コード例 #3
0
 public override void Redraw(Rect region)
 {
     Driver.SetAttribute(HasFocus ? ColorScheme.Focus : ColorScheme.Normal);
     Move(0, 0);
     Driver.AddStr(Checked ? "[x] " : "[ ] ");
     Move(4, 0);
     Driver.AddStr(Text);
     if (hot_pos != -1)
     {
         Move(4 + hot_pos, 0);
         Driver.SetAttribute(HasFocus ? ColorScheme.HotFocus : ColorScheme.HotNormal);
         Driver.AddRune(hot_key);
     }
 }
コード例 #4
0
ファイル: Checkbox.cs プロジェクト: migueldeicaza/gui.cs
 ///<inheritdoc/>
 public override void Redraw(Rect bounds)
 {
     Driver.SetAttribute(HasFocus ? ColorScheme.Focus : GetNormalColor());
     Move(0, 0);
     Driver.AddRune(Checked ? Driver.Checked : Driver.UnChecked);
     Driver.AddRune(' ');
     Move(2, 0);
     Driver.AddStr(Text);
     if (hot_pos != -1)
     {
         Move(2 + hot_pos, 0);
         Driver.SetAttribute(HasFocus ? ColorScheme.HotFocus : Enabled ? ColorScheme.HotNormal : ColorScheme.Disabled);
         Driver.AddRune(hot_key);
     }
 }
コード例 #5
0
ファイル: GlobeViewer.cs プロジェクト: kreghek/Lus
        public override void Redraw(Rect bounds)
        {
            if (Matrix is null)
            {
                return;
            }

            for (var i = 0; i < w; i++)
            {
                for (var j = 0; j < h; j++)
                {
                    Move(i, j);

                    if (Matrix.Items[i, j] == 0)
                    {
                        Driver.SetAttribute(new Attribute(Color.DarkGray, Color.Black));
                        Driver.AddStr("?");
                    }
                    else if (Matrix.Items[i, j] == 1)
                    {
                        Driver.SetAttribute(new Attribute(Color.Green, Color.Black));
                        Driver.AddStr("Y");
                    }
                    else if (Matrix.Items[i, j] == 2)
                    {
                        Driver.SetAttribute(new Attribute(Color.Gray, Color.Black));
                        Driver.AddStr("0");
                    }
                    else if (Matrix.Items[i, j] == 3)
                    {
                        Driver.SetAttribute(new Attribute(Color.Brown, Color.Black));
                        Driver.AddStr("_");
                    }
                    else if (Matrix.Items[i, j] == 4)
                    {
                        Driver.SetAttribute(new Attribute(Color.BrightBlue, Color.Black));
                        Driver.AddStr("@");
                    }
                    else if (Matrix.Items[i, j] == 5)
                    {
                        Driver.SetAttribute(new Attribute(Color.BrightBlue, Color.Black));
                        Driver.AddStr("░");
                    }
                }
            }
        }
コード例 #6
0
ファイル: Scrolling.cs プロジェクト: StefanHolst/gui.cs
            public override void Redraw(Rect bounds)
            {
                //Point pos = new Point (region.X, region.Y);
                Driver.SetAttribute(ColorScheme.Focus);

                for (int y = 0; y < h; y++)
                {
                    Move(0, y);
                    Driver.AddStr(y.ToString());
                    for (int x = 0; x < w - y.ToString().Length; x++)
                    {
                        //Driver.AddRune ((Rune)('0' + (x + y) % 10));
                        if (y.ToString().Length < w)
                        {
                            Driver.AddStr(" ");
                        }
                    }
                }
                //Move (pos.X, pos.Y);
            }
コード例 #7
0
ファイル: Menu.cs プロジェクト: wangyw15/gui.cs
        public override void Redraw(Rect region)
        {
            Driver.SetAttribute(ColorScheme.Normal);
            DrawFrame(region, padding: 0, fill: true);

            for (int i = 0; i < barItems.Children.Length; i++)
            {
                var item = barItems.Children [i];
                Move(1, i + 1);
                Driver.SetAttribute(item == null ? Colors.Base.Focus : i == current ? ColorScheme.Focus : ColorScheme.Normal);
                for (int p = 0; p < Frame.Width - 2; p++)
                {
                    if (item == null)
                    {
                        Driver.AddRune(Driver.HLine);
                    }
                    else
                    {
                        Driver.AddRune(' ');
                    }
                }

                if (item == null)
                {
                    continue;
                }

                Move(2, i + 1);
                DrawHotString(item.Title,
                              i == current? ColorScheme.HotFocus : ColorScheme.HotNormal,
                              i == current ? ColorScheme.Focus : ColorScheme.Normal);

                // The help string
                var l = item.Help.Length;
                Move(Frame.Width - l - 2, 1 + i);
                Driver.AddStr(item.Help);
            }
        }
コード例 #8
0
        public override void Redraw(Rect region)
        {
            if (columns == null)
            {
                return;
            }
            if (hOffset >= columns.Length)
            {
                hOffset = columns.Length - 1;
            }
            if (hOffset < 0)
            {
                hOffset = 0;
            }

            PositionCursor();
            int lineLen = 0;

            for (int i = hOffset - 1; i < columns.Length; i++)
            {
                if (lineLen + COLUMN_WIDTH >= region.Width)
                {
                    break; //if drawing another line would overrun the current one, dont draw any more.
                }
                lineLen += COLUMN_WIDTH;
                if (i == hOffset - 1)
                {
                    Driver.AddStr("Record ID".PadRight(COLUMN_WIDTH));
                }
                else
                {
                    string printStr = StringHelper.LimitLength(columns[i].columnIdenfier, COL_NAME_WIDTH, "") + " (" + GetShortColumnName(columns[i].columnType) + ")";
                    printStr = printStr.PadRight(COLUMN_WIDTH);
                    Driver.AddStr(printStr);
                }
            }
        }
コード例 #9
0
ファイル: Menu.cs プロジェクト: mchi2dy2/gui.cs
        public override void Redraw(Rect region)
        {
            Driver.SetAttribute(ColorScheme.Normal);
            DrawFrame(region, padding: 0, fill: true);

            for (int i = 0; i < barItems.Children.Length; i++)
            {
                var item = barItems.Children [i];
                Driver.SetAttribute(item == null ? ColorScheme.Normal : i == current ? ColorScheme.Focus : ColorScheme.Normal);
                if (item == null)
                {
                    Move(0, i + 1);
                    Driver.AddRune(Driver.LeftTee);
                }
                else
                {
                    Move(1, i + 1);
                }

                Driver.SetAttribute(DetermineColorSchemeFor(item, i));
                for (int p = 0; p < Frame.Width - 2; p++)
                {
                    if (item == null)
                    {
                        Driver.AddRune(Driver.HLine);
                    }
                    else if (p == Frame.Width - 3 && barItems.Children [i].SubMenu != null)
                    {
                        Driver.AddRune('>');
                    }
                    else
                    {
                        Driver.AddRune(' ');
                    }
                }

                if (item == null)
                {
                    Move(Frame.Right - 1, i + 1);
                    Driver.AddRune(Driver.RightTee);
                    continue;
                }

                Move(2, i + 1);
                if (!item.IsEnabled())
                {
                    DrawHotString(item.Title, ColorScheme.Disabled, ColorScheme.Disabled);
                }
                else
                {
                    DrawHotString(item.Title,
                                  i == current ? ColorScheme.HotFocus : ColorScheme.HotNormal,
                                  i == current ? ColorScheme.Focus : ColorScheme.Normal);
                }

                // The help string
                var l = item.Help.Length;
                Move(Frame.Width - l - 2, 1 + i);
                Driver.AddStr(item.Help);
            }
            PositionCursor();
        }
コード例 #10
0
ファイル: GraphView.cs プロジェクト: hong1990/gui.cs
        ///<inheritdoc/>
        public override void Redraw(Rect bounds)
        {
            if (CellSize.X == 0 || CellSize.Y == 0)
            {
                throw new Exception($"{nameof(CellSize)} cannot be 0");
            }

            SetDriverColorToGraphColor();

            Move(0, 0);

            // clear all old content
            for (int i = 0; i < Bounds.Height; i++)
            {
                Move(0, i);
                Driver.AddStr(new string (' ', Bounds.Width));
            }

            // If there is no data do not display a graph
            if (!Series.Any() && !Annotations.Any())
            {
                return;
            }

            // Draw 'before' annotations
            foreach (var a in Annotations.Where(a => a.BeforeSeries))
            {
                a.Render(this);
            }

            SetDriverColorToGraphColor();

            AxisY.DrawAxisLine(this);
            AxisX.DrawAxisLine(this);

            AxisY.DrawAxisLabels(this);
            AxisX.DrawAxisLabels(this);

            // Draw a cross where the two axis cross
            var axisIntersection = new Point(AxisY.GetAxisXPosition(this), AxisX.GetAxisYPosition(this));

            if (AxisX.Visible && AxisY.Visible)
            {
                Move(axisIntersection.X, axisIntersection.Y);
                AddRune(axisIntersection.X, axisIntersection.Y, '\u253C');
            }

            SetDriverColorToGraphColor();

            // The drawable area of the graph (anything that isn't in the margins)
            Rect       drawBounds = new Rect((int)MarginLeft, 0, Bounds.Width - ((int)MarginLeft), Bounds.Height - (int)MarginBottom);
            RectangleF graphSpace = ScreenToGraphSpace(drawBounds);

            foreach (var s in Series)
            {
                s.DrawSeries(this, drawBounds, graphSpace);

                // If a series changes the graph color reset it
                SetDriverColorToGraphColor();
            }

            SetDriverColorToGraphColor();

            // Draw 'after' annotations
            foreach (var a in Annotations.Where(a => !a.BeforeSeries))
            {
                a.Render(this);
            }
        }