Example #1
0
        /// <summary>Open the XML file 'filename'</summary>
        public void OpenFile(string filepath = null)
        {
            try
            {
                if (!filepath.HasValue())
                {
                    using (var fd = new OpenFileDialog {
                        Title = "Open an XML File", Filter = Util.FileDialogFilter("Extensible Mark-Up Language", "*.xml")
                    })
                    {
                        if (fd.ShowDialog(this) != DialogResult.OK)
                        {
                            return;
                        }
                        filepath = fd.FileName;
                    }
                }

                var file = new XmlTree(filepath);
                m_dock.Add(file, EDockSite.Centre);
            }
            catch (Exception ex)
            {
                MsgBox.Show(this, $"Failed to load XML file {filepath}\r\n{ex.Message}", "Load XML File Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
 protected override void Dispose(bool disposing)
 {
     Util.DisposeAll(m_diag.Elements.ToArray());
     Util.Dispose(ref m_diag);
     Util.Dispose(ref components);
     base.Dispose(disposing);
 }
Example #3
0
 protected override void Dispose(bool disposing)
 {
     Util.Dispose(ref m_series);
     Util.Dispose(ref m_obj0);
     Util.Dispose(ref components);
     base.Dispose(disposing);
 }
Example #4
0
 protected override void Dispose(bool disposing)
 {
     WorkerThreadActive = false;
     m_midi.Shutdown();
     Util.Dispose(m_audio);
     base.Dispose(disposing);
 }
Example #5
0
 protected override void Dispose(bool disposing)
 {
     DD        = null;
     FileInfos = null;
     Main      = null;
     Util.Dispose(ref components);
     base.Dispose(disposing);
 }
        public AndroidConnectDeviceUI(AndroidLogcat settings)
        {
            InitializeComponent();

            m_tt = new ToolTip();

            // Connection type combo
            m_combo_connection_type.ToolTip(m_tt, "Select the method used to connect to the android device");
            m_combo_connection_type.DataSource            = new[] { "USB", "TCP/IP" };
            m_combo_connection_type.SelectedIndex         = (int)settings.ConnectionType;
            m_combo_connection_type.SelectedIndexChanged += (s, a) =>
            {
                settings.ConnectionType    = (AndroidLogcat.EConnectionType)m_combo_connection_type.SelectedIndex;
                m_combo_ip_address.Enabled = settings.ConnectionType == AndroidLogcat.EConnectionType.Tcpip;
                m_edit_port.Enabled        = settings.ConnectionType == AndroidLogcat.EConnectionType.Tcpip;
            };

            // IP Address
            m_combo_ip_address.ToolTip(m_tt, "The IP address of the android device");
            m_combo_ip_address.Load(settings.IPAddressHistory);
            m_combo_ip_address.Enabled = settings.ConnectionType == AndroidLogcat.EConnectionType.Tcpip;

            // Port
            m_edit_port.ToolTip(m_tt, "The port on which to connect to the android device, typically (5555)");
            m_edit_port.Text         = settings.ConnectionPort.ToString(CultureInfo.InvariantCulture);
            m_edit_port.Enabled      = settings.ConnectionType == AndroidLogcat.EConnectionType.Tcpip;
            m_edit_port.TextChanged += (s, a) =>
            {
                int port;
                if (int.TryParse(m_edit_port.Text, out port))
                {
                    m_edit_port.BackColor   = Misc.FieldBkColor(false);
                    settings.ConnectionPort = port;
                }
                else
                {
                    m_edit_port.BackColor = SystemColors.ControlLight;
                }
            };

            FormClosing += (s, a) =>
            {
                if (DialogResult == DialogResult.OK)
                {
                    settings.IPAddressHistory = Util.AddToHistoryList(settings.IPAddressHistory, m_combo_ip_address.Text, false, Constants.MaxHistoryDefault);
                }
            };

            Disposed += (s, a) =>
            {
                m_tt.Dispose();
            };
        }
Example #7
0
        protected override void Dispose(bool disposing)
        {
            if (m_view3d != null)
            {
                m_view3d.View3d.DeleteObjects(new[] { m_demo_objs }, 1, 0);
            }

            Util.Dispose(ref m_giz);
            Util.Dispose(ref m_tex0);
            Util.Dispose(ref m_tex2);
            Util.Dispose(ref m_obj0);
            Util.Dispose(ref m_obj1);
            Util.Dispose(ref m_obj2);
            Util.Dispose(ref m_obj3);
            Util.Dispose(ref m_view3d);
            Util.Dispose(ref components);
            base.Dispose(disposing);
        }
Example #8
0
        /// <summary></summary>
        private void PlayWave()
        {
            if (!m_tb_wav_filepath.Text.HasValue())
            {
                using (var dlg = new OpenFileDialog {
                    Title = "Open WAV file", Filter = Util.FileDialogFilter("Wave Files", "*.wav")
                })
                {
                    if (dlg.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }
                    m_tb_wav_filepath.Text = dlg.FileName;
                }
            }

            if (m_tb_wav_filepath.Text.HasValue())
            {
                m_audio.PlayFile(m_tb_wav_filepath.Text);
            }
        }
Example #9
0
 protected override void Dispose(bool disposing)
 {
     DockControl = Util.Dispose(DockControl);
     base.Dispose(disposing);
 }
Example #10
0
        /// <summary>Set up UI elements</summary>
        private void SetupUI()
        {
            // Output file
            m_tb_output_filepath.ToolTip(m_tt, "The path of the file to export to");
            m_tb_output_filepath.ValueType     = typeof(string);
            m_tb_output_filepath.Text          = OutputFilepath;
            m_tb_output_filepath.ValueChanged += (s, a) =>
            {
                OutputFilepath = m_tb_output_filepath.Text;
                UpdateUI();
            };

            // Browse button
            m_btn_browse.ToolTip(m_tt, "Browse to the location of where to save the file");
            m_btn_browse.Click += (s, a) =>
            {
                var filter = Util.FileDialogFilter("Text Files", "*.txt", "Comma Separated Values", "*.csv", "All Files", "*.*");
                var dg     = new SaveFileDialog
                {
                    Title    = "Choose an output file name",
                    FileName = OutputFilepath,
                    Filter   = filter,
                };
                using (dg)
                {
                    if (dg.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }
                    m_tb_output_filepath.Text = dg.FileName;
                    OutputFilepath            = dg.FileName;
                }
            };

            // Radio buttons
            m_radio_whole_file.ToolTip(m_tt, "Export the entire file contents");
            m_radio_whole_file.Checked         = true;
            m_radio_whole_file.CheckedChanged += (s, a) =>
            {
                UpdateUI();
            };

            m_radio_selection.ToolTip(m_tt, "Export the selected rows only");
            m_radio_selection.Checked         = false;
            m_radio_selection.CheckedChanged += (s, a) =>
            {
                UpdateUI();
            };

            m_radio_range.ToolTip(m_tt, "Export a specific byte range within the file.\r\nThe byte range will automatically be expanded to start at the beginning of a line");
            m_radio_range.Checked         = false;
            m_radio_range.CheckedChanged += (s, a) =>
            {
                UpdateUI();
            };

            // Line ending
            m_tb_line_ending.ToolTip(m_tt, "The characters to end each line in the exported file.\r\nUse '<CR>', '<LF>', or '<TAB>' for carriage return, line feed, or tab respectively");
            m_tb_line_ending.Text         = RowDelim;
            m_tb_line_ending.TextChanged += (s, a) =>
            {
                RowDelim = m_tb_line_ending.Text;
                UpdateUI();
            };

            // Column delimiter
            m_tb_col_delim.ToolTip(m_tt, "The characters to use to separate columns in the exported file.\r\nUse '<CR>', '<LF>', or '<TAB>' for carriage return, line feed, or tab respectively");
            m_tb_col_delim.Text         = ColDelim;
            m_tb_col_delim.TextChanged += (s, a) =>
            {
                ColDelim = m_tb_col_delim.Text;
                UpdateUI();
            };

            // Byte Range
            m_tb_range_min.ValueType     = typeof(long);
            m_tb_range_min.ValidateText  = t => long_.TryParse(t) != null;
            m_tb_range_min.Value         = ByteRange.Beg;
            m_tb_range_min.ValueChanged += (s, a) =>
            {
                if (m_tb_range_min.Valid)
                {
                    ByteRange = new RangeI((long)m_tb_range_min.Value, ByteRange.End);
                }
                UpdateUI();
            };

            m_tb_range_max.ValueType     = typeof(long);
            m_tb_range_max.ValidateText  = t => long_.TryParse(t) != null;
            m_tb_range_max.Value         = ByteRange.End;
            m_tb_range_max.ValueChanged += (s, a) =>
            {
                if (m_tb_range_max.Valid)
                {
                    ByteRange = new RangeI(ByteRange.Beg, (long)m_tb_range_max.Value);
                }
                UpdateUI();
            };

            // Reset to start
            m_btn_range_to_start.Click += (s, a) =>
            {
                m_tb_range_min.Value = ByteRangeLimits.Beg;
                UpdateUI();
            };
            m_btn_range_to_end.Click += (s, a) =>
            {
                m_tb_range_max.Value = ByteRangeLimits.End;
                UpdateUI();
            };
        }
Example #11
0
 protected override void Dispose(bool disposing)
 {
     Util.Dispose(ref m_view3d);
     Util.Dispose(ref components);
     base.Dispose(disposing);
 }
        public NetworkConnectionUI(Settings settings)
        {
            InitializeComponent();
            m_settings     = settings;
            m_outp_history = new List <string>(m_settings.OutputFilepathHistory);
            Conn           = m_settings.NetworkConnectionHistory.Length != 0 ? new NetConn(m_settings.NetworkConnectionHistory[0]) : new NetConn();
            m_tt           = new ToolTip();
            string tt;

            // Protocol type
            m_combo_protocol_type.ToolTip(m_tt, "The connection type");
            var allowed = new[] { ProtocolType.Tcp, ProtocolType.Udp };

            foreach (var i in allowed)
            {
                m_combo_protocol_type.Items.Add(i);
            }
            m_combo_protocol_type.SelectedIndex         = 0;
            m_combo_protocol_type.SelectedIndexChanged += (s, a) =>
            {
                Conn.ProtocolType = (ProtocolType)m_combo_protocol_type.SelectedItem;
                UpdateUI();
            };

            // Listen
            tt = "When checked will act as a server listening for incoming connections.\r\nWhen not checked, will act as a client and attempt to connect to the remote system";
            m_check_listener.ToolTip(m_tt, tt);
            m_check_listener.Checked = Conn.Listener;
            m_check_listener.Click  += (s, a) =>
            {
                Conn.Listener = m_check_listener.Checked;
                UpdateUI();
            };

            // Hostname
            tt = "The remote host to connect to and receive data from";
            m_lbl_hostname.ToolTip(m_tt, tt);
            m_combo_hostname.ToolTip(m_tt, tt);
            foreach (var i in m_settings.NetworkConnectionHistory)
            {
                m_combo_hostname.Items.Add(i);
            }
            if (m_settings.NetworkConnectionHistory.Length != 0)
            {
                m_combo_hostname.SelectedIndex = 0;
            }
            m_combo_hostname.TextChanged += (s, a) =>
            {
                Conn.Hostname = m_combo_hostname.Text;
                UpdateUI();
            };
            m_combo_hostname.SelectedIndexChanged += (s, a) =>
            {
                Conn = new NetConn((NetConn)m_combo_hostname.SelectedItem);
                UpdateUI();
            };

            // Port
            tt = "The remote port to connect to and receive data from";
            m_lbl_port.ToolTip(m_tt, tt);
            m_spinner_port.ToolTip(m_tt, tt);
            m_spinner_port.Value         = Conn.Port;
            m_spinner_port.ValueChanged += (s, a) =>
            {
                Conn.Port = (ushort)m_spinner_port.Value;
                UpdateUI();
            };

            // Use proxy
            m_combo_proxy_type.ToolTip(m_tt, "Select if using a proxy server");
            m_combo_proxy_type.DataSource            = Enum.GetValues(typeof(Proxy.EType));
            m_combo_proxy_type.SelectedIndex         = (int)Conn.ProxyType;
            m_combo_proxy_type.SelectedIndexChanged += (s, a) =>
            {
                Conn.ProxyType = (Proxy.EType)m_combo_proxy_type.SelectedItem;
                Conn.ProxyPort = Proxy.PortDefault(Conn.ProxyType);
                UpdateUI();
            };

            // Proxy host
            tt = "The host name of the proxy server";
            m_lbl_proxy_hostname.ToolTip(m_tt, tt);
            m_edit_proxy_hostname.ToolTip(m_tt, tt);
            m_edit_proxy_hostname.Text         = Conn.ProxyHostname;
            m_edit_proxy_hostname.TextChanged += (s, a) =>
            {
                if (!((TextBox)s).Modified)
                {
                    return;
                }
                Conn.ProxyHostname = m_edit_proxy_hostname.Text;
                UpdateUI();
            };

            // Proxy port
            tt = "The remote port of the proxy server";
            m_lbl_proxy_port.ToolTip(m_tt, tt);
            m_spinner_proxy_port.ToolTip(m_tt, tt);
            m_spinner_proxy_port.Value         = Conn.ProxyPort;
            m_spinner_proxy_port.ValueChanged += (s, a) =>
            {
                Conn.ProxyPort = (ushort)m_spinner_proxy_port.Value;
                UpdateUI();
            };

            // Proxy user name
            tt = "The username used to connect to the proxy server.\r\nLeave blank if no username is required";
            m_lbl_proxy_username.ToolTip(m_tt, tt);
            m_edit_proxy_username.ToolTip(m_tt, tt);
            m_edit_proxy_username.Text         = Conn.ProxyUserName;
            m_edit_proxy_username.TextChanged += (s, a) =>
            {
                if (!((TextBox)s).Modified)
                {
                    return;
                }
                Conn.ProxyUserName = m_edit_proxy_username.Text;
                UpdateUI();
            };

            // Proxy password
            tt = "The password used to connect to the proxy server.\r\nLeave blank if no password is required";
            m_lbl_proxy_password.ToolTip(m_tt, tt);
            m_edit_proxy_password.ToolTip(m_tt, tt);
            m_edit_proxy_password.Text         = Conn.ProxyPassword;
            m_edit_proxy_password.TextChanged += (s, a) =>
            {
                if (!((TextBox)s).Modified)
                {
                    return;
                }
                Conn.ProxyPassword = m_edit_proxy_password.Text;
                UpdateUI();
            };

            // Output file
            m_combo_output_filepath.ToolTip(m_tt, "The file to capture network data in.\r\nLeave blank to not save captured data");
            foreach (var i in m_outp_history)
            {
                m_combo_output_filepath.Items.Add(i);
            }
            m_combo_output_filepath.Text         = Conn.OutputFilepath;
            m_combo_output_filepath.TextChanged += (s, a) =>
            {
                Conn.OutputFilepath = m_combo_output_filepath.Text;
                UpdateUI();
            };

            // Browse output file
            m_btn_browse_output.Click += (s, a) =>
            {
                var dg = new SaveFileDialog {
                    Filter = Constants.LogFileFilter, CheckPathExists = true, OverwritePrompt = false
                };
                if (dg.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }
                Conn.OutputFilepath = dg.FileName;
                UpdateUI();
            };

            // Append to existing
            m_check_append.ToolTip(m_tt, "If checked, captured data is appended to the capture file.\r\nIf not, then the capture file is overwritten");
            m_check_append.Checked = Conn.AppendOutputFile;
            m_check_append.Click  += (s, a) =>
            {
                Conn.AppendOutputFile = m_check_append.Checked;
                UpdateUI();
            };

            Shown += (s, a) =>
            {
                UpdateUI();
            };

            // Save settings on close
            FormClosing += (s, a) =>
            {
                // If launch is selected, add the launch command line to the history
                if (DialogResult == DialogResult.OK && Conn.Hostname.Length != 0)
                {
                    m_settings.NetworkConnectionHistory = Util.AddToHistoryList(m_settings.NetworkConnectionHistory, Conn, true, Constants.MaxNetConnHistoryLength);
                }
            };

            Disposed += (s, a) =>
            {
                m_tt.Dispose();
            };
        }
Example #13
0
        public NamedPipeUI(Settings settings)
        {
            InitializeComponent();
            m_settings     = settings;
            m_outp_history = new List <string>(m_settings.OutputFilepathHistory);
            Conn           = m_settings.PipeConnectionHistory.Length != 0 ? new PipeConn(m_settings.PipeConnectionHistory[0]) : new PipeConn();
            m_tt           = new ToolTip();
            m_pipeaddr     = Conn.PipeAddr;

            // Pipe name
            m_combo_pipe_name.ToolTip(m_tt, "The pipe name in the form \\\\<server>\\pipe\\<pipename>\r\nPipes on the local machine use '.' for <server>");
            foreach (var i in m_settings.PipeConnectionHistory)
            {
                m_combo_pipe_name.Items.Add(i);
            }
            if (m_settings.PipeConnectionHistory.Length != 0)
            {
                m_combo_pipe_name.SelectedIndex = 0;
            }
            m_combo_pipe_name.TextChanged += (s, a) =>
            {
                m_pipeaddr = m_combo_pipe_name.Text;
                UpdateUI();
            };

            // Output file
            m_combo_output_filepath.ToolTip(m_tt, "The file to save captured program output in.\r\nLeave blank to not save captured output");
            foreach (var i in m_outp_history)
            {
                m_combo_output_filepath.Items.Add(i);
            }
            m_combo_output_filepath.Text         = Conn.OutputFilepath;
            m_combo_output_filepath.TextChanged += (s, a) =>
            {
                Conn.OutputFilepath = m_combo_output_filepath.Text;
                UpdateUI();
            };

            // Browse output file
            m_btn_browse_output.Click += (s, a) =>
            {
                var dg = new SaveFileDialog {
                    Filter = Constants.LogFileFilter, CheckPathExists = true, OverwritePrompt = false
                };
                if (dg.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }
                Conn.OutputFilepath = dg.FileName;
                UpdateUI();
            };

            // Save settings on close
            FormClosing += (s, a) =>
            {
                // If launch is selected, add the launch command line to the history
                if (DialogResult == DialogResult.OK && m_pipeaddr.Length != 0)
                {
                    // Validate the pipe address
                    try { Conn.PipeAddr = m_pipeaddr; }
                    catch (ArgumentException)
                    {
                        MsgBox.Show(this, "The pipe name field is invalid.\r\n\r\nIt must have the form: \\\\<server>\\pipe\\<pipename>\r\ne.g. \\\\.\\pipe\\MyLocalPipe", "Pipe Name Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        a.Cancel = true;
                        return;
                    }

                    m_settings.PipeConnectionHistory = Util.AddToHistoryList(m_settings.PipeConnectionHistory, Conn, true, Constants.MaxSerialConnHistoryLength);
                }
            };

            Disposed += (s, a) =>
            {
                m_tt.Dispose();
            };

            UpdateUI();
        }
Example #14
0
 protected override void Dispose(bool disposing)
 {
     DockControl.Dispose();
     Util.Dispose(ref components);
     base.Dispose(disposing);
 }
Example #15
0
 protected override void Dispose(bool disposing)
 {
     Marks = null;
     Util.Dispose(ref components);
     base.Dispose(disposing);
 }
Example #16
0
		/// <summary>Handle unhandled exceptions</summary>
		private static void HandleTheUnhandled(Exception ex)
		{
			var res = MsgBox.Show(null,
				$"{Application.ProductName} has shutdown with the following error.\r\n"+
				$"Error: {ex.GetType().Name}\r\n"+
				$"\r\n"+
				$"Deleting the applications settings file, '{StartupOptions?.SettingsPath ?? Path_.FileName(Settings.Default.Filepath)}', might prevent this problem.\r\n"+
				$"\r\n"+
				$"Generating a report and sending it to {Util.GetAssemblyAttribute<AssemblyCompanyAttribute>().Company} will aid in the resolution of this issue. "+
				$"The generated report is a plain text file that you can review before sending.\r\n"+
				$"\r\n"+
				$"Would you like to generate the report?\r\n"+
				$"\r\n"+
				$"Alternatively, please contact {Constants.SupportEmail} with information about this error so that it can be fixed.\r\n"+
				$"\r\n"+
				$"Apologies for any inconvenience caused.\r\n",
				"Unexpected Termination", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
			if (res == DialogResult.Yes)
			{
				var dg = new SaveFileDialog{Title = "Save Crash Report", FileName = Application.ProductName+"CrashReport", Filter = Util.FileDialogFilter("Crash Report Files","*.txt", "All files","*.*"), DefaultExt = "txt", CheckPathExists = true};
				if (dg.ShowDialog() == DialogResult.OK)
				{
					var settings = "Settings filepath unknown";
					if (StartupOptions != null && Path_.FileExists(StartupOptions.SettingsPath))
						settings = File.ReadAllText(StartupOptions.SettingsPath);

					var sb = new StringBuilder()
						.Append(Application.ProductName).Append(" - Crash Report - ").Append(DateTime.UtcNow).AppendLine()
						.AppendLine("---------------------------------------------------------------")
						.AppendLine("[Unhandled Exception Type]")
						.AppendLine(ex.MessageFull())
						.AppendLine()
						.AppendLine("[Settings File Contents]")
						.AppendLine(settings)
						.AppendLine()
						.AppendLine("[General]")
						.AppendLine($"Application Version: {Util.AssemblyVersion()}")
						.AppendLine(Environment.OSVersion.VersionString)
						.AppendLine(StartupOptions?.Dump() ?? string.Empty)
						.AppendLine()
						.AppendLine("[Additional Comments]")
						.AppendLine("Any additional information about what you were doing when this crash occurred would be extremely helpful and appreciated");
					File.WriteAllText(dg.FileName, sb.ToString());

					try
					{
						if (MsgBox.Show(null, "Preview the report before sending?", "Review Report", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
						Process.Start(dg.FileName);
					} catch {}

					try
					{
						// Try to create an email with the attachment ready to go
						var email = new MailMessage();
						email.From = new MailAddress(Constants.SupportEmail);
						email.To.Add(Constants.SupportEmail);
						email.Subject = $"{Util.AppProductName} crash report";
						email.Priority = MailPriority.Normal;
						email.IsBodyHtml = false;
						email.Body =
							$"To {Util.AppCompany},\r\n" +
							$"\r\n" +
							$"Attached is a crash report generated on {DateTime.Now}.\r\n" +
							$"A brief description of how the application was being used at the time follows:\r\n" +
							$"\r\n\r\n\r\n\r\n" +
							$"Regards,\r\n" +
							$"A Helpful User";
						email.Attachments.Add(new Attachment(dg.FileName));

						// Try to send it
						var smtp = new SmtpClient();
						smtp.Send(email);
					}
					catch {}
				}
			}
			Environment.ExitCode = 1;
		}
        public SerialConnectionUI(Settings settings)
        {
            InitializeComponent();
            m_settings     = settings;
            m_outp_history = new List <string>(m_settings.OutputFilepathHistory);
            Conn           = m_settings.SerialConnectionHistory.Length != 0 ? new SerialConn(m_settings.SerialConnectionHistory[0]) : new SerialConn();
            m_tt           = new ToolTip();

            // Comm Port
            string[] portnames = SerialPort.GetPortNames();
            m_combo_commport.ToolTip(m_tt, "The serial communications port to connect to");
            foreach (var i in portnames)
            {
                m_combo_commport.Items.Add(i);
            }
            m_combo_commport.TextChanged += (s, a) =>
            {
                Conn.CommPort = m_combo_commport.Text;
                UpdateUI();
            };
            m_combo_commport.SelectedIndexChanged += (s, a) =>
            {
                Conn.CommPort = m_combo_commport.Text;
                UpdateUI();
            };

            // Baud rate
            var baudrates = new[] { 110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200, 230400, 460800, 921600, 1843200 };

            m_combo_baudrate.ToolTip(m_tt, "The baud rate for the connection");
            foreach (var i in baudrates)
            {
                m_combo_baudrate.Items.Add(i);
            }
            m_combo_baudrate.KeyPress    += (s, a) => a.Handled = !char.IsDigit(a.KeyChar);
            m_combo_baudrate.TextChanged += (s, a) =>
            {
                int.TryParse(m_combo_baudrate.Text, out Conn.BaudRate);
                UpdateUI();
            };
            m_combo_baudrate.SelectedIndexChanged += (s, a) =>
            {
                Conn.BaudRate = (int)m_combo_baudrate.SelectedItem;
                UpdateUI();
            };

            // Data bits
            var databits = new[] { 7, 8 };

            m_combo_databits.ToolTip(m_tt, "The number of data bits");
            foreach (var i in databits)
            {
                m_combo_databits.Items.Add(i);
            }
            m_combo_databits.KeyPress    += (s, a) => a.Handled = !char.IsDigit(a.KeyChar);
            m_combo_databits.TextChanged += (s, a) =>
            {
                int.TryParse(m_combo_databits.Text, out Conn.DataBits);
                UpdateUI();
            };
            m_combo_databits.SelectedIndexChanged += (s, a) =>
            {
                Conn.DataBits = (int)m_combo_databits.SelectedItem;
                UpdateUI();
            };

            // Parity
            m_combo_parity.ToolTip(m_tt, "The parity checking protocol to use");
            m_combo_parity.DataSource            = Enum.GetValues(typeof(Parity));
            m_combo_parity.SelectedItem          = Conn.Parity;
            m_combo_parity.SelectedIndexChanged += (s, a) =>
            {
                Conn.Parity = (Parity)m_combo_parity.SelectedItem;
                UpdateUI();
            };

            // Stop bits
            m_combo_stopbits.ToolTip(m_tt, "The number of stop bits per byte");
            m_combo_stopbits.DataSource            = Enum.GetValues(typeof(StopBits));
            m_combo_stopbits.SelectedItem          = Conn.StopBits;
            m_combo_stopbits.SelectedIndexChanged += (s, a) =>
            {
                Conn.StopBits = (StopBits)m_combo_stopbits.SelectedItem;
                UpdateUI();
            };

            // Flow control
            m_combo_flow_control.ToolTip(m_tt, "The handshaking protocol for communication");
            m_combo_flow_control.DataSource            = Enum.GetValues(typeof(Handshake));
            m_combo_flow_control.SelectedItem          = Conn.FlowControl;
            m_combo_flow_control.SelectedIndexChanged += (s, a) =>
            {
                Conn.FlowControl = (Handshake)m_combo_flow_control.SelectedItem;
                UpdateUI();
            };

            // DTR enable
            m_check_dtr_enable.ToolTip(m_tt, "Set the Data Terminal Ready signal during communication");
            m_check_dtr_enable.Checked = Conn.DtrEnable;
            m_check_dtr_enable.Click  += (s, a) =>
            {
                Conn.DtrEnable = m_check_dtr_enable.Checked;
                UpdateUI();
            };

            // RTS enable
            m_check_rts_enable.ToolTip(m_tt, "Set the Request to Send signal during communication");
            m_check_rts_enable.Checked = Conn.RtsEnable;
            m_check_rts_enable.Click  += (s, a) =>
            {
                Conn.RtsEnable = m_check_rts_enable.Checked;
                UpdateUI();
            };

            // Output file
            m_combo_output_filepath.ToolTip(m_tt, "The file to save captured program output in.\r\nLeave blank to not save captured output");
            foreach (var i in m_outp_history)
            {
                m_combo_output_filepath.Items.Add(i);
            }
            m_combo_output_filepath.Text         = Conn.OutputFilepath;
            m_combo_output_filepath.TextChanged += (s, a) =>
            {
                Conn.OutputFilepath = m_combo_output_filepath.Text;
                UpdateUI();
            };

            // Browse output file
            m_btn_browse_output.Click += (s, a) =>
            {
                var dg = new SaveFileDialog {
                    Filter = Constants.LogFileFilter, CheckPathExists = true, OverwritePrompt = false
                };
                if (dg.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }
                Conn.OutputFilepath = dg.FileName;
                UpdateUI();
            };

            // Save settings on close
            FormClosing += (s, a) =>
            {
                // If launch is selected, add the launch command line to the history
                if (DialogResult == DialogResult.OK && Conn.CommPort.Length != 0)
                {
                    m_settings.SerialConnectionHistory = Util.AddToHistoryList(m_settings.SerialConnectionHistory, Conn, true, Constants.MaxSerialConnHistoryLength);
                }
            };

            Disposed += (s, a) =>
            {
                m_tt.Dispose();
            };

            UpdateUI();
        }
Example #18
0
 public void Dispose()
 {
     Util.DisposeRange(m_diag.Elements);
     Util.Dispose(ref m_diag);
 }
Example #19
0
        public ProgramOutputUI(Settings settings)
        {
            InitializeComponent();
            m_settings     = settings;
            m_outp_history = new List <string>(m_settings.OutputFilepathHistory);
            Launch         = m_settings.LogProgramOutputHistory.Length != 0 ? new LaunchApp(m_settings.LogProgramOutputHistory[0]) : new LaunchApp();
            m_tt           = new ToolTip();

            // Command line
            m_combo_launch_cmdline.ToolTip(m_tt, "Command line for the application to launch");
            m_combo_launch_cmdline.Load(m_settings.LogProgramOutputHistory);
            m_combo_launch_cmdline.TextChanged += (s, a) =>
            {
                Launch.Executable = m_combo_launch_cmdline.Text;
                UpdateUI();
            };
            m_combo_launch_cmdline.SelectedIndexChanged += (s, a) =>
            {
                Launch = new LaunchApp((LaunchApp)m_combo_launch_cmdline.SelectedItem);
                UpdateUI();
            };

            // Arguments
            m_edit_arguments.ToolTip(m_tt, "Command line arguments for the executable");
            m_edit_arguments.Text         = Launch.Arguments;
            m_edit_arguments.TextChanged += (s, a) =>
            {
                if (!((TextBox)s).Modified)
                {
                    return;
                }
                Launch.Arguments = m_edit_arguments.Text;
                UpdateUI();
            };

            // Working Directory
            m_edit_working_dir.ToolTip(m_tt, "The application working directory");
            m_edit_working_dir.Text         = Launch.WorkingDirectory;
            m_edit_working_dir.TextChanged += (s, a) =>
            {
                if (!((TextBox)s).Modified)
                {
                    return;
                }
                Launch.WorkingDirectory = m_edit_working_dir.Text;
                UpdateUI();
            };

            // Output file
            m_combo_output_filepath.ToolTip(m_tt, "The file to save captured program output in.\r\nLeave blank to not save captured output");
            foreach (var i in m_outp_history)
            {
                m_combo_output_filepath.Items.Add(i);
            }
            m_combo_output_filepath.Text         = Launch.OutputFilepath;
            m_combo_output_filepath.TextChanged += (s, a) =>
            {
                Launch.OutputFilepath = m_combo_output_filepath.Text;
                UpdateUI();
            };

            // Browse executable
            m_btn_browse_exec.Click += (s, a) =>
            {
                var dg = new OpenFileDialog {
                    Filter = Constants.ExecutablesFilter, CheckFileExists = true
                };
                if (dg.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }
                Launch.Executable       = dg.FileName;
                Launch.WorkingDirectory = Path.GetDirectoryName(dg.FileName);
                UpdateUI();
            };

            // Browse output file
            m_btn_browse_output.Click += (s, a) =>
            {
                var dg = new SaveFileDialog {
                    Filter = Constants.LogFileFilter, CheckPathExists = true, OverwritePrompt = false
                };
                if (dg.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }
                Launch.OutputFilepath = dg.FileName;
                UpdateUI();
            };

            // Todo, show window doesn't really work, remove it
            Launch.ShowWindow = false;
            //// Show window
            //m_check_show_window.ToolTip(m_tt, "If checked, the window for the application is shown.\r\n If not, then it is hidden");
            //m_check_show_window.Checked = Launch.ShowWindow;
            //m_check_show_window.Click += (s,a)=>
            //	{
            //		Launch.ShowWindow = m_check_show_window.Checked;
            //		UpdateUI();
            //	};

            // Append to existing
            m_check_append.ToolTip(m_tt, "If checked, captured output is appended to the capture file.\r\nIf not, then the capture file is overwritten");
            m_check_append.Checked = Launch.AppendOutputFile;
            m_check_append.Click  += (s, a) =>
            {
                Launch.AppendOutputFile = m_check_append.Checked;
                UpdateUI();
            };

            // Capture Stdout
            m_check_capture_stdout.ToolTip(m_tt, "Check to log standard output (STDOUT)");
            m_check_capture_stdout.Click += (s, a) =>
            {
                Launch.Streams = (StandardStreams)Bit.SetBits(
                    (int)Launch.Streams,
                    (int)StandardStreams.Stdout,
                    m_check_capture_stdout.Checked);
            };

            // Capture Stderr
            m_check_capture_stderr.ToolTip(m_tt, "Check to log standard error (STDERR)");
            m_check_capture_stderr.Click += (s, a) =>
            {
                Launch.Streams = (StandardStreams)Bit.SetBits(
                    (int)Launch.Streams,
                    (int)StandardStreams.Stderr,
                    m_check_capture_stdout.Checked);
            };

            // Save settings on close
            FormClosing += (s, a) =>
            {
                // If launch is selected, add the launch command line to the history
                if (DialogResult == DialogResult.OK && Launch.Executable.Length != 0)
                {
                    m_settings.LogProgramOutputHistory = Util.AddToHistoryList(m_settings.LogProgramOutputHistory, Launch, true, Constants.MaxProgramHistoryLength);
                }
            };

            Disposed += (s, a) =>
            {
                m_tt.Dispose();
            };

            UpdateUI();
        }