예제 #1
0
파일: WideMessageBox.cs 프로젝트: rkm/RDMP
        public WideMessageBox(WideMessageBoxArgs args)
        {
            InitializeComponent();

            Setup(args);

            //can only write to clipboard in STA threads
            btnCopyToClipboard.Visible = Thread.CurrentThread.GetApartmentState() == ApartmentState.STA;

            //try to resize form to fit bounds
            this.Size = GetPreferredSizeOfTextControl(richTextBox1);
            this.Size = new Size(this.Size.Width + 10, this.Size.Height + 150);//leave a bit of padding

            var theScreen = Screen.FromControl(this);

            //enforce sensible max/min sizes
            Width = Math.Min(Math.Max(600, Width), theScreen.Bounds.Width - 400);

            //if the text is too long vertically just maximise the message box
            if (this.Height > theScreen.Bounds.Height)
            {
                this.WindowState = FormWindowState.Maximized;
            }

            richTextBox1.LinkClicked += richTextBox1_LinkClicked;
            btnViewSourceCode.Click  += (s, e) => new ViewSourceCodeDialog((string)btnViewSourceCode.Tag).Show();
        }
예제 #2
0
        protected void Setup(WideMessageBoxArgs args)
        {
            Args = args;

            btnBack.Enabled = _navigationStack.Any();

            btnViewStackTrace.Visible = args.EnvironmentDotStackTrace != null;

            richTextBox1.Font = new Font(FontFamily.GenericMonospace, richTextBox1.Font.Size);
            richTextBox1.Select(0, 0);
            richTextBox1.WordWrap = true;
            richTextBox1.Text     = "";

            var message = args.Message;
            var title   = args.Title;

            //todo hack:if there's a long title and no message
            if (!string.IsNullOrWhiteSpace(title) && string.IsNullOrWhiteSpace(message) && title.Length > 100)
            {
                message = title;
                title   = null;
            }

            //Replace single newlines with double new lines
            if (Args.FormatAsParagraphs && CommentStore != null)
            {
                message = CommentStore.FormatAsParagraphs(message);
            }

            //if there is a title
            if (!string.IsNullOrWhiteSpace(title))
            {
                lblMainMessage.Text = title.Length > MAX_LENGTH_TITLE?title.Substring(0, MAX_LENGTH_TITLE) : title;
            }
            else
            {
                richTextBox1.Top       = lblMainMessage.Top;
                richTextBox1.Height   += lblMainMessage.Top;
                lblMainMessage.Visible = false;
            }

            SetMessage(message, args.KeywordNotToAdd);

            ApplyTheme(args.Theme);

            if (args.Theme == WideMessageBoxTheme.Help)
            {
                SetViewSourceCodeButton(args.Title);
            }
        }
예제 #3
0
        public WideMessageBox(WideMessageBoxArgs args)
        {
            InitializeComponent();

            Setup(args);

            //can only write to clipboard in STA threads
            btnCopyToClipboard.Visible = Thread.CurrentThread.GetApartmentState() == ApartmentState.STA;

            //try to resize form to fit bounds
            this.Size = GetPreferredSizeOfTextControl(richTextBox1);
            this.Size = new Size(this.Size.Width + 10, this.Size.Height + 150);//leave a bit of padding

            richTextBox1.LinkClicked += richTextBox1_LinkClicked;
            btnViewSourceCode.Click  += (s, e) => new ViewSourceCodeDialog((string)btnViewSourceCode.Tag).Show();
        }
예제 #4
0
        private YesNoYesToAllDialog(WideMessageBoxArgs wideMessageBoxArgs) : base(wideMessageBoxArgs)
        {
            AddButton(btnYes);
            AddButton(btnYesToAll);
            AddButton(btnNo);
            AddButton(btnNoToAll);

            p.Dock = DockStyle.Fill;

            ButtonsPanel.Controls.Clear();
            ButtonsPanel.Controls.Add(p);

            MinimumSize = new Size(600, 300);

            //start at no in case they close with X button
            DialogResult = DialogResult.No;
        }