Пример #1
0
        public ViewsAndSubViews() : base(1, 1)
        {
            mainView = new Console(60, 23);
            subView  = Console.FromSurface(mainView.GetViewSurface(new Rectangle(0, 0, 20, 23)));

            IsVisible = false;
            UseMouse  = true;

            mainView.DrawLine(new Point(59, 0), new Point(59, 22), Color.White, glyph: ConnectedLineThin[(int)ConnectedLineIndex.Left]);

            // Setup main view
            mainView.Position   = new Point(0, 2);
            mainView.MouseMove += (s, e) => { if (e.MouseState.Mouse.LeftButtonDown)
                                              {
                                                  e.MouseState.Cell.Background = Color.Blue; mainView.IsDirty = true;
                                              }
            };
            mainView.DirtyChanged += (s, e) => subView.IsDirty = true;

            // Setup sub view
            subView.Position = new Point(60, 2);
            //subView.SetViewFromSurface(new Rectangle(0, 0, 20, 23), mainView);
            subView.MouseMove += (s, e) => { if (e.MouseState.Mouse.LeftButtonDown)
                                             {
                                                 e.MouseState.Cell.Background = Color.Red; subView.IsDirty = true;
                                             }
            };
            subView.DirtyChanged += (s, e) => mainView.IsDirty = true;

            // Ad the consoles to the list.
            Children.Add(mainView);
            Children.Add(subView);
        }
Пример #2
0
        public SubConsoleCursor()
        {
            mainView = new Console(80, 23);
            subView  = Console.FromSurface(mainView.GetViewSurface(new Rectangle(30, 4, 25, 10)));

            UseKeyboard = true;

            // Setup main view
            mainView.FillWithRandomGarbage();
            mainView.MouseMove += (s, e) => { if (e.MouseState.Mouse.LeftButtonDown)
                                              {
                                                  e.MouseState.Cell.Background = Color.Blue;
                                              }
            };

            // Setup sub view
            subView.Position          = new Point(4, 4);
            subView.DefaultBackground = Color.Black;
            subView.MouseMove        += (s, e) => { if (e.MouseState.Mouse.LeftButtonDown)
                                                    {
                                                        e.MouseState.Cell.Background = Color.Red;
                                                    }
            };
            subView.DirtyChanged += (s, e) => mainView.IsDirty = subView.IsDirty;
            subView.Clear();
            subView.Cursor.IsVisible = true;
            subView.Cursor
            .Print("The left box is a whole console which is a view into the box on the right.")
            .CarriageReturn()
            .LineFeed();


            // Ad the consoles to the list.
            Children.Add(mainView);
            Children.Add(subView);

            IsVisible = false;
        }