Ejemplo n.º 1
0
 private void Client_OnJoinedChannel(object sender, TwitchLib.Events.Client.OnJoinedChannelArgs e)
 {
     OutputTextBox.Invoke((MethodInvoker) delegate
     {
         OutputTextBox.Text = "Join successfull!\n";
     });
 }
Ejemplo n.º 2
0
        private void DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            IsDownloading = false;
            if (NotifyOnDone)
            {
                Invoke(new MethodInvoker(() => Notify()));
            }
            Invoke(new MethodInvoker(() =>
            {
                UnlockButtons();
                StopAsyncButton.Enabled = false;
                OutputTextBox.Clear();
            }));

            if (e.Cancelled)
            {
                Invoke(new MethodInvoker(() => OutputTextBox.Text = $"Cancelled downloading for {((DownloadSession)sender).FileName}"));
            }
            else if (e.Error != null)
            {
                Invoke(new MethodInvoker(() =>
                                         ErrorTextBox.Text = $@"{e.Error.Message}
                    { e.Error.StackTrace}
                    { e.Error?.InnerException?.Message }
                    { e.Error?.InnerException?.StackTrace}"
                                         ));
            }
            else
            {
                Invoke(new MethodInvoker(() => OutputTextBox.Text = $"Finished downloading for {((DownloadSession)sender).FileName}"));
                File.WriteAllBytes(string.Format(@"\\?\{0}{1}", downloadLocation, ((DownloadSession)sender).FileName), e.Result);
            }
        }
Ejemplo n.º 3
0
        private void TransferButton_Click(object sender, EventArgs e)
        {
            var count = InputTextBox.Text.Count(Char.IsDigit);

            string[] TextToTransfer = new string[count];

            OutputTextBox.Clear();

            using (StringReader reader = new StringReader(InputTextBox.Text))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    // Do something with the line
                    line = _defaultPhrase + SpacesPhrase + line;

                    if (!string.IsNullOrWhiteSpace(OutputTextBox.Text))
                    {
                        OutputTextBox.AppendText("\r\n" + line);
                    }
                    else
                    {
                        OutputTextBox.AppendText(line);
                    }
                    OutputTextBox.ScrollToCaret();
                }
            }
        }
Ejemplo n.º 4
0
 //Update any user input into Argument textbox into Argument property of selected tool.
 private void Run_Click(object sender, EventArgs e)
 {
     if (MultiHostCheckBox.Checked == true)
     {
         try
         {
             string[] inputIps = File.ReadAllLines(HostsTextBox.Text);
             foreach (string ip in inputIps)
             {
                 tools[(string)ToolsListBox.SelectedItem].Client = ClientTextBox.Text;
                 tools[(string)ToolsListBox.SelectedItem].DeployString = SyntaxTextBox.Text.Replace("x.x.x.x", ip);
                 tools[(string)ToolsListBox.SelectedItem].AutoLog = AutoLoggingcheckBox.Checked;
                 OutputTextBox.AppendText(tools[(string)ToolsListBox.SelectedItem].Deploy(ip, UsernameTextBox.Text, PasswordTextBox.Text));
             }
         }
         catch (Exception)
         {
             MessageBox.Show("Error: Cannot deploy tool.");
         }
     }
     else
     {
         tools[(string)ToolsListBox.SelectedItem].Client = ClientTextBox.Text;
         tools[(string)ToolsListBox.SelectedItem].DeployString = SyntaxTextBox.Text;
         tools[(string)ToolsListBox.SelectedItem].AutoLog = AutoLoggingcheckBox.Checked;
         OutputTextBox.AppendText(tools[(string)ToolsListBox.SelectedItem].Deploy(IPTextBox.Text, UsernameTextBox.Text, PasswordTextBox.Text));
     }
 }
Ejemplo n.º 5
0
 private async Task CollectAsync(Server server, string type)
 {
     try
     {
         OutputTextBox.AppendText(string.Format("Coletando Logs de {0}...\n", server.Host));
         string             collectCommand = string.Format("racadm techsupreport collect -t {0}", type);
         IdracSshController idrac          = new IdracSshController(server);
         string             result         = idrac.RunCommand(collectCommand);
         string             jobLine        = result.Split('\n').FirstOrDefault();
         string             jobId          = jobLine.Split('=')[1].Trim();
         IdracJob           job            = await new JobController(server).GetJobAsync(jobId);
         var load = new LoadWindow(server, job)
         {
             Title = server.Host
         };
         load.Closed += (object sender, EventArgs e) =>
         {
             var window = (LoadWindow)sender;
             job = window.Job;
             if (job.JobState.Contains("Completed"))
             {
                 ExportTsr(server);
             }
         };
         load.Show();
     }
     catch (Exception ex)
     {
         OutputTextBox.AppendText(string.Format("Falha ao coletar TSR de {0}, {1}\n", server.Host, ex.Message));
     }
 }
Ejemplo n.º 6
0
        private void ExportTsr(Server server)
        {
            string exportCommand = string.Format(@"racadm -r {0} -u {1} -p {2} techsupreport export -f {3}\{4}.zip",
                                                 server.Host, server.User, server.Password, KnownFolders.Downloads.Path, server.Host);

            System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo()
            {
                WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden,
                FileName    = "cmd.exe",
                Arguments   = string.Format(@"/C {0}", exportCommand)
            };

            System.Diagnostics.Process process = new System.Diagnostics.Process()
            {
                StartInfo = info
            };
            process.Start();
            process.WaitForExit();

            if (process.ExitCode == 0)
            {
                OutputTextBox.AppendText(string.Format("Logs de {0} coletados com sucesso ! salvo em {1}\n", server.Host, KnownFolders.Downloads.Path));
            }
            else
            {
                OutputTextBox.AppendText(string.Format("Falha ao coletar os Logs de {0}\n", server.Host));
            }
        }
Ejemplo n.º 7
0
        public void WriteLine(string line, params object[] arguments)
        {
            //Check if the application is shutting down to prevent timed invokes on the output text from piling up
            if (ShuttingDown)
            {
                return;
            }

            line = string.Format(line, arguments);
            line = string.Format("{0} {1}", Nil.Time.Timestamp(), line);
            if (IsFirstLine)
            {
                IsFirstLine = false;
            }
            else
            {
                line = "\n" + line;
            }

            var action = (Action) delegate
            {
                lock (OutputTextBox)
                {
                    OutputTextBox.AppendText(line);
                    OutputTextBox.ScrollToEnd();
                }
            };

            OutputTextBox.Dispatcher.Invoke(action);
        }
Ejemplo n.º 8
0
 private async Task RunScriptAsync(string path)
 {
     foreach (Server server in ServersListBox.Items)
     {
         if (!await NetworkHelper.CheckConnectionAsync(server.Host))
         {
             OutputTextBox.AppendText(string.Format("Servidor {0} inacessivel.\n", server.Host));
             continue;
         }
         try
         {
             OutputTextBox.AppendText(string.Format("Aplicando script para {0}\n", server.Host));
             var      idrac  = new IdracSshController(server);
             string[] script = File.ReadAllLines(path);
             foreach (var command in script)
             {
                 idrac.RunCommand(command);
             }
         }
         catch (Exception ex)
         {
             OutputTextBox.AppendText(string.Format("Falha ao executar o script para {0} : {1}\n", server.Host, ex.Message));
         }
     }
     ApplyButton.IsEnabled = true;
     ClearButton.IsEnabled = true;
 }
Ejemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(fileTxtName.Text))
            {
                OutputTextBox.AppendText("<REPORTER>: The txt path box is empty.");
                OutputTextBox.AppendText("<REPORTER>: Please add the txt path.");
            }

            else if (String.IsNullOrEmpty(fileCfgName.Text))
            {
                OutputTextBox.AppendText("<REPORTER>: The cfg path box is empty.");
                OutputTextBox.AppendText("<REPORTER>: Please add the cfg path.");
            }

            else if (String.IsNullOrEmpty(fileTxtName.Text) && String.IsNullOrEmpty(fileCfgName.Text))
            {
                OutputTextBox.AppendText("<REPORTER>: The txt and cfg path boxes are empty.");
                OutputTextBox.AppendText("<REPORTER>: Please add both paths.");
            }

            else
            {
                CH_Generate();
            }
        }
Ejemplo n.º 10
0
        private void CreateButton_Click(object sender, EventArgs e)
        {
            //
            // Create the output array
            //
            OutputTextBox.Text = "";
            OutputTextBox.Refresh();

            if (InputTextBox.Text.Length == 0)
            {
                return;
            }

            Int32 l = (4 - ((InputTextBox.Text.Length) % 4)) % 4;

            Byte[] tmpB = Encoding.ASCII.GetBytes(InputTextBox.Text +
                                                  sb.ToString().Substring(0, l));
            Int32 f = tmpB.Length;

            Byte[] tmpR = new Byte[f * 2];

            byteRandom.NextBytes(tmpR);

            for (Int32 i = 0; i < tmpB.Length; i++)
            {
                tmpR[i + f] = (Byte)(tmpB[i] ^ tmpR[i]);
            }

            BuildArray(tmpR, 4, "tmpR");
        }
Ejemplo n.º 11
0
        private async Task UpdateJobsAsync()
        {
            timer.Stop();
            foreach (var job in currentJobs.Values)
            {
                try
                {
                    var idrac      = new JobController(job.Server);
                    var updatedJob = await idrac.GetJobAsync(job.Job.Id);

                    currentJobs.AddOrUpdate(job.Job.Id, new ServerJob()
                    {
                        Server = job.Server, Job = updatedJob, SerialNumber = job.SerialNumber
                    },
                                            (key, existingVal) =>
                    {
                        existingVal.Job.Message         = updatedJob.Message;
                        existingVal.Job.PercentComplete = updatedJob.PercentComplete;
                        existingVal.Job.JobState        = updatedJob.JobState;
                        return(existingVal);
                    });
                }
                catch (Exception ex)
                {
                    OutputTextBox.AppendText(string.Format("Falha ao obter dados de {0} {1}\n", job.Server, ex.Message));
                    timer.Start();
                    return;
                }
            }
            JobsDataGrid.ItemsSource = currentJobs.Values;
            timer.Start();
        }
Ejemplo n.º 12
0
 private void ClearButton_Click(object sender, EventArgs e)
 {
     InputTextTextBox.Clear();
     OutputTextBox.Clear();
     secetWordTextBox.Clear();
     secetWordTextBox.Focus();
 }
        public NightcoreWindow(NightcoreWindowEnumeration setting)
        {
            InitializeComponent();

            Setting = setting;


            switch (Setting)
            {
            case NightcoreWindowEnumeration.Single:
                Title += "Single";
                InputTextBox.SetValue(TextBoxHelper.WatermarkProperty,
                                      (InputTextBox.GetValue(TextBoxHelper.WatermarkProperty) as string) + " (File)");
                OutputTextBox.SetValue(TextBoxHelper.WatermarkProperty,
                                       (OutputTextBox.GetValue(TextBoxHelper.WatermarkProperty) as string) + " (File)");
                break;

            case NightcoreWindowEnumeration.Multiple:
                Title += "Multiple";
                InputTextBox.SetValue(TextBoxHelper.WatermarkProperty,
                                      (InputTextBox.GetValue(TextBoxHelper.WatermarkProperty) as string) + " (Directory)");
                OutputTextBox.SetValue(TextBoxHelper.WatermarkProperty,
                                       (OutputTextBox.GetValue(TextBoxHelper.WatermarkProperty) as string) + " (Directory)");
                break;
            }

            InputTextBox.SetValue(TextBoxHelper.WatermarkProperty,
                                  (InputTextBox.GetValue(TextBoxHelper.WatermarkProperty) as string) + "...");
            OutputTextBox.SetValue(TextBoxHelper.WatermarkProperty,
                                   (OutputTextBox.GetValue(TextBoxHelper.WatermarkProperty) as string) + "...");
        }
Ejemplo n.º 14
0
        private async Task UpdateJobsAsync()
        {
            timer.Stop();
            foreach (ServerJob job in currentJobs.Values)
            {
                try
                {
                    var idrac      = new JobController(job.Server);
                    var updatedJob = await idrac.GetJobAsync(job.Job.Id);

                    currentJobs.AddOrUpdate(job.Job.Id, new ServerJob()
                    {
                        Server = job.Server, Job = updatedJob, SerialNumber = job.SerialNumber
                    },
                                            (key, existingVal) =>
                    {
                        existingVal.Job.Message         = updatedJob.Message;
                        existingVal.Job.PercentComplete = updatedJob.PercentComplete;
                        existingVal.Job.JobState        = updatedJob.JobState;
                        return(existingVal);
                    });
                }
                catch
                {
                    OutputTextBox.AppendText("Falha ao atualizar status dos Jobs\n");
                    timer.Start();
                    return;
                }
            }
            JobsDataGrid.ItemsSource = currentJobs.Values;
            timer.Start();
        }
Ejemplo n.º 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RandomButton_Click(object sender, EventArgs e)
        {
            InputTextBox.Clear();
            OutputTextBox.Clear();
            TimeBox.Clear();
            CountText.Clear();

            int    n    = rnd.Next(2, 20);
            int    k    = rnd.Next(1, n);
            string line = null;

            for (int i = 0; i < k; i++)
            {
                int temp1 = rnd.Next(1, n);
                int temp2 = rnd.Next(1, n);
                if (temp1 != temp2)
                {
                    line += temp1 + " " + temp2 + "\n";
                    i++;
                }
            }
            if (line != null)
            {
                InputTextBox.Text = line.Trim();
            }
            CountText.Text = n + " " + k;
        }
Ejemplo n.º 16
0
        private void RevertButton_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            var dialogResult = MessageBox.Show(
                "Do you really want to revert all changes?",
                "Are you sure?",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Question,
                MessageBoxDefaultButton.Button2);

            if (dialogResult != DialogResult.Yes)
            {
                return;
            }

            Cursor.Current = Cursors.WaitCursor;

            _hostsFileAccess.RemoveUrls();
            _spotifyUpdateDirectoryAccess.Allow();

            if (CleanupCheckBox.Checked)
            {
                var uninstaller = new Uninstaller(OutputTextBox);
                uninstaller.UninstallSpotify();
            }

            SetUiAndConfig(false);

            OutputTextBox.AppendText("\r\nAll changes successfully reverted!", Color.Green);
            OutputTextBox.AppendText(_textBoxSeparator);

            SystemSounds.Asterisk.Play();
        }
        private void InitializeQuestionnaire(FileInfo qlFile)
        {
            try
            {
                var form   = ParseQLFile(qlFile);
                var report = ValidateQuestionForm(form);

                OutputTextBox.AppendText(report.ToString());

                if (report.NrOfErrors == 0)
                {
                    var ui = BuildUI(form);
                    SplitPanel.Panel1.Controls.Add(ui);
                }
                else
                {
                    MessageBox.Show("Validation errors in the questionnaire AST. See Output Window for details."
                                    , "Validation errors", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    SplitPanel.Panel2Collapsed = false;
                }
            }
            catch (Exception ex)
            {
                Output.WriteLine("ERROR - {0}", ex.ToString());
                MessageBox.Show("Exception occured. See Output Window for details.", "Unhandled exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 18
0
 private void OnLedMatrixDisplayed()
 {
     OutputTextBox.Text = new StringBuilder(OutputTextBox.Text)
                          .Append("The matrix you have sent has been displayed." + "\n")
                          .ToString();
     OutputTextBox.ScrollToBottom();
 }
Ejemplo n.º 19
0
        public OutputWindow()
        {
            InitializeComponent();

            Dock = DockStyle.Fill;
            //OutputTextBox.Dock = DockStyle.None;
            //OutputTextBox.Width = 300;
            //OutputTextBox.Height = 4000;
            OutputTextBox.ScrollBars = RichTextBoxScrollBars.Horizontal;
            Controls.Add(OutputTextBox);
            Controls.Add(vScrollBar);
            //Controls.Add(hScrollBar);

            using (var g = OutputTextBox.CreateGraphics())
            {
                _lineHeight = TextRenderer.MeasureText(g, "I", OutputTextBox.Font).Height;
            }

            OutputTextBox.MouseWheel += (s, a) => OnMouseWheel(a);

            vScrollBar.Scroll += (sender, args) => RefreshOutput();

            OutputTextBox.MouseDoubleClick += (sender, args) => { ClickedLine(args.Location.Y / _lineHeight); };

            ResumeLayout();
        }
Ejemplo n.º 20
0
 private void ClearButton_Click(object sender, EventArgs e)
 {
     InputTextBox.Clear();
     OutputTextBox.Clear();
     arrayLengthLabel.Text = "Длина массива:";
     timeSortLabel.Text    = "Время работы сортировки:";
 }
Ejemplo n.º 21
0
        private void mDoScriptAnalyzis()
        {
            logLabel.Text = "Running analysis...";
            OutputTextBox.Clear();
            using (var templateAccessor = new TemplateListAccessor())
            {
                if (templateAccessor.ExecuteTemplate(scriptFilePathTextBox.Text) == true)
                {
                    logLabel.Text = "Script complies with an expected predef.lua script";
                    List <Template> templateList = templateAccessor.GetAllTemplates();

                    foreach (Template template in templateList)
                    {
                        string s = "id = " + template.ID.ToString() + " - " +
                                   "classid = " + template.Class.ToString() + "\n";
                        OutputTextBox.AppendText(s);
                    }
                }
                else
                {
                    OutputTextBox.AppendText(templateAccessor.GetLastExecutionError());
                    logLabel.Text = "Script DOES NOT comply with an expected predef.lua script";
                }
            }
        }
Ejemplo n.º 22
0
        private void GenerateButtonClick(object sender, EventArgs e)
        {
            int  number;
            bool result = int.TryParse(NumberOfGuidsTextBox.Text, out number);

            if (!result)
            {
                MessageBox.Show("Invalid number specified");
                return;
            }

            OutputTextBox.Clear();

            var sb = new StringBuilder();

            for (int i = 0; i < number; i++)
            {
                var x    = Guid.NewGuid();
                var guid = IncludeDashesCheckBox.Checked ? x.ToString() : x.ToString().Replace("-", "");

                sb.Append(guid);
                sb.Append("\r\n");
            }

            OutputTextBox.Text = sb.ToString();
        }
Ejemplo n.º 23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ClearButton_Click(object sender, EventArgs e)
 {
     InputTextBox.Clear();
     OutputTextBox.Clear();
     TimeBox.Clear();
     CountText.Clear();
 }
Ejemplo n.º 24
0
        private async Task ExportScpFileAsync(Server server, string target, string exportUse)
        {
            if (!await NetworkHelper.CheckConnectionAsync(server.Host))
            {
                MessageBox.Show("Servidor inacessivel", "Erro", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            try
            {
                ScpController idrac = new ScpController(server);
                ExportButton.IsEnabled = false;
                OutputTextBox.AppendText(string.Format("Exportando configurações de {0}...\n", server.Host));
                IdracJob job = await idrac.ExportScpFileAsync(target, exportUse);

                var load = new LoadWindow(server, job)
                {
                    Title = server.Host
                };
                load.Closed += async(object sender, EventArgs e) =>
                {
                    var window = (LoadWindow)sender;
                    job = window.Job;
                    if (job.JobState.Contains("Completed"))
                    {
                        await SaveFileAsync(server, job);
                    }
                };
                load.Show();
            }
            catch (Exception ex)
            {
                OutputTextBox.AppendText(string.Format("Falha ao exportar arquivo: {0}\n", ex.Message));
                ExportButton.IsEnabled = true;
            }
        }
Ejemplo n.º 25
0
        private async Task ImportScpAsync(string path, string target, string shutdown)
        {
            foreach (Server server in ServersListBox.Items)
            {
                if (!await NetworkHelper.CheckConnectionAsync(server.Host))
                {
                    OutputTextBox.AppendText(string.Format("Servidor {0} inacessivel, verifique a conexão e tente novamente.\n", server.Host));
                    continue;
                }
                try
                {
                    OutputTextBox.AppendText(string.Format("Importando configurações para {0}...\n", server.Host));
                    ScpController idrac = new ScpController(server);
                    IdracJob      job   = await idrac.ImportScpFileAsync(path, target, shutdown, "On");

                    OutputTextBox.AppendText(string.Format("Job {0} criado para servidor {1}\n", job.Id, server));
                    var chassisIdrac = new ChassisController(server);
                    var chassis      = await chassisIdrac.GetChassisAsync();

                    currentJobs.TryAdd(job.Id, new ServerJob()
                    {
                        Job = job, SerialNumber = chassis.SKU, Server = server
                    });
                }
                catch (Exception ex)
                {
                    OutputTextBox.AppendText(string.Format("Falha ao importar arquivo para {0} {1}\n", server.Host, ex.Message));
                }
            }
            ImportButton.IsEnabled = true;
        }
Ejemplo n.º 26
0
        private void SubmitInputButton_Click(object sender, EventArgs e)
        {
            try
            {
                string RusKey = "Ё!\"№;%:?*()_+ЙЦУКЕНГШЩЗХЪ/ФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,ё1234567890-=йцукенгшщзхъ\\фывапролджэячсмитьбю. ";
                string EngKey = "~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:\"ZXCVBNM<>?`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./ ";


                string Text       = InputTextBox.Text;
                string OutputText = "";

                for (int i = 0; i < Text.Length; i++)
                {
                    try
                    {
                        OutputText += EngKey.Substring(RusKey.IndexOf(Text[i]), 1);
                    }
                    catch
                    {
                        OutputText += RusKey.Substring(EngKey.IndexOf(Text[i]), 1);
                    }
                }


                OutputTextBox.Clear();
                OutputTextBox.AppendText(OutputText);
                MessageBox.Show("Успешно переведено                                                  ");
            }
            catch
            {
                MessageBox.Show("Что-то пошло не так                                                      ");
            }
        }
Ejemplo n.º 27
0
 private void OutputTextBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Control && e.KeyCode == Keys.A)
     {
         OutputTextBox.SelectAll();
     }
 }
Ejemplo n.º 28
0
        private void OutputTextBox_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int Line = OutputTextBox.GetLineFromCharIndex(OutputTextBox.GetCharIndexFromPosition(e.Location));

            if (ErrorsAndWarningsDict.ContainsKey(Line))
            {
                if (LastHighlitedLine != -1)
                {
                    CleanHighlight(LastHighlitedLine);
                }
                HighlightLine(Line, Color.Blue, Color.White);
                WEMessage mes = ErrorsAndWarningsDict[Line];
                if ((mes.MessageObject as FileMessageObject) != null)
                {
                    FileMessageObject FMO = mes.MessageObject as FileMessageObject;
                    if (File.Exists(FMO.File))
                    {
                        PKStudio.Helpers.EditorsFormsController.EditFileDescriptor comp = new PKStudio.Helpers.EditorsFormsController.EditFileDescriptor();
                        comp.Path   = FMO.File;
                        comp.Line   = FMO.LineNumber;
                        comp.Column = FMO.ColumnNumber;
                        this.OnEditEvent(comp);
                    }
                }
                if ((mes.MessageObject as ComponentMessageObject) != null)
                {
                    ComponentMessageObject CMO = mes.MessageObject as ComponentMessageObject;
                    this.OnEditEvent(CMO.Component);
                }
            }
        }
Ejemplo n.º 29
0
 private void ResetTextButton_Click(object sender, EventArgs e)
 {
     InputTextBox.Clear();
     OutputTextBox.Clear();
     CopyToBufferButton.Enabled = false;
     ActiveControl = InputTextBox;
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DebugLogWindow"/> class.
        /// </summary>
        /// <param name="editor">The editor.</param>
        public OutputLogWindow(Editor editor)
            : base(editor, true, ScrollBars.None)
        {
            Title        = "Output Log";
            ClipChildren = false;

            // Setup UI
            _viewDropdown = new Button(2, 2, 40.0f, TextBoxBase.DefaultHeight)
            {
                TooltipText = "Change output log view options",
                Text        = "View",
                Parent      = this,
            };
            _viewDropdown.Clicked += OnViewButtonClicked;
            _searchBox             = new TextBox(false, _viewDropdown.Right + 2, 2, Width - _viewDropdown.Right - 2 - _scrollSize)
            {
                WatermarkText = "Search...",
                Parent        = this,
            };
            _searchBox.TextChanged += Refresh;
            _hScroll = new HScrollBar(this, Height - _scrollSize, Width - _scrollSize, _scrollSize)
            {
                ThumbThickness = 10,
                Maximum        = 0,
            };
            _hScroll.ValueChanged += OnHScrollValueChanged;
            _vScroll = new VScrollBar(this, Width - _scrollSize, Height, _scrollSize)
            {
                ThumbThickness = 10,
                Maximum        = 0,
            };
            _vScroll.ValueChanged += OnVScrollValueChanged;
            _output = new OutputTextBox
            {
                Window      = this,
                IsReadOnly  = true,
                IsMultiline = true,
                BackgroundSelectedFlashSpeed = 0.0f,
                Location = new Float2(2, _viewDropdown.Bottom + 2),
                Parent   = this,
            };
            _output.TargetViewOffsetChanged += OnOutputTargetViewOffsetChanged;
            _output.TextChanged             += OnOutputTextChanged;

            // Setup context menu
            _contextMenu = new ContextMenu();
            _contextMenu.AddButton("Clear log", Clear);
            _contextMenu.AddButton("Copy selection", _output.Copy);
            _contextMenu.AddButton("Select All", _output.SelectAll);
            _contextMenu.AddButton("Show in explorer", () => FileSystem.ShowFileExplorer(Path.Combine(Globals.ProjectFolder, "Logs")));
            _contextMenu.AddButton("Scroll to bottom", () => { _vScroll.TargetValue = _vScroll.Maximum; }).Icon = Editor.Icons.ArrowDown12;

            // Setup editor options
            Editor.Options.OptionsChanged += OnEditorOptionsChanged;
            OnEditorOptionsChanged(Editor.Options.Options);

            GameCooker.Event += OnGameCookerEvent;
            ScriptsBuilder.CompilationFailed += OnScriptsCompilationFailed;
        }
Ejemplo n.º 31
0
 protected override TextBox CreateOutputBox()
 {
   OutputTextBox Result = new OutputTextBox(this);
   Result.CustomWordBreaks = true;
   Result.DragEnter += OutputBox_DragEnter;
   Result.DragOver += OutputBox_DragOver;
   Result.DragLeave += OutputBox_DragLeave;
   Result.DragDrop += OutputBox_DragDrop;
   Result.DataBindings.Add(new Binding("BackColor", Settings.Default, "BackColor", true, DataSourceUpdateMode.Never));
   Result.DataBindings.Add(new Binding("ForeColor", Settings.Default, "ForeColor", true, DataSourceUpdateMode.Never));
   return Result;
 }