Example #1
0
        public (ControlsConsole, Window) CreateM2Window(Size windowSize, string title)
        {
            int viewWidth  = windowSize.Width - 2;
            int viewHeight = windowSize.Height - 2;

            Window menuWindow = new Window(windowSize.Width, windowSize.Height)
            {
                CanDrag           = true,
                Title             = title.Align(HorizontalAlignment.Center, viewWidth),
                DefaultBackground = MG.Color.Black,
            };

            log.DebugFormat("Created menu window, [{0}].", menuWindow.AbsoluteArea);

            var menuConsole = new ControlsConsole(viewWidth, viewHeight)
            {
                DefaultBackground = MG.Color.Black,
            };

            // Fit the Console inside the Window border
            menuConsole.Position = new Coord(1, 1);
            log.DebugFormat("Created menu console, [{0}].", menuConsole.AbsoluteArea);

            menuConsole.Clear();

            menuWindow.Children.Add(menuConsole);
            return(menuConsole, menuWindow);
        }
Example #2
0
        public ToolPane()
        {
            ToolsConsole = new ControlsConsole(Settings.Config.ToolPaneWidth - 1, Settings.Config.WindowHeight * 3);
            ToolsConsole.MouseHandler = ProcessMouse;
            ToolsConsole.UseKeyboard  = false;

            // Create scrollbar
            ToolsPaneScroller               = SadConsole.Controls.ScrollBar.Create(System.Windows.Controls.Orientation.Vertical, Settings.Config.WindowHeight - 1);
            ToolsPaneScroller.Maximum       = ToolsConsole.TextSurface.Height - Settings.Config.WindowHeight;
            ToolsPaneScroller.ValueChanged += (o, e) =>
            {
                ToolsConsole.TextSurface.RenderArea = new Rectangle(0, ToolsPaneScroller.Value, ToolsConsole.Width, Settings.Config.WindowHeight);
            };

            ScrollerConsole = new ControlsConsole(1, Settings.Config.WindowHeight - 1);
            ScrollerConsole.Add(ToolsPaneScroller);
            ScrollerConsole.Position          = new Point(Width, 0);
            ScrollerConsole.IsVisible         = true;
            ScrollerConsole.FocusOnMouseClick = false;



            PanelWidth         = Settings.Config.ToolPaneWidth - 1;
            PanelWidthControls = PanelWidth - 2;

            _tools = new Dictionary <string, ITool>();

            ToolsConsole.TextSurface.DefaultBackground = Settings.Color_MenuBack;
            ToolsConsole.TextSurface.DefaultForeground = Settings.Color_TitleText;
            ToolsConsole.Clear();

            _hotSpots = new List <Tuple <CustomPanel, int> >();

            // Create tools
            _tools.Add(PaintTool.ID, new PaintTool());
            ToolsConsole.TextSurface.RenderArea = new Rectangle(0, 0, ToolsConsole.Width, Settings.Config.WindowHeight - 1);

            // Create panels
            PanelFiles = new FilesPanel();
            //PanelTools = new ToolsPanel();

            Children.Add(ToolsConsole);
            Children.Add(ScrollerConsole);
        }
Example #3
0
        public void RedrawPanels()
        {
            int activeRow = 0;

            ToolsConsole.Clear();
            ToolsConsole.RemoveAll();
            _hotSpots.Clear();

            char open   = (char)31;
            char closed = (char)16;

            List <CustomPanel> allPanels = new List <CustomPanel>()
            {
                PanelFiles
            };

            // Custom panels from the selected editor
            if (MainScreen.Instance.ActiveEditor != null)
            {
                if (MainScreen.Instance.ActiveEditor.Panels != null && MainScreen.Instance.ActiveEditor.Panels.Length != 0)
                {
                    allPanels.AddRange(MainScreen.Instance.ActiveEditor.Panels);
                }
            }

            // Custom panels from the selected tool
            //if (SelectedTool.ControlPanels != null && SelectedTool.ControlPanels.Length != 0)
            //    allPanels.AddRange(SelectedTool.ControlPanels);

            // Display all panels needed
            if (allPanels.Count != 0)
            {
                foreach (var pane in allPanels)
                {
                    if (pane.IsVisible)
                    {
                        pane.Loaded();
                        _hotSpots.Add(new Tuple <CustomPanel, int>(pane, activeRow));
                        if (pane.IsCollapsed == false)
                        {
                            ToolsConsole.Print(1, activeRow++, open + " " + pane.Title);
                            ToolsConsole.Print(0, activeRow++, new string((char)196, ToolsConsole.TextSurface.Width));

                            foreach (var control in pane.Controls)
                            {
                                if (control != null)
                                {
                                    if (control.IsVisible)
                                    {
                                        ToolsConsole.Add(control);
                                        control.Position = new Point(1, activeRow);
                                        activeRow       += pane.Redraw(control) + control.Height;
                                    }
                                }
                                else
                                {
                                    activeRow++;
                                }
                            }

                            activeRow += 1;
                        }
                        else
                        {
                            ToolsConsole.Print(1, activeRow++, closed + " " + pane.Title);
                        }
                    }
                }
            }

            int scrollAbility = activeRow + 1 - Settings.Config.WindowHeight;

            if (scrollAbility <= 0)
            {
                ToolsPaneScroller.IsEnabled = false;
                ToolsPaneScroller.Maximum   = 0;
            }
            else
            {
                ToolsPaneScroller.Maximum   = scrollAbility;
                ToolsPaneScroller.IsEnabled = true;
            }
        }