Example #1
0
 /// <summary>
 /// Notifies the user with a message using NotifyIcon and windows desktop alerts.
 /// </summary>
 /// <param name="msg">The message to show in notification. </param>s
 public static void Notify(string msg, MessageKind kind)
 {
     /////TO-DO/////
     /// Call notify icon
     ///////////////
     NotificationManager.Show(msg, kind);
 }
Example #2
0
 public static ReceivedEventArgs NewEvent(byte[] message, MessageKind messageKind)
 {
     return(new ReceivedEventArgs()
     {
         Message = message, MessageKind = messageKind
     });
 }
Example #3
0
        public void Log(string contents, string channel, MessageKind kind = MessageKind.Information, string title = null, params string[] tags)
        {
            // send message
            var task = LogAsync(contents, channel, kind, title, tags);

            task.Wait();
        }
Example #4
0
        private void SendBytes(byte[] message, MessageKind kind)
        {
            try
            {
                if (message == null)
                {
                    message = new byte[0];
                }

                var length = message.Length;

                if (length > ushort.MaxValue)
                {
                    throw new ArgumentOutOfRangeException();
                }

                byte[] outMessage;
                EnvelopeSend(message, kind, length, out outMessage);

                sendMessage.Enqueue(outMessage);

                mreBeginSend.SetIfNotNull();
            }
            catch (Exception e)
            {
                this.HandleError(e);
            }
        }
Example #5
0
 public Message(Task sender, Clause clause)
 {
     Kind   = MessageKind.Add;
     Sender = sender;
     Result = null;
     Clause = clause;
 }
Example #6
0
 //
 public Message(MessageKind kind)
 {
     Kind   = kind;
     Sender = null;
     Result = null;
     Clause = null;
 }
Example #7
0
        public void Log(MessageKind messageKind, BinaryAnalyzerContext context, string message)
        {
            switch (messageKind)
            {
            case MessageKind.Pass:
            {
                PassTargets.Add(context.PE.FileName);
                break;
            }

            case MessageKind.Fail:
            {
                FailTargets.Add(context.PE.FileName);
                break;
            }

            case MessageKind.NotApplicable:
            {
                NotApplicableTargets.Add(context.PE.FileName);
                break;
            }

            case MessageKind.Note:
            case MessageKind.Pending:
            case MessageKind.InternalError:
            case MessageKind.ConfigurationError:
            {
                throw new NotImplementedException();
            }
            }
        }
Example #8
0
        public static Task <DialogResult> Show(
            string title, string message, MessageKind messageKind = MessageKind.None, DialogOptions options = DialogOptions.Ok)
        {
            var box = new MessageBox(title, message, messageKind, options);

            return(box.ShowDialog <DialogResult>(App.Current.MainWindow));
        }
Example #9
0
        /// <summary>
        /// Shows a message at the bottom of the screen
        /// </summary>
        /// <param name="message">The message</param>
        /// <param name="kind">error, information or success</param>
        /// <param name="cursorPosition"></param>
        public static void ShowMessage(string message, MessageKind kind, CursorPosition cursorPosition = null)
        {
            if (cursorPosition == null)
            {
                cursorPosition = new CursorPosition(Console.CursorLeft, Console.CursorTop);
            }

            ConsoleColor consoleColor = Console.ForegroundColor;

            Console.SetCursorPosition(Console.WindowWidth / 2 - (message.Length / 2), Console.WindowHeight - 10);
            switch (kind)
            {
            case MessageKind.Error:
                Console.ForegroundColor = ConsoleColor.Red;
                break;

            case MessageKind.Info:
                Console.ForegroundColor = ConsoleColor.Yellow;
                break;

            case MessageKind.Success:
                Console.ForegroundColor = ConsoleColor.Green;
                break;
            }

            Console.Write(message);
            Console.SetCursorPosition(cursorPosition.Left, cursorPosition.Top);
            Console.ForegroundColor = consoleColor;
        }
Example #10
0
 public override void LogMessage(string message, MessageKind kind)
 {
     if (kind == MessageKind.Informational)
     {
         Console.WriteLine(message);
     }
 }
        private string ConvertBytesToString(byte[] bytes)
        {
            //char[] chars = new char[iRx + 1];
            //System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
            //d.GetChars(bytes, 0, iRx, chars, 0);
            //string szData = new string(chars);
            //return szData;

            int         messageKind;
            MessageBase msg;

            MessageComposer.Deserialize(bytes, out messageKind, out msg);

            MessageKind kind = (MessageKind)messageKind;

            switch (kind)
            {
            case MessageKind.SendingTime:
                SendingTimeMessage sendingTimeMessage = (SendingTimeMessage)msg;
                return("SendingTimeMessage: " + sendingTimeMessage.Message);

            case MessageKind.Simple:
                SimpleMessage simpleMessage = (SimpleMessage)msg;
                return("SimpleMessage: " + simpleMessage.Message);
            }

            return("UnKnown");
        }
        private string GetFormData(Func<object> messageDataFn, MessageKind messageKind)
        {
            object messageData;
            try
            {
                messageData = messageDataFn();
            }
            catch (Exception e)
            {
                LogError(string.Format("Error creating message data for {0} message", messageKind), e);
                return null;
            }

            string json;
            try
            {
                json = ToJson(messageData);
            }
            catch (Exception e)
            {
                LogError("Error serializing message to JSON.", e);
                return null;
            }

            try
            {
                return "data=" + ToBase64(json);
            }
            catch (Exception e)
            {
                LogError("Error converting message JSON to base64.", e);
                return null;
            }
        }
Example #13
0
 public SocketBuffer()
 {
     socketBuffer  = new byte[Const.BufferSize];
     outBuffer     = new List <byte>();
     messageKind   = MessageKind.Unknown;
     messageLength = int.MaxValue;
 }
Example #14
0
        protected override void Invoke(MessageNotification context, MessageKind kind, string title, string message, string detail, Window owner)
        {
            if (!(this.AssociatedObject is TaskbarIcon taskbarIcon))
            {
                return;
            }

            BalloonIcon image;

            switch (kind)
            {
            case MessageKind.Warning:
            case MessageKind.CancelableWarning:
                image = BalloonIcon.Warning;
                break;

            case MessageKind.Error:
                image = BalloonIcon.Error;
                break;

            default:
                image = BalloonIcon.Info;
                break;
            }

            taskbarIcon.ShowBalloonTip(message, detail, image);
        }
 public SocketBuffer()
 {
     socketBuffer = new byte[Const.BufferSize];
     outBuffer = new List<byte>();
     messageKind = MessageKind.Unknown;
     messageLength = int.MaxValue;
 }
Example #16
0
        private MixpanelMessage GetMessage(
            MessageKind messageKind,
            Func <MessageBuildResult> messageBuildResultFn)
        {
            try
            {
                MessageBuildResult messageBuildResult = messageBuildResultFn();
                if (!messageBuildResult.Success)
                {
                    LogError(
                        $"Cannot build message for {messageKind}.",
                        new Exception(messageBuildResult.Error));
                }

                return(new MixpanelMessage
                {
                    Kind = messageKind,
                    Data = messageBuildResult.Message
                });
            }
            catch (Exception e)
            {
                LogError($"Error building message for {messageKind}.", e);
                return(null);
            }
        }
Example #17
0
        private string GetMessageKindStr(MessageKind messageKind)
        {
            var ret = "未定義";

            switch (messageKind)
            {
            case MessageKind.Confirm:
                ret = "確認";
                break;

            case MessageKind.Info:
                ret = "情報";
                break;

            case MessageKind.Warn:
                ret = "警告";
                break;

            case MessageKind.Error:
                ret = "エラー";
                break;
            }

            return("[{0}]".Fmt(ret));
        }
Example #18
0
 public Message(MessageKind kind, Task sender, TaskResult result, Clause clause)
 {
     Kind   = kind;
     Sender = sender;
     Result = result;
     Clause = clause;
 }
Example #19
0
 private Message(MessageCode code, string text, MessageKind kind, params Diagnostics.Span[] carets)
 {
     this.code  = code;
     this.text  = text;
     this.kind  = kind;
     this.spans = carets;
 }
Example #20
0
 public NaccsException(MessageKind kind, int code, string detail, MessageBoxButtons button) : this()
 {
     this.kind = kind;
     this.code = code;
     this.detail = detail;
     this.button = button;
 }
        private bool SendMessageInternal(
            Func<object> getMessageDataFn, string endpoint, MessageKind messageKind)
        {
            string formData = GetFormData(getMessageDataFn, messageKind);
            if (formData == null)
            {
                return false;
            }

#if (PORTABLE || PORTABLE40)
            if (!ConfigHelper.HttpPostFnSet(_config))
            {
                throw new MixpanelConfigurationException(
                    "There is no default HTTP POST method in portable builds. Please use configuration to set it.");
            }
#endif

            string url = GenerateUrl(endpoint);
            try
            {
                var httpPostFn = ConfigHelper.GetHttpPostFn(_config);
                return httpPostFn(url, formData);
            }
            catch (Exception e)
            {
                LogError(string.Format("POST fails to '{0}' with data '{1}'", url, formData), e);
                return false;
            }
        }
Example #22
0
        private void AnalyzeManagedAssembly(string assemblyFilePath, IEnumerable <string> roslynAnalyzerFilePaths, BinaryAnalyzerContext context)
        {
            if (_globalRoslynAnalysisContext == null)
            {
                _globalRoslynAnalysisContext = new RoslynAnalysisContext();

                // We could use the ILDiagnosticsAnalyzer factory method that initializes
                // an object instance from an enumerable collection of analyzer paths. We
                // initialize a context object from each path one-by-one instead, in order
                // to make an attempt to load each specified analyzer. We will therefore
                // collect information on each analyzer that fails to load. We will also
                // proceed with performing as much analysis as possible. Ultimately, a
                // single analyzer load failure will return in BinSkim returning a non-zero
                // failure code from the run.
                foreach (string analyzerFilePath in roslynAnalyzerFilePaths)
                {
                    InvokeCatchingRelevantIOExceptions
                    (
                        action: () => { ILDiagnosticsAnalyzer.LoadAnalyzer(analyzerFilePath, _globalRoslynAnalysisContext); },
                        exceptionHandler: (ex) =>
                    {
                        LogExceptionLoadingRoslynAnalyzer(analyzerFilePath, context, ex);
                    }
                    );
                }
            }

            ILDiagnosticsAnalyzer roslynAnalyzer = ILDiagnosticsAnalyzer.Create(_globalRoslynAnalysisContext);

            roslynAnalyzer.Analyze(assemblyFilePath, diagnostic =>
            {
                MessageKind messageKind = diagnostic.Severity.ConvertToMessageKind();
                context.Logger.Log(messageKind, context, diagnostic.GetMessage(CultureInfo.CurrentCulture));
            });
        }
Example #23
0
    void AddMessage(MessageKind kind, string format, params object[] args)
    {
        var msg1 = string.Format(format, args);
        var msg2 = string.Format("{0}: {1}\n", kind.ToString("G").PadRight(16, ' '), msg1);

        textviewLog.Buffer.Text += msg2;
    }
Example #24
0
        public async Task LogAsync(string contents, string channel, MessageKind kind = MessageKind.Information, string title = null, params string[] tags)
        {
            // check inputs
            if (string.IsNullOrEmpty(title))
            {
                title = kind.ToString();
            }

            // create message
            var message = new Message()
            {
                Contents = contents,
                Channel  = channel,
                Kind     = kind,
                Title    = title
            };

            // check and add tags
            if (tags != null)
            {
                tags.ToList();
            }

            // send message
            await DoSendAsync(message, _configuration);
        }
Example #25
0
        private void EnqueueMessage(MessageKind kind, StreamMessage <TK, TP> message = null)
        {
            this.te.tasks.Enqueue(new QueuedMessage <StreamMessage> {
                Kind = kind, Message = message
            });
            var newCount = Interlocked.Increment(ref this.te.TaskCount);

            if (newCount == 1)
            {
                lock (this.scheduler.global)
                {
                    if (this.te.Status == TaskEntryStatus.Inactive)
                    {
                        // It's possible that a scheduler thread dequeues this event before this happens,
                        // and hence does not see the correct priority for the TaskEvent. This is benign.
                        this.te.Priority = message?.MinTimestamp ?? StreamEvent.MaxSyncTime;
                        this.te.Status   = TaskEntryStatus.HasWork;
                        this.scheduler.pendingTasks.Add(this.te);
                        if (this.scheduler.pendingTasks.Count == 1)
                        {
                            Monitor.Pulse(this.scheduler.global);
                        }
                    }
                }
            }
        }
Example #26
0
 internal void OnMessageReceived(byte[] message, MessageKind messageKind)
 {
     if (messageKind == MessageKind.Message)
     {
         MessageReceived(this, ReceivedEventArgs.NewEvent(message, messageKind));
     }
     else if (messageKind == MessageKind.ListClientId)
     {
         if (isServerSocket)
         {
             MessageReceived(this, ReceivedEventArgs.NewEvent(message, messageKind));
         }
         else
         {
             OnListClientIdReceived(message.ToListOfInt());
         }
     }
     else if (messageKind == MessageKind.ServerReady)
     {
     }
     else if (messageKind == MessageKind.ClientId)
     {
         OnClientIdReceived(message.ToInt());
     }
 }
Example #27
0
 public override void LogMessage(string message, MessageKind kind)
 {
     foreach (var logger in loggers)
     {
         logger.LogMessage(message, kind);
     }
 }
Example #28
0
 public MessageHeader(int messageSizeInBytes, RequestId requestId, ClientId clientId, MessageKind messageKind)
 {
     MessageSizeInBytes = messageSizeInBytes;
     RequestId          = requestId;
     ClientId           = clientId;
     MessageKind        = messageKind;
 }
Example #29
0
        /// <summary>
        /// メッセージのセット
        /// </summary>
        /// <param name="iMessage"></param>
        /// <param name="iKind"></param>
        private void setMessage(string iMessage, MessageKind iKind = MessageKind.Unknown)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke
                    ((MethodInvoker) delegate() { setMessage(iMessage, iKind); });
                return;
            }
            lblMessage.Text = iMessage;
            switch (iKind)
            {
            case MessageKind.Normal:
                toolStrip.BackColor = SystemColors.Control;
                break;

            case MessageKind.Execute:
                toolStrip.BackColor = Color.FromArgb(0x80, 0xFF, 0xFF);
                break;

            case MessageKind.Warning:
                toolStrip.BackColor = Color.FromArgb(0xFF, 0xFF, 0x80);
                SystemSounds.Asterisk.Play();
                break;

            case MessageKind.Critical:
                toolStrip.BackColor = Color.FromArgb(0xFF, 0x80, 0x80);
                SystemSounds.Hand.Play();
                break;

            default:
                break;
            }
        }
Example #30
0
 public void Log(MessageKind messageKind, BinaryAnalyzerContext context, string message)
 {
     foreach (IMessageLogger <BinaryAnalyzerContext> logger in Loggers)
     {
         logger.Log(messageKind, context, message);
     }
 }
Example #31
0
        private bool SendMessageInternal(
            Func <object> getMessageDataFn, string endpoint, MessageKind messageKind)
        {
            string formData = GetFormData(getMessageDataFn, messageKind);

            if (formData == null)
            {
                return(false);
            }

#if (PORTABLE || PORTABLE40)
            if (!ConfigHelper.HttpPostFnSet(_config))
            {
                throw new MixpanelConfigurationException(
                          "There is no default HTTP POST method in portable builds. Please use configuration to set it.");
            }
#endif

            string url = GenerateUrl(endpoint);
            try
            {
                var httpPostFn = ConfigHelper.GetHttpPostFn(_config);
                return(httpPostFn(url, formData));
            }
            catch (Exception e)
            {
                LogError(string.Format("POST fails to '{0}' with data '{1}'", url, formData), e);
                return(false);
            }
        }
Example #32
0
 private Message(MessageCode code, string text, MessageKind kind, params Diagnostics.Span[] carets)
 {
     this.code = code;
     this.text = text;
     this.kind = kind;
     this.spans = carets;
 }
Example #33
0
        public void Log(string contents, string channel, MessageKind kind = MessageKind.Information, string title = null, params string[] tags)
        {
            // check inputs
            if (string.IsNullOrWhiteSpace(title))
            {
                title = kind.ToString();
            }

            // create message
            var message = new Message()
            {
                Contents = contents,
                Channel  = channel,
                Kind     = kind,
                Title    = title
            };

            // check and add tags
            if (tags != null)
            {
                message.Tags = tags.ToList();
            }

            // log the message
            Log(message);
        }
Example #34
0
        public static string GetMessageKindString(MessageKind m)
        {
            switch (m)
            {
            case MessageKind.CommitMsg:
                return("commit");

            case MessageKind.NewViewMsg:
                return("new-view");

            case MessageKind.PrepareMsg:
                return("prepare");

            case MessageKind.PrePrepareMsg:
                return("pre-prepare");

            case MessageKind.UnknownMsg:
                return("unknown");

            case MessageKind.ViewChangedMsg:
                return("view-change");

            default:
                throw new Exception($"blockmania: unknown message kind: {m}");
            }
        }
Example #35
0
        public void Log(string message, string channelName, MessageKind kind = MessageKind.Information, string title = null, params string[] tags)
        {
            // create context
            var context = new SqlLoggerContext(_configuration.Connection);

            // add channel if it doesn't exist
            AddOrUpdateChannel(channelName, context);

            // find channel
            var channel = context.Channels.FirstOrDefault(c => c.Name == channelName);

            // log error for channel not found
            if (channel == null)
            {
                Log($"Channel not found - {channelName}", "historian.errors", MessageKind.Error, "Channel Not Found");
            }

            // create message
            var m = new Entities.Message
            {
                ChannelId = channel.Id,
                Contents  = message,
                Kind      = kind,
                Timestamp = DateTime.Now,
                Title     = title
            };

            // add and save message
            context.Messages.Add(m);
            context.SaveChanges();
        }
        public PendingDownstreamMessage(MessageKind kind, uint associationId, object message)
        {
            Require.NotNull(message, "message");

            Kind = kind;
            AssociationId = associationId;
            Message = message;
        }
Example #37
0
 public NaccsException(MessageKind kind, int code, string detail, MessageBoxButtons button, int adint)
 {
     this.machineName = "";
     this.exceptionTime = DateTime.Now;
     this.kind = kind;
     this.code = code;
     this.detail = detail;
     this.button = button;
     this.adint = adint;
 }
Example #38
0
 public NaccsException()
 {
     this.machineName = "";
     this.exceptionTime = DateTime.Now;
     this.kind = MessageKind.Information;
     this.code = 0;
     this.detail = "";
     this.button = MessageBoxButtons.OK;
     this.adint = 0;
 }
        private string GetFormData(Func<object> messageDataFn, MessageKind messageKind)
        {
#if (PORTABLE || PORTABLE40)
            if (!ConfigHelper.SerializeJsonFnSet(_config))
            {
                throw new MixpanelConfigurationException(
                    "There is no default JSON serializer in portable builds. Please use configuration to set it.");
            }
#endif

            object messageData;
            try
            {
                messageData = messageDataFn();
            }
            catch (Exception e)
            {
                LogError(string.Format("Error creating message data for {0} message", messageKind), e);
                return null;
            }

            string json;
            try
            {
                json = ToJson(messageData);
            }
            catch (Exception e)
            {
                LogError("Error serializing message to JSON.", e);
                return null;
            }

            try
            {
                return "data=" + ToBase64(json);
            }
            catch (Exception e)
            {
                LogError("Error converting message JSON to base64.", e);
                return null;
            }
        }
        private bool SendMessageInternal(
            Func<object> getMessageDataFn, string endpoint, MessageKind messageKind)
        {
            string formData = GetFormData(getMessageDataFn, messageKind);
            if (formData == null)
            {
                return false;
            }

            string url = GenerateUrl(endpoint);
            try
            {
                var httpPostFn = ConfigHelper.GetHttpPostFn(_config);
                return httpPostFn(url, formData);
            }
            catch (Exception e)
            {
                LogError(string.Format("POST fails to '{0}' with data '{1}'", url, formData), e);
                return false;
            }
        }
Example #41
0
        private void PrintLineExcerptWithHighlighting(MessageKind color, int line, Diagnostics.Span[] spans)
        {
            // FIXME! Not ready for multiple sources yet.
            var source = spans[0].unit;

            if (line >= source.GetNumberOfLines())
                return;

            int lineStart = source.GetLineStartPos(line);
            int index = lineStart;
            var inbetweenLast = false;

            // Step through each character in line.
            while (index <= source.Length())
            {
                // Find if this character is referenced by any caret.
                var highlight = false;
                var inbetween = false;
                foreach (var span in spans)
                {
                    if (index >= span.start && index < span.end)
                    {
                        highlight = true;
                    }
                    else if (!inbetweenLast && index == span.start && index == span.end)
                    {
                        highlight = true;
                        inbetween = true;
                    }
                }

                inbetweenLast = inbetween;

                // Set up text color for highlighting.
                if (highlight)
                {
                    Console.BackgroundColor = this.GetDarkColor(color);
                    Console.ForegroundColor = this.GetLightColor(color);
                }
                else
                {
                    Console.ResetColor();
                    Console.ForegroundColor = ConsoleColor.Gray;
                }

                // Print a space if two carets meet ends,
                // or print the current character.
                if (inbetween && (index == source.Length() || !(source[index] >= 0 && source[index] <= ' ')))
                {
                    Console.Write(" ");
                }
                else if (index == source.Length() || source[index] == '\n')
                {
                    Console.Write(" ");
                    break;
                }
                else
                {
                    if (source[index] == '\t')
                        Console.Write("  ");
                    else if (source[index] >= 0 && source[index] <= ' ')
                        Console.Write(" ");
                    else
                        Console.Write(source[index]);

                    index++;
                }

                Console.ResetColor();
            }
        }
 /// <summary>
 /// Initialise a new <see cref="Message"/> with a message.
 /// </summary>
 /// <param name="message">The message</param>
 /// <param name="kind">the message kind</param>
 public Message(string message, MessageKind kind)
 {
     this.message = message;
     this.Kind = kind;
 }
        public DialogResult ShowMessage(ButtonPatern buttonPatern, MessageKind messageKind, string message, MessageBoxDefaultButton defaultButton)
        {
            switch (messageKind)
            {
                case MessageKind.Information:
                    this.Text = "Private Terminal Software";
                    this.icon = SystemIcons.Information;
                    this.pictureBoxIcon.Image = this.icon.ToBitmap();
                    break;

                case MessageKind.Error:
                    this.Text = "Private Terminal Software";
                    this.icon = SystemIcons.Error;
                    this.pictureBoxIcon.Image = this.icon.ToBitmap();
                    break;

                case MessageKind.Warning:
                    this.Text = "Private Terminal Software";
                    this.icon = SystemIcons.Warning;
                    this.pictureBoxIcon.Image = this.icon.ToBitmap();
                    break;

                case MessageKind.Confirmation:
                    this.Text = "Private Terminal Software";
                    this.icon = SystemIcons.Question;
                    this.pictureBoxIcon.Image = this.icon.ToBitmap();
                    break;

                default:
                    return MessageBox.Show(string.Format(Resources.ResourceManager.GetString("CORE13"), messageKind));
            }
            switch (buttonPatern)
            {
                case ButtonPatern.OK_ONLY:
                    this.btnOK.TabIndex = 1;
                    this.flwPnlDown.Controls.Add(this.btnOK);
                    this.btnCANCEL.Size = new Size(0, 0);
                    this.btnCANCEL.TabStop = false;
                    this.flwPnlDown.Controls.Add(this.btnCANCEL);
                    base.CancelButton = this.btnCANCEL;
                    break;

                case ButtonPatern.OK_CANCEL:
                    this.btnOK.TabIndex = 1;
                    this.flwPnlDown.Controls.Add(this.btnOK);
                    this.btnCANCEL.TabIndex = 2;
                    this.flwPnlDown.Controls.Add(this.btnCANCEL);
                    base.CancelButton = this.btnCANCEL;
                    break;

                case ButtonPatern.YES_NO:
                    this.btnOK.TabIndex = 1;
                    this.flwPnlDown.Controls.Add(this.btnYES);
                    this.btnNO.TabIndex = 2;
                    this.flwPnlDown.Controls.Add(this.btnNO);
                    base.CancelButton = this.btnNO;
                    break;

                case ButtonPatern.YES_NO_CANCEL:
                    this.btnOK.TabIndex = 1;
                    this.flwPnlDown.Controls.Add(this.btnYES);
                    this.btnNO.TabIndex = 2;
                    this.flwPnlDown.Controls.Add(this.btnNO);
                    this.btnCANCEL.TabIndex = 3;
                    this.flwPnlDown.Controls.Add(this.btnCANCEL);
                    base.CancelButton = this.btnCANCEL;
                    break;

                default:
                    return MessageBox.Show(string.Format(Resources.ResourceManager.GetString("CORE14"), buttonPatern));
            }
            int num = 0;
            MessageBoxDefaultButton button = defaultButton;
            if (button == MessageBoxDefaultButton.Button2)
            {
                num = 1;
            }
            else if (button == MessageBoxDefaultButton.Button3)
            {
                num = 2;
            }
            else
            {
                num = 0;
            }
            if (num < this.flwPnlDown.Controls.Count)
            {
                this.flwPnlDown.Controls[num].Select();
            }
            this.rTxbMessage.Text = message;
            if (this.AutoSize)
            {
                Size size = new Size(base.Size.Width, base.Size.Height);
                if (this.rTxbMessage.Size.Width < (this.rTxbMessage.PreferredSize.Width + this.rTxbMessage.Margin.Horizontal))
                {
                    size.Width += (this.rTxbMessage.PreferredSize.Width + this.rTxbMessage.Margin.Horizontal) - this.rTxbMessage.Size.Width;
                }
                if (this.rTxbMessage.Lines.Length > 0)
                {
                    int num2 = this.rTxbMessage.GetPositionFromCharIndex(this.rTxbMessage.Lines[0].Length + 1).Y - this.rTxbMessage.GetPositionFromCharIndex(0).Y;
                    int num3 = (this.rTxbMessage.Lines.Length + 1) * num2;
                    if (this.rTxbMessage.Size.Height < (num3 + this.rTxbMessage.Margin.Vertical))
                    {
                        size.Height += (num3 + this.rTxbMessage.Margin.Vertical) - this.rTxbMessage.Size.Height;
                    }
                }
                this.MinimumSize = size;
            }
            return base.ShowDialog();
        }
 public DialogResult ShowMessage(ButtonPatern buttonPatern, MessageKind messageKind, string message)
 {
     return this.ShowMessage(buttonPatern, messageKind, message, MessageBoxDefaultButton.Button1);
 }
 private void ProcessMessage(MessageKind kind, uint type, uint length, uint associationId)
 {
     if (kind == MessageKind.Response)
         ProcessResponseMessage(type, length, associationId);
     else
         ProcessRequestMessage(type, length, associationId, kind == MessageKind.OneWay);
 }
Example #46
0
 public static Message Make(MessageCode code, string text, MessageKind kind, params Diagnostics.Span[] carets)
 {
     return new Message(code, text, kind, carets);
 }
Example #47
0
 private void ShowErrMessage(ButtonPatern bp, MessageKind mk, string err_str)
 {
     MessageDialog dialog = new MessageDialog();
     dialog.ShowMessage(bp, mk, err_str);
     dialog.Dispose();
 }
Example #48
0
 private ClientEventArgs(MessageKind kind)
 {
     Kind = kind;
 }
Example #49
0
        public virtual IMessageProvider Register(MessageKind[] kinds)
        {
            if (kinds == null || kinds.Length < 1) throw new ArgumentNullException("kinds");
            kinds = kinds.Distinct().OrderBy(e => e).ToArray();
            if (kinds == null || kinds.Length < 1) throw new ArgumentNullException("kinds");

            // 检查注册范围是否有效
            var ks = Kinds;
            if (ks != null)
            {
                foreach (var item in kinds)
                {
                    if (Array.IndexOf<MessageKind>(ks, item) < 0) throw new ArgumentOutOfRangeException("kinds", "当前消息提供者不支持Kind=" + item + "的消息!");
                }
            }

            var mc = new MessageConsumer() { Parent = this, Kinds = kinds };
            lock (Consumers)
            {
                Consumers.Add(mc);
            }
            mc.OnDisposed += (s, e) => Consumers.Remove(s as MessageConsumer);
            return mc;
        }
Example #50
0
 public virtual IMessageProvider Register(MessageKind start, MessageKind end)
 {
     if (start > end) throw new ArgumentOutOfRangeException("start", "起始不能大于结束!");
     //return Register(Enumerable.Range(start, end - start + 1).Select(e => (MessageKind)e).ToArray());
     var list = new List<MessageKind>();
     for (MessageKind i = start; i <= end; i++)
     {
         list.Add(i);
     }
     return Register(list.ToArray());
 }
Example #51
0
 public PacketHeader(MessageKind kind, ErrorKind error, uint responseTo)
 {
     Kind = kind;
     Error = error;
     SequenceNumberResponseTo = responseTo;
 }
Example #52
0
 private string GetKindName(MessageKind kind)
 {
     switch (kind)
     {
         case MessageKind.Internal: return "internal compiler error";
         case MessageKind.Error: return "error";
         case MessageKind.Warning: return "warning";
         case MessageKind.Style: return "style";
         case MessageKind.Info: return "info";
         default: return "unknown";
     }
 }
Example #53
0
 private ConsoleColor GetLightColor(MessageKind kind)
 {
     switch (kind)
     {
         case MessageKind.Internal: return ConsoleColor.Red;
         case MessageKind.Error: return ConsoleColor.Red;
         case MessageKind.Warning: return ConsoleColor.Yellow;
         case MessageKind.Style: return ConsoleColor.Magenta;
         case MessageKind.Info: return ConsoleColor.Cyan;
         default: return ConsoleColor.White;
     }
 }
Example #54
0
 public NaccsException(MessageKind kind, int code, string detail) : this()
 {
     this.kind = kind;
     this.code = code;
     this.detail = detail;
 }
Example #55
0
 public static ServerReceivedEventArgs NewEvent(Client client, byte[] message, MessageKind messageKind)
 {
     return new ServerReceivedEventArgs() { Client = client, Message = message, MessageKind = messageKind };
 }
Example #56
0
 private void ShowEditErrMessage(ButtonPatern bp, MessageKind mk, string err_str, TextBox txb)
 {
     MessageDialog dialog = new MessageDialog();
     dialog.ShowMessage(bp, mk, string.Concat(new object[] { txb.Tag.ToString(), "は", txb.MaxLength, err_str }));
     dialog.Dispose();
 }
Example #57
0
 public static ReceivedEventArgs NewEvent(byte[] message, MessageKind messageKind)
 {
     return new ReceivedEventArgs() { Message = message , MessageKind = messageKind };
 }
Example #58
0
 private ConsoleColor GetDarkColor(MessageKind kind)
 {
     switch (kind)
     {
         case MessageKind.Internal: return ConsoleColor.DarkRed;
         case MessageKind.Error: return ConsoleColor.DarkRed;
         case MessageKind.Warning: return ConsoleColor.DarkYellow;
         case MessageKind.Style: return ConsoleColor.DarkMagenta;
         case MessageKind.Info: return ConsoleColor.DarkCyan;
         default: return ConsoleColor.Gray;
     }
 }
Example #59
0
        private void PrintExcerptWithHighlighting(MessageKind color, params Diagnostics.Span[] spans)
        {
            if (spans.Length == 0)
                return;

            // FIXME! Not ready for multiple sources yet.
            var source = spans[0].unit;
            if (source == null)
                return;

            // Find the very first and the very last lines
            // referenced by any caret, with some added margin around.
            int startLine = -1;
            int endLine = -1;
            foreach (var span in spans)
            {
                int start = source.GetLineIndexAtSpanStart(span) - 2;
                int end = source.GetLineIndexAtSpanEnd(span) + 2;

                if (start < startLine || startLine == -1)
                    startLine = start;

                if (end > endLine || endLine == -1)
                    endLine = end;
            }

            if (startLine < 0)
                startLine = 0;

            if (endLine >= source.GetNumberOfLines())
                endLine = source.GetNumberOfLines() - 1;

            // Step through the referenced line range,
            // skipping lines in between that are too far away from any caret.
            bool skipped = false;
            for (int i = startLine; i <= endLine; i++)
            {
                if (GetMinimumLineDistanceFromCarets(spans, i) > 2)
                {
                    if (!skipped)
                    {
                        Console.Write(this.indentation);
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("".PadLeft(6) + "...");
                    }
                    skipped = true;
                    continue;
                }
                else
                    skipped = false;

                Console.ForegroundColor = ConsoleColor.White;
                Console.Write(this.indentation);
                Console.Write((i + 1).ToString().PadLeft(5) + ": ");

                PrintLineExcerptWithHighlighting(color, i, spans);

                Console.ResetColor();
                Console.WriteLine();
            }
        }
Example #60
0
		internal void OnMessageReceived(Client client, byte[] message, MessageKind messageKind)
		{
			if (messageKind == MessageKind.Message)
			{
				MessageReceived(this, ServerReceivedEventArgs.NewEvent(client, message, messageKind));
			}
			else if (messageKind == MessageKind.ListClientId)
			{
				client.Send(clients.Keys.ToArrayOfByte(), MessageKind.ListClientId);
			}
		}