예제 #1
0
 public PTabPage(IXCommand xcom)
 {
     InitializeComponent();
     pdraw      = new PDraw();
     pdraw.xcom = xcom;
     Controls.Add(pdraw);
 }
예제 #2
0
        public PStatusBar(IXCommand xCommand)
        {
            _xCommand = xCommand;
            ToolStripStatusLabel statusLbl = new ToolStripStatusLabel("X:  Y: ");

            Items.Add(statusLbl);
        }
예제 #3
0
 public static IXCommand SetDependency(this IXCommand command, params INotifyPropertyChanged[] properties)
 {
     foreach (var property in properties)
     {
         property.PropertyChanged += (sender, args) => { command.ChangeCanExecute(); };
     }
     return(command);
 }
예제 #4
0
 private void Write(IXCommand command, string text, bool appendNewLine = true, ConsoleColor color = ConsoleColor.White)
 {
     if (appendNewLine)
     {
         Writer.WriteLine(text, color);
     }
     else
     {
         Writer.Write(text, color);
     }
 }
예제 #5
0
        public PFigure(int x, int y, int w, int h, XData xData, IXCommand xCommand)
        {
            //ContextMenuStrip = new CtxMenu(xCommand);

            Location   = new Point(x, y);
            Size       = new Size(w, h);
            _color     = xData.color;
            _lineWidth = xData.lineWidth;
            _type      = xData.type;

            Paint += PFigure_Paint;
            Click += PFigure_Click;
        }
예제 #6
0
 public void AskForInput(IXCommand command, string text, bool appendNewLine = false)
 {
     if (!text.EndsWith(": "))
     {
         if (text.Contains(":"))
         {
             text += " ";
         }
         else
         {
             text += ": ";
         }
     }
     Write(command, text, appendNewLine);
 }
예제 #7
0
        public PElements(IXCommand xCommand)
        {
            _xCommand = xCommand;

            _figureTypeGroupBox          = new GroupBox();
            _figureTypeGroupBox.Parent   = this;
            _figureTypeGroupBox.Text     = Localization.GetText("figure_type_text_id");
            _figureTypeGroupBox.Location = new Point(0, 0);
            _figureTypeGroupBox.Size     = new Size(Width - 10, 200);

            _simpleFigure          = new Button();
            _simpleFigure.Parent   = _figureTypeGroupBox;
            _simpleFigure.Text     = Localization.GetText("simple_figure_text_id");
            _simpleFigure.Location = new Point(10, 20);
            _simpleFigure.Size     = new Size(100, 35);
            _simpleFigure.Click   += delegate { _xCommand.ActiveFigurePlugin = null; };

            //int y = 30;
            //Button r = new Button();
            //r.Text = "Simple Figure";
            //r.Location = new Point(10, y);
            //r.Width = 130;
            //y += 30;
            //r.Click += delegate
            //{
            //    _xCommand.ActiveFigurePlugin = null;
            //};
            // Controls.Add(r);
            int y = 30;

            foreach (var plugin in xCommand.FigurePlugins)
            {
                Button b = plugin.GetElements();
                b.Location = new Point(10, y);
                b.Width    = 130;
                b.Click   += delegate
                {
                    _xCommand.ActiveFigurePlugin = plugin;
                };
                y += 30;
                Controls.Add(b);
            }

            SkinController.OnSkinChange += SkinController_OnSkinChange;
        }
예제 #8
0
 public ActionSave(IXCommand cmd)
 {
     this.cmd = cmd;
 }
예제 #9
0
        public PToolBox(IXCommand xCommand)
        {
            _xCommand = xCommand;

            // properties
            _emptyFigureGroupBox          = new GroupBox();
            _emptyFigureGroupBox.Parent   = this;
            _emptyFigureGroupBox.Text     = Localization.GetText("properties_text_id");
            _emptyFigureGroupBox.Location = new System.Drawing.Point(0, 0);
            _emptyFigureGroupBox.Size     = new System.Drawing.Size(Width - 5, 490);

            _typeLbl          = new Label();
            _typeLbl.Parent   = _emptyFigureGroupBox;
            _typeLbl.Text     = Localization.GetText("types_text_id");
            _typeLbl.Location = new System.Drawing.Point(10, 20);
            _typeLbl.Size     = new System.Drawing.Size(40, 25);

            _line          = new Button();
            _line.Parent   = _emptyFigureGroupBox;
            _line.Text     = Localization.GetText("line_text_id");
            _line.Location = new System.Drawing.Point(50, 20);
            _line.Size     = new System.Drawing.Size(100, 25);
            _line.Click   += delegate { _xCommand.SetType(Models.XData.FigureType.Line); };

            _rect          = new Button();
            _rect.Parent   = _emptyFigureGroupBox;
            _rect.Text     = Localization.GetText("rectangle_text_id");
            _rect.Location = new System.Drawing.Point(50, 46);
            _rect.Size     = new System.Drawing.Size(100, 25);
            _rect.Click   += delegate { _xCommand.SetType(Models.XData.FigureType.Rectangle); };

            _roundRect          = new Button();
            _roundRect.Parent   = _emptyFigureGroupBox;
            _roundRect.Text     = Localization.GetText("rounded_rectangle_text_id");
            _roundRect.Location = new System.Drawing.Point(50, 72);
            _roundRect.Size     = new System.Drawing.Size(100, 25);
            _roundRect.Click   += delegate { _xCommand.SetType(Models.XData.FigureType.RoundRectangle); };

            _ellipse          = new Button();
            _ellipse.Parent   = _emptyFigureGroupBox;
            _ellipse.Text     = Localization.GetText("ellipse_text_id");
            _ellipse.Location = new System.Drawing.Point(50, 98);
            _ellipse.Size     = new System.Drawing.Size(100, 25);
            _ellipse.Click   += delegate { _xCommand.SetType(Models.XData.FigureType.Ellipse); };

            _colorLbl          = new Label();
            _colorLbl.Parent   = _emptyFigureGroupBox;
            _colorLbl.Text     = Localization.GetText("color_text_id");
            _colorLbl.Location = new System.Drawing.Point(10, 133);
            _colorLbl.Size     = new System.Drawing.Size(40, 25);

            _color          = new Button();
            _color.Parent   = _emptyFigureGroupBox;
            _color.Text     = Localization.GetText("color_text_id");
            _color.Location = new System.Drawing.Point(50, 133);
            _color.Size     = new System.Drawing.Size(100, 25);
            _color.Click   += delegate
            {
                try
                {
                    _xCommand.SetColor(Utilities.GetColor());
                }
                catch { }
            };

            _lineWidthLabel          = new Label();
            _lineWidthLabel.Parent   = _emptyFigureGroupBox;
            _lineWidthLabel.Text     = Localization.GetText("width_text_id");
            _lineWidthLabel.Location = new System.Drawing.Point(10, 168);
            _lineWidthLabel.Size     = new System.Drawing.Size(40, 25);


            _lineWidth        = new ComboBox();
            _lineWidth.Parent = _emptyFigureGroupBox;
            _lineWidth.Items.Add(1);
            _lineWidth.Items.Add(5);
            _lineWidth.Items.Add(10);
            _lineWidth.Items.Add(15);
            _lineWidth.Items.Add(20);
            _lineWidth.SelectedIndex = 0;
            _lineWidth.Text          = Localization.GetText("color_text_id");
            _lineWidth.Location      = new System.Drawing.Point(50, 168);
            _lineWidth.Size          = new System.Drawing.Size(100, 25);
            _lineWidth.Click        += delegate { try { _xCommand.SetLineWidth(Int32.Parse(_lineWidth.SelectedText)); } catch { } };

            // files
            _filesGroupBox          = new GroupBox();
            _filesGroupBox.Parent   = this;
            _filesGroupBox.Text     = Localization.GetText("file_text_id");
            _filesGroupBox.Location = new System.Drawing.Point(0, 492);
            _filesGroupBox.Size     = new System.Drawing.Size(Width - 5, 70);

            _save          = new Button();
            _save.Parent   = _filesGroupBox;
            _save.Text     = Localization.GetText("save_text_id");
            _save.Location = new System.Drawing.Point(10, 20);
            _save.Size     = new System.Drawing.Size(140, 25);
            _save.Click   += delegate { _xCommand.SaveInCloud(); };

            _open          = new Button();
            _open.Parent   = _filesGroupBox;
            _open.Text     = Localization.GetText("open_text_id");
            _open.Location = new System.Drawing.Point(10, 46);
            _open.Size     = new System.Drawing.Size(140, 25);
            _open.Click   += delegate { _xCommand.OpenFromCloud(); };

            Localization.OnLocalChange      += Localization_OnLocalChange;
            _xCommand.OnFigurePluginChanged += _xCommand_OnFigurePluginChanged;
            SkinController.OnSkinChange     += SkinController_OnSkinChange;
        }
예제 #10
0
 public void WriteHelp(IXCommand command)
 {
     Writer.WriteLine($"HELP - {command.GetName()}", ConsoleColor.Cyan, ConsoleColor.Blue);
     Writer.WriteLine(command.GetDescription(), ConsoleColor.Gray);
 }
예제 #11
0
        public PMainMenu(IXCommand xCommand)
        {
            _xCommand = xCommand;

            // MainMenu
            _fileBtn          = new ToolStripMenuItem(Localization.GetText("file_text_id"));
            _figureBtn        = new ToolStripMenuItem(Localization.GetText("figure_text_id"));
            _viewBtn          = new ToolStripMenuItem(Localization.GetText("view_text_id"));
            _tabBtn           = new ToolStripMenuItem(Localization.GetText("tab_text_id"));
            _pagesBtn         = new ToolStripMenuItem(Localization.GetText("pages_text_id"));
            _languageBtn      = new ToolStripMenuItem(Localization.GetText("language_text_id"));
            _figurePluginsBtn = new ToolStripMenuItem(Localization.GetText("figure_plugins_text_id"));
            _formatPluginsBtn = new ToolStripMenuItem(Localization.GetText("format_plugins_text_id"));
            _cloudBtn         = new ToolStripMenuItem(Localization.GetText("cloud_text_id"));
            _skinsBtn         = new ToolStripMenuItem(Localization.GetText("skins_text_id"));
            _helpBtn          = new ToolStripMenuItem(Localization.GetText("help_text_id"));

            // MainMenu: File
            _saveBtn = new ToolStripMenuItem(Localization.GetText("save_text_id"), null, delegate { _xCommand.FileSave(); });
            _openBtn = new ToolStripMenuItem(Localization.GetText("open_text_id"), null, delegate { _xCommand.FileOpen(); });
            _exitBtn = new ToolStripMenuItem(Localization.GetText("exit_text_id"), null, delegate { _xCommand.Exit(); });

            // MainMenu: Figure
            _typeBtn  = new ToolStripMenuItem(Localization.GetText("types_text_id"));
            _colorBtn = new ToolStripMenuItem(Localization.GetText("color_text_id"), null, delegate
            {
                try
                {
                    _xCommand.SetColor(Utilities.GetColor());
                }
                catch { }
            });
            _widthBtn = new ToolStripMenuItem(Localization.GetText("width_text_id"));

            // MainMenu: Figure: Type
            _lineBtn             = new ToolStripMenuItem(Localization.GetText("line_text_id"), null, delegate { _xCommand.SetType(XData.FigureType.Line); });
            _rectangleBtn        = new ToolStripMenuItem(Localization.GetText("rectangle_text_id"), null, delegate { _xCommand.SetType(XData.FigureType.Rectangle); });
            _roundedRectangleBtn = new ToolStripMenuItem(Localization.GetText("rounded_rectangle_text_id"), null, delegate { _xCommand.SetType(XData.FigureType.RoundRectangle); });
            _ellipseBtn          = new ToolStripMenuItem(Localization.GetText("ellipse_text_id"), null, delegate { _xCommand.SetType(XData.FigureType.Ellipse); });

            // MainMenu: Figure: Width
            _width1Btn  = new ToolStripMenuItem("1", null, delegate { _xCommand.SetLineWidth(1); });
            _width5Btn  = new ToolStripMenuItem("5", null, delegate { _xCommand.SetLineWidth(5); });
            _width10Btn = new ToolStripMenuItem("10", null, delegate { _xCommand.SetLineWidth(10); });
            _width15Btn = new ToolStripMenuItem("15", null, delegate { _xCommand.SetLineWidth(15); });
            _width20Btn = new ToolStripMenuItem("20", null, delegate { _xCommand.SetLineWidth(20); });

            // MainMenu: View
            _toolBarBtn    = new ToolStripMenuItem(Localization.GetText("tool_bar_text_id"), null, delegate { _xCommand.AddToolBar(); });
            _propertiesBtn = new ToolStripMenuItem(Localization.GetText("properties_text_id"), null, delegate { _xCommand.AddProperties(); });

            // MainMenu: Tab
            _newTabBtn    = new ToolStripMenuItem(Localization.GetText("new_tab_text_id"), null, delegate { _xCommand.NewTab(); });
            _renameTabBtn = new ToolStripMenuItem(Localization.GetText("rename_tab_text_id"), null, delegate { _xCommand.RenameTab(); });
            _closeTabBtn  = new ToolStripMenuItem(Localization.GetText("close_tab_text_id"), null, delegate { _xCommand.CloseTab(); });

            // MainMenu: Language
            _russianBtn   = new ToolStripMenuItem(Localization.GetText("russian_text_id"), null, delegate { _xCommand.RussianLanguage(); });
            _englishBtn   = new ToolStripMenuItem(Localization.GetText("english_text_id"), null, delegate { _xCommand.EnglishLanguage(); });
            _ukrainianBtn = new ToolStripMenuItem(Localization.GetText("ukrainian_text_id"), null, delegate { _xCommand.UkrainianLanguage(); });

            // MainMenu: Figure Plugins
            _simpleFigureBtn = new ToolStripMenuItem(Localization.GetText("simple_figure_text_id"), null, delegate { _xCommand.SimpleFigure(); });

            // MainMenu: Format Plugins
            //_jsonFormatBtn = new ToolStripMenuItem(Localization.GetText("json_text_id"), null, delegate { _xCommand.AddJSON(); });
            //_xmlFormatBtn = new ToolStripMenuItem(Localization.GetText("xml_text_id"), null, delegate { _xCommand.AddXML(); });
            //_yamlFormatBtn = new ToolStripMenuItem(Localization.GetText("yaml_text_id"), null, delegate { _xCommand.AddYAML(); });

            // MainMenu: Cloud
            _saveInCloudBtn   = new ToolStripMenuItem(Localization.GetText("save_text_id"), null, delegate { _xCommand.SaveInCloud(); });
            _loadFromCloudBtn = new ToolStripMenuItem(Localization.GetText("load_from_cloud_text_id"), null, delegate { _xCommand.OpenFromCloud(); });

            // MainMenu: Skins
            _skin1Btn = new ToolStripMenuItem(Localization.GetText("skin1_text_id"), null, delegate { _xCommand.Skin1(); });
            _skin2Btn = new ToolStripMenuItem(Localization.GetText("skin2_text_id"), null, delegate { _xCommand.Skin2(); });
            _skin3Btn = new ToolStripMenuItem(Localization.GetText("skin2_text_id"), null, delegate { _xCommand.Skin3(); });

            // MainMenu: Help
            _faqBtn   = new ToolStripMenuItem(Localization.GetText("faq_text_id"), null, delegate { _xCommand.ShowFAQ(); });
            _aboutBtn = new ToolStripMenuItem(Localization.GetText("about_text_id"), null, delegate { _xCommand.ShowAbout(); });

            FillMenu();

            Localization.OnLocalChange      += Localization_OnLocalChange;
            _xCommand.OnFigurePluginChanged += _xCommand_OnFigurePluginChanged;
            SkinController.OnSkinChange     += SkinController_OnSkinChange;
        }
예제 #12
0
 public void Start()
 {
     WriteSystemText(Environment.NewLine + "Starting X console.Please wait....");
     Thread.Sleep(2000);
     ;
     if (Config[CONSOLE_ENABL_KEY] == "1" || Config[CONSOLE_ENABL_KEY] == "yes")
     {
         WelcomeMessage();
         while (true)
         {
             Writer.Write(Prompt, ConsoleColor.Black, ConsoleColor.White);
             Writer.Write(" ");
             string command = Console.ReadLine();
             if (command == "quit" || command == "exit")
             {
                 Quit();
             }
             if (command == "clear" || command == "cls")
             {
                 Console.Clear();
                 WelcomeMessage();
             }
             else
             {
                 if (command == "help")
                 {
                     command = "list-commands";
                 }
                 var commandClass = FindCommand(command);
                 if (commandClass != null)
                 {
                     IXCommand instance = null;
                     try
                     {
                         instance = CreateCommandInstance(commandClass);
                     }
                     catch (Exception ex)
                     {
                         WriteSystemText("Error creating command instance.");
                         Writer.WriteLine(ex.Message, ConsoleColor.DarkRed);
                         instance = null;
                     }
                     if (instance != null)
                     {
                         try
                         {
                             instance.Run(this).GetAwaiter().GetResult();
                         }
                         catch (Exception ex)
                         {
                             WriteSystemText("Unhandled exception thrown while running the command.");
                             Writer.WriteLine(ex.Message, ConsoleColor.DarkRed);
                         }
                     }
                     else
                     {
                         WriteSystemText("Command instance is null. Cannot continue.");
                     }
                 }
                 else
                 {
                     WriteSystemText($"Could not find the command {command}.");
                 }
             }
         }
     }
     else
     {
         WriteSystemText("Console is disabled.");
         Quit();
     }
 }
예제 #13
0
 public void WriteInfo(IXCommand command, string text, bool appendNewLine = true)
 {
     Write(command, text, appendNewLine, ConsoleColor.Cyan);
 }
예제 #14
0
 public ActionOpen(IXCommand cmd)
 {
     this.cmd = cmd;
 }
예제 #15
0
 public void WriteWarning(IXCommand command, string text, bool appendNewLine = true)
 {
     Write(command, text, appendNewLine, ConsoleColor.Yellow);
 }
예제 #16
0
 public void WriteError(IXCommand command, string text, bool appendNewLine = true)
 {
     Write(command, text, appendNewLine, ConsoleColor.Red);
 }
예제 #17
0
 public void WriteSuccess(IXCommand command, string text, bool appendNewLine = true)
 {
     Write(command, text, appendNewLine, ConsoleColor.Green);
 }
예제 #18
0
 public ActionAddTab(IXCommand cmd)
 {
     this.cmd = cmd;
 }
예제 #19
0
 public void WriteException(IXCommand command, Exception ex)
 {
     Writer.WriteLine($"{command.GetName()} - Error Occurred ", ConsoleColor.White, ConsoleColor.Red);
     Writer.WriteLine(ex.Message, ConsoleColor.Red);
 }
예제 #20
0
 public ActionSelectTab(IXCommand cmd)
 {
     this.cmd = cmd;
 }
예제 #21
0
        public PToolBar(IXCommand xCommand)
        {
            _xCommand = xCommand;

            //File
            _fileLbl             = new ToolStripLabel(Localization.GetText("file_text_id"));
            _saveBtn             = new ToolStripButton(Localization.GetText("save_text_id"), null, delegate { _xCommand.FileSave(); });
            _saveBtn.ToolTipText = Localization.GetText("save_text_id");
            _loadBtn             = new ToolStripButton(Localization.GetText("load_text_id"), null, delegate { _xCommand.FileOpen(); });
            _loadBtn.ToolTipText = Localization.GetText("load_text_id");

            //Tab
            _tabLbl                   = new ToolStripLabel(Localization.GetText("tab_text_id"));
            _newTabBtn                = new ToolStripButton(Localization.GetText("new_text_id"), null, delegate { _xCommand.NewTab(); });
            _delTabBtn                = new ToolStripButton(Localization.GetText("del_text_id"), null, delegate { _xCommand.CloseTab(); });
            _renameTabBtn             = new ToolStripButton(Localization.GetText("rename_text_id"), null, delegate { _xCommand.RenameTab(); });
            _newTabBtn.ToolTipText    = Localization.GetText("new_text_id");
            _delTabBtn.ToolTipText    = Localization.GetText("del_text_id");
            _renameTabBtn.ToolTipText = Localization.GetText("rename_text_id");

            //Figure
            _figureLbl = new ToolStripLabel(Localization.GetText("figure_text_id"));
            _typeCbx   = new ToolStripComboBox();

            _lineBtn             = new ToolStripMenuItem(Localization.GetText("line_text_id"), null, delegate { _xCommand.SetType(XData.FigureType.Line); });
            _rectangleBtn        = new ToolStripMenuItem(Localization.GetText("rectangle_text_id"), null, delegate { _xCommand.SetType(XData.FigureType.Rectangle); });
            _roundedRectangleBtn = new ToolStripMenuItem(Localization.GetText("rounded_rectangle_text_id"), null, delegate { _xCommand.SetType(XData.FigureType.RoundRectangle); });
            _ellipseBtn          = new ToolStripMenuItem(Localization.GetText("ellipse_text_id"), null, delegate { _xCommand.SetType(XData.FigureType.Ellipse); });


            _widthCbx = new ToolStripComboBox();

            _width1Btn  = new ToolStripMenuItem("1", null, delegate { _xCommand.SetLineWidth(1); });
            _width5Btn  = new ToolStripMenuItem("5", null, delegate { _xCommand.SetLineWidth(5); });
            _width10Btn = new ToolStripMenuItem("10", null, delegate { _xCommand.SetLineWidth(10); });
            _width15Btn = new ToolStripMenuItem("15", null, delegate { _xCommand.SetLineWidth(15); });
            _width20Btn = new ToolStripMenuItem("20", null, delegate { _xCommand.SetLineWidth(20); });


            _colorBtn = new ToolStripButton(Localization.GetText("color_text_id"), null, delegate
            {
                try
                {
                    _xCommand.SetColor(Utilities.GetColor());
                }
                catch { }
            });

            Items.Add(_fileLbl);
            Items.Add(_saveBtn);
            Items.Add(_loadBtn);
            Items.Add(new ToolStripSeparator());
            Items.Add(_tabLbl);
            Items.Add(_newTabBtn);
            Items.Add(_delTabBtn);
            Items.Add(_renameTabBtn);
            Items.Add(new ToolStripSeparator());

            Items.Add(_figureLbl);
            Items.Add(_typeCbx);
            _typeCbx.Items.Add(_lineBtn);
            _typeCbx.Items.Add(_rectangleBtn);
            _typeCbx.Items.Add(_roundedRectangleBtn);
            _typeCbx.Items.Add(_ellipseBtn);
            _typeCbx.SelectedItem = _lineBtn;

            Items.Add(_widthCbx);
            _widthCbx.Items.Add(_width1Btn);
            _widthCbx.Items.Add(_width5Btn);
            _widthCbx.Items.Add(_width10Btn);
            _widthCbx.Items.Add(_width15Btn);
            _widthCbx.Items.Add(_width20Btn);
            //_widthCbx.Items.Add(1);
            //_widthCbx.Items.Add(5);
            //_widthCbx.Items.Add(10);
            //_widthCbx.Items.Add(15);
            //_widthCbx.Items.Add(20);
            _widthCbx.SelectedItem = _width1Btn;
            // _widthCbx.Click += delegate { try { _xCommand.SetLineWidth(Int32.Parse(_widthCbx.SelectedText)); } catch { } };

            Items.Add(_colorBtn);

            Localization.OnLocalChange  += Localization_OnLocalChange;
            SkinController.OnSkinChange += SkinController_OnSkinChange;
        }