예제 #1
0
        private void UpdateConsole(string text, StreamState state)
        {
            /*if (c == '\r') { output.Inlines.Add(@"\r"); file.Write("\\r"); }
             *  else if (c == '\n') { output.Inlines.Add(@"\n"); file.Write("\\n\n"); }
             *  output.Inlines.Add(""+c);
             *  file.Write(c);
             *  file.Flush();
             *  continue;*/

            if (text != null)
            {
                foreach (char c in text)
                {
                    switch (c)
                    {
                    case '\r' when(state.Is(StreamState.State.BEGIN)):
                    {
                        state.Set(StreamState.State.READ_CARRIAGE);
                        break;
                    }

                    case '\n' when(state.Is(StreamState.State.READ_CARRIAGE)):
                    {
                        if (state.buffer.Length > 0)
                        {
                            string buffer = state.Fetch();

                            AppendToTextBox(buffer, state.isError ? Brushes.Red : Brushes.White);

                            if (!state.isError)
                            {
                                ProcessStringForProgressBar(buffer);
                            }
                        }
                        _paragraph.Inlines.Add(new LineBreak());
                        state.Clear();
                        state.Set(StreamState.State.BEGIN);
                        break;
                    }

                    default:
                        if (state.Is(StreamState.State.READ_CARRIAGE) && state.HasData())
                        {
                            if (!(_paragraph.Inlines.LastInline is LineBreak))
                            {
                                _paragraph.Inlines.Remove(_paragraph.Inlines.LastInline);
                            }

                            string buffer = state.Fetch();

                            AppendToTextBox(buffer, state.isError ? Brushes.Red : Brushes.White);

                            if (!state.isError)
                            {
                                ProcessStringForProgressBar(buffer);
                            }

                            state.Clear();
                        }

                        state.Set(StreamState.State.BEGIN);
                        state.Append(c);
                        break;
                    }
                }
            }
        }
예제 #2
0
        private void UpdateConsole(string text, StreamState state)
        {
            /*if (c == '\r') { output.Inlines.Add(@"\r"); file.Write("\\r"); }
             *  else if (c == '\n') { output.Inlines.Add(@"\n"); file.Write("\\n\n"); }
             *  output.Inlines.Add(""+c);
             *  file.Write(c);
             *  file.Flush();
             *  continue;*/

            if (text != null)
            {
                foreach (char c in text)
                {
                    switch (c)
                    {
                    case '\r' when(state.Is(StreamState.State.BEGIN)):
                    {
                        state.Set(StreamState.State.READ_CARRIAGE);
                        break;
                    }

                    case '\n' when(state.Is(StreamState.State.READ_CARRIAGE)):
                    {
                        if (state.buffer.Length > 0)
                        {
                            string buffer = state.Fetch();

                            AppendToTextBox(buffer, state.isError ? System.Drawing.Color.Red : System.Drawing.Color.White);

                            if (!state.isError)
                            {
                                ProcessStringForProgressBar(buffer);
                            }
                        }
                        output.AppendText(Environment.NewLine);
                        state.Clear();
                        state.Set(StreamState.State.BEGIN);
                        break;
                    }

                    default:
                        if (state.Is(StreamState.State.READ_CARRIAGE) && state.HasData())
                        {
                            if (!String.IsNullOrEmpty(output.Lines.Last()))
                            {
                                output.Lines[output.Lines.Length] = string.Empty;
                            }

                            string buffer = state.Fetch();

                            AppendToTextBox(buffer, state.isError ? System.Drawing.Color.Red : System.Drawing.Color.White);

                            if (!state.isError)
                            {
                                ProcessStringForProgressBar(buffer);
                            }

                            state.Clear();
                        }

                        state.Set(StreamState.State.BEGIN);
                        state.Append(c);
                        break;
                    }
                }
            }
        }