示例#1
0
 public PipeConn(PipeConn rhs)
 {
     ServerName       = rhs.ServerName;
     PipeName         = rhs.PipeName;
     OutputFilepath   = rhs.OutputFilepath;
     AppendOutputFile = rhs.AppendOutputFile;
 }
示例#2
0
 public BufferedPipeConn(PipeConn conn)
     : base(conn.OutputFilepath, conn.AppendOutputFile)
 {
     m_conn = conn;
     m_buf  = new byte[BufBlockSize];
     m_pipe = new NamedPipeClientStream(m_conn.ServerName, m_conn.PipeName, PipeDirection.InOut, PipeOptions.Asynchronous);
 }
示例#3
0
        /// <summary>Open a named pipe connection and log anything read</summary>
        private void LogNamedPipeConnection(PipeConn conn)
        {
            BufferedPipeConn buffered_pipeconn = null;

            try
            {
                // Close any currently open file
                // Strictly, we don't have to close because OpenLogFile closes before opening
                // however if the user reopens the same connection the existing connection will
                // hold a lock on the capture file preventing the new connection being created.
                Src = null;

                // Set options so that data always shows
                PrepareForStreamedData(conn.OutputFilepath);

                // Create the buffered pipe connection
                buffered_pipeconn = new BufferedPipeConn(conn);

                // Give some UI feedback if the connection drops
                buffered_pipeconn.ConnectionDropped += (s, a) =>
                {
                    this.BeginInvoke(() => SetStaticStatusMessage("Connection dropped", Color.Black, Color.LightSalmon));
                };

                // Open the capture file
                OpenSingleLogFile(buffered_pipeconn.Filepath, !buffered_pipeconn.TmpFile);
                buffered_pipeconn.Start(this);
                SetStaticStatusMessage("Connected", Color.Black, Color.LightGreen);

                // Pass over the ref
                if (m_buffered_pipeconn != null)
                {
                    m_buffered_pipeconn.Dispose();
                }
                m_buffered_pipeconn = buffered_pipeconn;
                buffered_pipeconn   = null;
            }
            catch (OperationCanceledException) {}
            catch (Exception ex)
            {
                Log.Write(ELogLevel.Error, ex, $"Failed to connect {conn.PipeAddr} -> {conn.OutputFilepath}");
                Misc.ShowMessage(this, $"Failed to connect to {conn.PipeAddr}.", Application.ProductName, MessageBoxIcon.Error, ex);
            }
            finally
            {
                if (buffered_pipeconn != null)
                {
                    buffered_pipeconn.Dispose();
                }
            }
        }
示例#4
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();
        }
示例#5
0
        public Settings()
        {
            RecentFiles       = string.Empty;
            RecentPatternSets = string.Empty;
            Font                        = new Font("Consolas", 8.25f, GraphicsUnit.Point);
            RestoreScreenLoc            = false;             // False so that first runs start in the default window position
            ScreenPosition              = new Point(100, 100);
            WindowSize                  = new Size(640, 480);
            PatternSetDirectory         = Util.ResolveUserDocumentsPath(Application.CompanyName, Application.ProductName);
            ExportFilepath              = null;
            AlternateLineColours        = true;
            LineSelectBackColour        = Color.DarkGreen;
            LineSelectForeColour        = Color.White;
            LineBackColour1             = Color.WhiteSmoke;
            LineBackColour2             = Color.White;
            LineForeColour1             = Color.Black;
            LineForeColour2             = Color.Black;
            FileScrollWidth             = Constants.FileScrollWidthDefault;
            ScrollBarFileRangeColour    = Color.FromArgb(0x80, Color.White);
            ScrollBarCachedRangeColour  = Color.FromArgb(0x40, Color.LightBlue);
            ScrollBarDisplayRangeColour = Color.FromArgb(0x80, Color.SteelBlue);
            BookmarkColour              = Color.Violet;
            RowHeight                   = Constants.RowHeightDefault;
            LoadLastFile                = false;
            LastLoadedFile              = string.Empty;
            OpenAtEnd                   = true;
            FullPathInTitle             = true;
            TabSizeInSpaces             = 4;
            FileChangesAdditive         = true;
            IgnoreBlankLines            = false;
            AlwaysOnTop                 = false;
            FirstRun                    = true;
            ShowTOTD                    = true;
            CheckForUpdates             = false;
            CheckForUpdatesServer       = "http://www.rylogic.co.nz/";
            UseWebProxy                 = false;
            WebProxyHost                = string.Empty;
            WebProxyPort                = Constants.PortNumberWebProxyDefault;
            QuickFilterEnabled          = false;
            HighlightsEnabled           = true;
            FiltersEnabled              = false;
            TransformsEnabled           = false;
            ActionsEnabled              = false;
            TailEnabled                 = true;
            WatchEnabled                = true;
            FileBufSize                 = Constants.FileBufSizeDefault;
            MaxLineLength               = Constants.MaxLineLengthDefault;
            LineCacheCount              = Constants.LineCacheCountDefault;
            Patterns                    = PatternSet.Default();
            RowDelimiter                = string.Empty;             // stored in humanised form, empty means auto detect
            ColDelimiter                = string.Empty;             // stored in humanised form, empty means auto detect
            ColumnCount                 = 2;
            Encoding                    = string.Empty;             // empty means auto detect
            OutputFilepathHistory       = new string[0];
            LogProgramOutputHistory     = new LaunchApp[0];
            NetworkConnectionHistory    = new NetConn[0];
            SerialConnectionHistory     = new SerialConn[0];
            PipeConnectionHistory       = new PipeConn[0];
            AndroidLogcat               = new AndroidLogcat();

            AutoSaveOnChanges = true;
        }