예제 #1
0
        ///<inheritdoc cref="Redraw"/>
        public override void Redraw(Rect region)
        {
            if (Frame.Y != Driver.Rows - 1)
            {
                Frame = new Rect(Frame.X, Driver.Rows - 1, Frame.Width, Frame.Height);
                Y     = Driver.Rows - 1;
                SetNeedsDisplay();
            }

            Move(0, 0);
            Driver.SetAttribute(ColorScheme.Normal);
            for (int i = 0; i < Frame.Width; i++)
            {
                Driver.AddRune(' ');
            }

            Move(1, 0);
            var scheme = ColorScheme.Normal;

            Driver.SetAttribute(scheme);
            for (int i = 0; i < Items.Length; i++)
            {
                var title = Items [i].Title;
                for (int n = 0; n < title.Length; n++)
                {
                    if (title [n] == '~')
                    {
                        scheme = ToggleScheme(scheme);
                        continue;
                    }
                    Driver.AddRune(title [n]);
                }
                Driver.AddRune(' ');
            }
        }
예제 #2
0
파일: demo.cs 프로젝트: deltawarp/gui.cs
        public override void Redraw(Rect region)
        {
            Driver.SetAttribute(ColorScheme.Focus);
            var f = Frame;

            for (int y = 0; y < f.Width; y++)
            {
                Move(0, y);
                for (int x = 0; x < f.Height; x++)
                {
                    Rune r;
                    switch (x % 3)
                    {
                    case 0:
                        r = '.';
                        break;

                    case 1:
                        r = 'o';
                        break;

                    default:
                        r = 'O';
                        break;
                    }
                    Driver.AddRune(r);
                }
            }
        }
예제 #3
0
파일: Menu.cs 프로젝트: wangyw15/gui.cs
        public override void Redraw(Rect region)
        {
            Move(0, 0);
            Driver.SetAttribute(Colors.Base.Focus);
            for (int i = 0; i < Frame.Width; i++)
            {
                Driver.AddRune(' ');
            }

            Move(1, 0);
            int pos = 1;

            for (int i = 0; i < Menus.Length; i++)
            {
                var menu = Menus [i];
                Move(pos, 0);
                Attribute hotColor, normalColor;
                if (i == selected)
                {
                    hotColor    = i == selected ? ColorScheme.HotFocus : ColorScheme.HotNormal;
                    normalColor = i == selected ? ColorScheme.Focus : ColorScheme.Normal;
                }
                else
                {
                    hotColor    = Colors.Base.Focus;
                    normalColor = Colors.Base.Focus;
                }
                DrawHotString(" " + menu.Title + " " + "   ", hotColor, normalColor);
                pos += menu.TitleLength + 3;
            }
            PositionCursor();
        }
예제 #4
0
        public override void Redraw(Rect bounds)
        {
            Driver.SetAttribute(ColorScheme.Focus);
            var f = Frame;

            for (int y = 0; y < f.Width; y++)
            {
                Move(0, y);
                for (int x = 0; x < f.Height; x++)
                {
                    Rune r;
                    switch (x % 3)
                    {
                    case 0:
                        Driver.AddRune(y.ToString().ToCharArray(0, 1) [0]);
                        if (y > 9)
                        {
                            Driver.AddRune(y.ToString().ToCharArray(1, 1) [0]);
                        }
                        r = '.';
                        break;

                    case 1:
                        r = 'o';
                        break;

                    default:
                        r = 'O';
                        break;
                    }
                    Driver.AddRune(r);
                }
            }
        }
예제 #5
0
            protected override void RenderCell(Terminal.Gui.Attribute cellColor, string render, bool isPrimaryCell)
            {
                int unicorns = render.IndexOf("unicorns", StringComparison.CurrentCultureIgnoreCase);
                int rainbows = render.IndexOf("rainbows", StringComparison.CurrentCultureIgnoreCase);

                for (int i = 0; i < render.Length; i++)
                {
                    if (unicorns != -1 && i >= unicorns && i <= unicorns + 8)
                    {
                        Driver.SetAttribute(Driver.MakeAttribute(Color.White, cellColor.Background));
                    }

                    if (rainbows != -1 && i >= rainbows && i <= rainbows + 8)
                    {
                        var letterOfWord = i - rainbows;
                        switch (letterOfWord)
                        {
                        case 0:
                            Driver.SetAttribute(Driver.MakeAttribute(Color.Red, cellColor.Background));
                            break;

                        case 1:
                            Driver.SetAttribute(Driver.MakeAttribute(Color.BrightRed, cellColor.Background));
                            break;

                        case 2:
                            Driver.SetAttribute(Driver.MakeAttribute(Color.BrightYellow, cellColor.Background));
                            break;

                        case 3:
                            Driver.SetAttribute(Driver.MakeAttribute(Color.Green, cellColor.Background));
                            break;

                        case 4:
                            Driver.SetAttribute(Driver.MakeAttribute(Color.BrightGreen, cellColor.Background));
                            break;

                        case 5:
                            Driver.SetAttribute(Driver.MakeAttribute(Color.BrightBlue, cellColor.Background));
                            break;

                        case 6:
                            Driver.SetAttribute(Driver.MakeAttribute(Color.BrightCyan, cellColor.Background));
                            break;

                        case 7:
                            Driver.SetAttribute(Driver.MakeAttribute(Color.Cyan, cellColor.Background));
                            break;
                        }
                    }

                    Driver.AddRune(render [i]);
                    Driver.SetAttribute(cellColor);
                }
            }
예제 #6
0
파일: demo.cs 프로젝트: deltawarp/gui.cs
        public override void Redraw(Rect region)
        {
            Driver.SetAttribute(ColorScheme.Focus);

            for (int y = 0; y < 10; y++)
            {
                Move(0, y);
                for (int x = 0; x < 10; x++)
                {
                    Driver.AddRune((Rune)('0' + (x + y) % 10));
                }
            }
        }
예제 #7
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);
     }
 }
예제 #8
0
 ///<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);
     }
 }
예제 #9
0
            public override void Redraw(Rect bounds)
            {
                Driver.SetAttribute(ColorScheme.Focus);
                var f = Frame;

                w = 0;
                h = 0;

                for (int y = 0; y < f.Width; y++)
                {
                    Move(0, y);
                    var nw = 0;
                    for (int x = 0; x < f.Height; x++)
                    {
                        Rune r;
                        switch (x % 3)
                        {
                        case 0:
                            var er = y.ToString().ToCharArray(0, 1) [0];
                            nw += er.ToString().Length;
                            Driver.AddRune(er);
                            if (y > 9)
                            {
                                er  = y.ToString().ToCharArray(1, 1) [0];
                                nw += er.ToString().Length;
                                Driver.AddRune(er);
                            }
                            r = '.';
                            break;

                        case 1:
                            r = 'o';
                            break;

                        default:
                            r = 'O';
                            break;
                        }
                        Driver.AddRune(r);
                        nw += Rune.RuneLen(r);
                    }
                    if (nw > w)
                    {
                        w = nw;
                    }
                    h = y + 1;
                }
            }
예제 #10
0
            public override void Redraw(Rect region)
            {
                Driver.SetAttribute(ColorScheme.Focus);
                var f = Frame;

                for (int y = 0; y < f.Width; y++)
                {
                    Move(0, y);
                    for (int x = 0; x < f.Height; x++)
                    {
                        var r = (x % 3) switch {
                            0 => '.',
                            1 => 'o',
                            _ => 'O',
                        };
                        Driver.AddRune(r);
                    }
                }
            }
예제 #11
0
    public override void Redraw(Rect region)
    {
        Clear();
        var drewFocus = false;

        foreach (var pt in _game.GetWithin(region.Left - _offset.X, region.Top - _offset.Y, region.Width - 1, region.Height - 1))
        {
            if (HasFocus && _inputMode == InputMode.Editing && Focus.X == pt.Item1 + _offset.X && Focus.Y == pt.Item2 + _offset.Y)
            {
                Driver.SetAttribute(ColorScheme.Focus);
                drewFocus = true;
            }
            else
            {
                Driver.SetAttribute(ColorScheme.Normal);
            }
            Move(pt.Item1 + _offset.X, pt.Item2 + _offset.Y);
            Driver.AddRune('x');
        }

        if (HasFocus && _inputMode == InputMode.Editing && !drewFocus)
        {
            Driver.SetAttribute(ColorScheme.Focus);
            Move(Focus.X, Focus.Y);
            Driver.AddRune(' ');
        }

        if (_inputMode == InputMode.AddingEntity)
        {
            Driver.SetAttribute(ColorScheme.Focus);
            var entityToAddPts = _entityToAdd
                                 .Select(x => new Point(x.X + Focus.X, x.Y + Focus.Y))
                                 .Where(x => x.X > 0 && x.X < region.Width - 1 && x.Y > 0 && x.Y < region.Height - 1);

            foreach (var pt in entityToAddPts)
            {
                Move(pt.X, pt.Y);
                Driver.AddRune('x');
            }
        }
        Driver.SetAttribute(ColorScheme.Normal);
    }
예제 #12
0
        public override void Redraw(Rect region)
        {
            Driver.SetAttribute(ColorScheme.Focus);
            Move(0, 0);

            for (int i = 0; i < Frame.Width; i++)
            {
                int p = first + i;

                if (p < text.Length)
                {
                    Driver.AddRune(Secret ? (Rune)'*' : text [p]);
                }
                else
                {
                    Driver.AddRune(' ');
                }
            }
            PositionCursor();
        }
예제 #13
0
        /// <summary>
        /// Draws the line including any starting/ending anchors
        /// </summary>
        /// <param name="bounds"></param>
        public override void Redraw(Rect bounds)
        {
            base.Redraw(bounds);

            Move(0, 0);
            Driver.SetAttribute(GetNormalColor());

            var hLineWidth = Math.Max(1, Rune.ColumnWidth(Driver.HLine));

            var dEnd = Orientation == Orientation.Horizontal ?
                       bounds.Width :
                       bounds.Height;

            for (int d = 0; d < dEnd; d += hLineWidth)
            {
                if (Orientation == Orientation.Horizontal)
                {
                    Move(d, 0);
                }
                else
                {
                    Move(0, d);
                }

                Rune rune = LineRune;

                if (d == 0)
                {
                    rune = StartingAnchor ?? LineRune;
                }
                else
                if (d == dEnd - 1)
                {
                    rune = EndingAnchor ?? LineRune;
                }

                Driver.AddRune(rune);
            }
        }
예제 #14
0
        ///<inheritdoc/>
        public override void Redraw(Rect bounds)
        {
            //if (Frame.Y != Driver.Rows - 1) {
            //	Frame = new Rect (Frame.X, Driver.Rows - 1, Frame.Width, Frame.Height);
            //	Y = Driver.Rows - 1;
            //	SetNeedsDisplay ();
            //}

            Move(0, 0);
            Driver.SetAttribute(Colors.Menu.Normal);
            for (int i = 0; i < Frame.Width; i++)
            {
                Driver.AddRune(' ');
            }

            Move(1, 0);
            var scheme = ColorScheme.Normal;

            Driver.SetAttribute(scheme);
            for (int i = 0; i < Items.Length; i++)
            {
                var title = Items [i].Title.ToString();
                for (int n = 0; n < Items [i].Title.RuneCount; n++)
                {
                    if (title [n] == '~')
                    {
                        scheme = ToggleScheme(scheme);
                        continue;
                    }
                    Driver.AddRune(title [n]);
                }
                if (i + 1 < Items.Length)
                {
                    Driver.AddRune(' ');
                    Driver.AddRune(Driver.VLine);
                    Driver.AddRune(' ');
                }
            }
        }
예제 #15
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);
            }
        }
예제 #16
0
파일: Menu.cs 프로젝트: ag-csharp/gui.cs
        ///<inheritdoc/>
        public override void Redraw(Rect bounds)
        {
            Move(0, 0);
            Driver.SetAttribute(Colors.Menu.Normal);
            for (int i = 0; i < Frame.Width; i++)
            {
                Driver.AddRune(' ');
            }

            Move(1, 0);
            int pos = 1;

            for (int i = 0; i < Menus.Length; i++)
            {
                var menu = Menus [i];
                Move(pos, 0);
                Attribute hotColor, normalColor;
                if (i == selected)
                {
                    hotColor    = i == selected ? ColorScheme.HotFocus : ColorScheme.HotNormal;
                    normalColor = i == selected ? ColorScheme.Focus : ColorScheme.Normal;
                }
                else if (openedByAltKey)
                {
                    hotColor    = ColorScheme.HotNormal;
                    normalColor = ColorScheme.Normal;
                }
                else
                {
                    hotColor    = ColorScheme.Normal;
                    normalColor = ColorScheme.Normal;
                }
                DrawHotString($" {menu.Title}  ", hotColor, normalColor);
                pos += 1 + menu.TitleLength + 2;
            }
            PositionCursor();
        }
예제 #17
0
        /// <summary>
        /// Draw a box for one color.
        /// </summary>
        /// <param name="x">X location.</param>
        /// <param name="y">Y location</param>
        /// <param name="selected"></param>
        private void DrawColorBox(int x, int y, bool selected)
        {
            var index = 0;

            for (var zommedY = 0; zommedY < verticalZoom; zommedY++)
            {
                for (var zommedX = 0; zommedX < horizontalZoom; zommedX++)
                {
                    Move(x * horizontalZoom + zommedX, y * verticalZoom + zommedY + 1);

                    if (selected)
                    {
                        var character = cursorRunes [index];
                        Driver.AddRune(character);
                    }
                    else
                    {
                        Driver.AddRune(' ');
                    }

                    index++;
                }
            }
        }
예제 #18
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();
        }