示例#1
0
 public LostMessage(uint fileLine, string name, uint line, int process)
 {
     this.mName 				= name;
     this.mGate 				= "";
     this.mLine 				= line;
     this.mProcess 			= process;
     this.mInitialHeight 	= (uint)Generator.LOOP_OFFSET;
     this.mItemPen 			= new Pen(Color.Black, 1);
     this.mPos 				= MessagePos.Left;
 }
示例#2
0
        public bool ProcessMessage(string message)
        {
            // Note: Post() to UI thread is expensive, and can saturate the message pump when there's a lot of output,
            // making UI non-responsive. So avoid using it unless we need it - and we only need it for FlushOutput,
            // and we only need it to handle CR.
            if (message.Length > 1 && message[0] == '\r' && message[1] != '\n')
            {
                _coreShell.MainThread().Post(() => {
                    // Make sure output buffer is up to date
                    _interactiveWindow.FlushOutput();

                    // If message starts with CR we remember current output buffer
                    // length so we can continue writing lines into the same spot.
                    // See txtProgressBar in R.
                    // Store the message and the initial position. All subsequent
                    // messages that start with CR will be written into the same place.
                    if (_messagePos != null)
                    {
                        ProcessReplacement();
                    }

                    // Locate last end of line
                    var snapshot = _interactiveWindow.OutputBuffer.CurrentSnapshot;
                    var line     = snapshot.GetLineFromPosition(snapshot.Length);
                    var text     = message.Substring(1);

                    _messagePos = new MessagePos()
                    {
                        Text              = text,
                        Position          = line.Start,
                        PlaceholderLength = text.Length + 8 // buffer for, say, '| 100%'
                    };

                    // It is important that replacement matches original text length
                    // since interactive window creates fixed colorized spans for errors
                    // and replacement of text by a text with a different length
                    // causes odd changes in color - word may appear partially in
                    // black and partially in red.

                    // Replacement placeholder so we can receive 'buffer changed' event
                    // Placeholder is whitespace that is as long as original message plus
                    // few more space to account for example, for 0% - 100% when CR is used
                    // to display ASCII progress.
                    var placeholder = new string(' ', _messagePos.PlaceholderLength);

                    _interactiveWindow.Write(placeholder);
                    _interactiveWindow.FlushOutput(); // Must flush so we do get 'buffer changed' immediately.
                });
                return(true);
            }
            return(false);
        }
示例#3
0
        public bool ProcessMessage(string message) {
            // Note: DispatchOnUIThread is expensive, and can saturate the message pump when there's a lot of output,
            // making UI non-responsive. So avoid using it unless we need it - and we only need it for FlushOutput,
            // and we only need it to handle CR.
            if (message.Length > 1 && message[0] == '\r' && message[1] != '\n') {
                _coreShell.DispatchOnUIThread(() => {
                    // Make sure output buffer is up to date
                    _interactiveWindow.FlushOutput();

                    // If message starts with CR we remember current output buffer
                    // length so we can continue writing lines into the same spot.
                    // See txtProgressBar in R.
                    // Store the message and the initial position. All subsequent 
                    // messages that start with CR will be written into the same place.
                    if (_messagePos != null) {
                        ProcessReplacement();
                    }

                    // Locate last end of line
                    var snapshot = _interactiveWindow.OutputBuffer.CurrentSnapshot;
                    var line = snapshot.GetLineFromPosition(snapshot.Length);
                    var text = message.Substring(1);

                    _messagePos = new MessagePos() {
                        Text = text,
                        Position = line.Start,
                        PlaceholderLength = text.Length + 8 // buffer for, say, '| 100%'
                    };

                    // It is important that replacement matches original text length
                    // since interactive window creates fixed colorized spans for errors
                    // and replacement of text by a text with a different length
                    // causes odd changes in color - word may appear partially in
                    // black and partially in red.
                     
                    // Replacement placeholder so we can receive 'buffer changed' event
                    // Placeholder is whitespace that is as long as original message plus
                    // few more space to account for example, for 0% - 100% when CR is used
                    // to display ASCII progress.
                    var placeholder = new string(' ', _messagePos.PlaceholderLength);

                    _interactiveWindow.Write(placeholder);
                    _interactiveWindow.FlushOutput(); // Must flush so we do get 'buffer changed' immediately.
                });
                return true;
            }
            return false;
        }
示例#4
0
        private void ProcessReplacement()
        {
            _coreShell.AssertIsOnMainThread();
            // Writing messages in the same line (via simulated CR)

            var m = _messagePos;

            _messagePos = null;

            // Replace last written placeholder with the actual message.
            // Pad text as necessary by spaces to match original length.
            var extra       = m.PlaceholderLength - m.Text.Length;
            var replacement = m.Text + (extra > 0 ? new string(' ', extra) : string.Empty);

            _interactiveWindow.OutputBuffer.Replace(new Span(m.Position, m.PlaceholderLength), replacement);
        }
示例#5
0
        private void AddMessageItem(Message response)
        {
            MessagePos pos = MessagePos.Left;

            if (response.SocketId == message.SocketId)
            {
                pos = MessagePos.Right;
            }

            MessageItem item = new MessageItem(response, pos);

            MessagesItemsTbl.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            MessagesItemsTbl.Controls.Add(item, 0, MessageRowCount);
            MessageRowCount++;
            MessagesListPanel.ScrollControlIntoView(item);
        }
示例#6
0
        private void GenerateControl(Message response, MessagePos pos)
        {
            switch (pos)
            {
            case MessagePos.Left:
                leftName.Text    = response.UserName;
                leftMessage.Text = response.MessageContent;
                break;

            case MessagePos.Right:
                leftName.Text         = response.UserName;
                leftMessage.Text      = response.MessageContent;
                leftMessage.BackColor = Color.Honeydew;
                leftName.Location     = new Point(550 - leftName.PreferredWidth, leftName.Location.Y);
                leftMessage.Location  = new Point(550 - leftMessage.PreferredWidth, leftMessage.Location.Y);
                break;
            }
        }
示例#7
0
 public InterpretResult addLostMessage(uint fileLine, string processName, uint line, string name, string gate, MessagePos placement)
 {
     Process process;
     IEnumerator enumerator = processes.GetEnumerator();
     bool instanceFound = false;
     for(int i=0;i<processes.Count;i++){
         enumerator.MoveNext();
         process = (Process) enumerator.Current;
         if(process.ProcessName == processName){
             items.Add(new LostMessage(fileLine, name, gate, line, i, placement));
             instanceFound = true;
             break;
         }
     }
     if (instanceFound==false)
         return InterpretResult.InstanceNotFound;
     mLines = Math.Max(mLines, line);
     return InterpretResult.Ok;
 }
示例#8
0
        private void ProcessReplacement() {
            _coreShell.AssertIsOnMainThread();
            // Writing messages in the same line (via simulated CR)

            var m = _messagePos;
            _messagePos = null;

            // Replace last written placeholder with the actual message.
            // Pad text as necessary by spaces to match original length.
            var extra = m.PlaceholderLength - m.Text.Length;
            var replacement = m.Text + (extra > 0 ? new string(' ', extra) : string.Empty);
            _interactiveWindow.OutputBuffer.Replace(new Span(m.Position, m.PlaceholderLength), replacement);
        }
 public static void RepertoryImage(Graphics drawDestination, MessagePos pos, MscStyle style)
 {
     StringFormat itemStringFormat = new StringFormat();
     if (style == MscStyle.SDL){
         if (pos == MessagePos.Right){
             RectangleF itemBox = new RectangleF(10, 30, 42, 10);
             RectangleF itemBox2 = new RectangleF(60, 48, 10, 10);
             itemStringFormat.Alignment = StringAlignment.Center;
             itemStringFormat.LineAlignment = StringAlignment.Far;
             drawDestination.DrawLine(Pens.DarkGray,10,10,10,70);
             PointF[] capPolygon = new PointF[3];
             capPolygon[0] = new PointF(60, 40);
             capPolygon[1] = new PointF(52, 44);
             capPolygon[2] = new PointF(52, 36);
             drawDestination.FillPolygon(Brushes.Black,capPolygon);
             drawDestination.DrawString("Lost",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
             drawDestination.DrawString("g",new Font("Arial",8),Brushes.Black,itemBox2,itemStringFormat);
             drawDestination.DrawLine(Pens.Black,10, 40, 60,40);
             drawDestination.FillEllipse(Brushes.Black, new RectangleF(60,35, 10,10));
         }
         else {
             RectangleF itemBox = new RectangleF(28, 30, 42, 10);
             RectangleF itemBox2 = new RectangleF(10, 48, 10, 10);
             itemStringFormat.Alignment = StringAlignment.Center;
             itemStringFormat.LineAlignment = StringAlignment.Far;
             drawDestination.DrawLine(Pens.DarkGray,70,10,70,70);
             PointF[] capPolygon = new PointF[3];
             capPolygon[0] = new PointF(20, 40);
             capPolygon[1] = new PointF(28, 44);
             capPolygon[2] = new PointF(28, 36);
             drawDestination.FillPolygon(Brushes.Black,capPolygon);
             drawDestination.DrawString("Lost",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
             drawDestination.DrawString("g",new Font("Arial",8),Brushes.Black,itemBox2,itemStringFormat);
             drawDestination.DrawLine(Pens.Black,20, 40, 70,40);
             drawDestination.FillEllipse(Brushes.Black, new RectangleF(10,35, 10,10));
         }
     }
     else if(style == MscStyle.UML2){
         if (pos == MessagePos.Right){
             RectangleF itemBox = new RectangleF(10, 30, 42, 10);
             RectangleF itemBox2 = new RectangleF(60, 48, 10, 10);
             itemStringFormat.Alignment = StringAlignment.Center;
             itemStringFormat.LineAlignment = StringAlignment.Far;
             drawDestination.DrawLine(Pens.DarkGray,10,10,10,70);
             drawDestination.DrawString("Lost",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
             drawDestination.DrawString("g",new Font("Arial",8),Brushes.Black,itemBox2,itemStringFormat);
             drawDestination.DrawLine(Pens.Black,10, 40, 60, 40);
             drawDestination.DrawLine(Pens.Black,60, 40, 52, 43);
             drawDestination.DrawLine(Pens.Black,60, 40, 52, 37);
             drawDestination.FillEllipse(Brushes.Black, new RectangleF(60,35, 10,10));
         }
         else{
             RectangleF itemBox = new RectangleF(28, 30, 42, 10);
             RectangleF itemBox2 = new RectangleF(10, 48, 10, 10);
             itemStringFormat.Alignment = StringAlignment.Center;
             itemStringFormat.LineAlignment = StringAlignment.Far;
             drawDestination.DrawLine(Pens.DarkGray,70,10,70,70);
             drawDestination.DrawString("Lost",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
             drawDestination.DrawString("g",new Font("Arial",8),Brushes.Black,itemBox2,itemStringFormat);
             drawDestination.DrawLine(Pens.Black,20, 40, 28, 43);
             drawDestination.DrawLine(Pens.Black,20, 40, 28, 37);
             drawDestination.DrawLine(Pens.Black,20, 40, 70,40);
             drawDestination.FillEllipse(Brushes.Black, new RectangleF(10,35, 10,10));
         }
     }
     itemStringFormat.Dispose();
 }
示例#10
0
        public MessageItem(Message messangerDTO, MessagePos pos)
        {
            InitializeComponent();

            GenerateControl(messangerDTO, pos);
        }
示例#11
0
 public FoundMessage(uint fileLine, string name, uint line, int process, MessagePos placement)
 {
     this.mName 				= name;
     this.mGate 				= "";
     this.mLine 				= line;
     this.mProcess 			= process;
     this.mInitialHeight 	= (uint)Generator.LOOP_OFFSET;
     this.mItemPen 			= new Pen(Color.Black, 1);
     this.mPos 				= placement;
     this.mFileLine 			= fileLine;
 }
示例#12
0
 /// <summary>
 /// 显示信息
 /// </summary>
 public static void ShowMessage(string message, string detailMes = null, MessagePos pos = MessagePos.Popup)
 {
     ShowMessageAction?.Invoke(message, detailMes, pos);
 }