예제 #1
0
        public void SetContent(string text)
        {
            richTextBox1.Text = text == "" ? "(Empty)" : text ?? "(Null)";
            Size textsize = GuiTool.CalculateTextSize(Content, TextFont, MaxClientSize.Width);

            ClientSize = new Size(textsize.Width + padding * 2, Math.Min(textsize.Height + padding * 2, MaxClientSize.Height));
        }
예제 #2
0
        public MessageForm(string title = null, string content = null)
        {
            InitializeComponent();

            padding       = richTextBox1.Location.X;
            MinClientSize = new Size(200, GuiTool.CalculateTextSize(Content, TextFont).Height + padding * 2);
            MaxClientSize = new Size(1600, 1000);
            MinimumSize   = this.ClientToFull(MinClientSize);
            MaximumSize   = this.ClientToFull(MaxClientSize);

            richTextBox1.TextChanged += (o, e) => richTextBox1.ScrollToBottom();
            richTextBox1.MouseWheel  += (o, e) => richTextBox1.Scroll(e.Delta, false);

            richTextBox1.MouseDown  += (o, e) => WinAPI.HideCaret(richTextBox1.Handle);
            richTextBox1.GotFocus   += (o, e) => WinAPI.HideCaret(richTextBox1.Handle);
            richTextBox1.MouseWheel += (o, e) => WinAPI.HideCaret(richTextBox1.Handle);

            SetTitle(title);
            SetContent(content);
            Location = new Area(size: Size).CenterOn(Monitor.Primary.WorkArea);

            Application.AddMessageFilter(MessageFilterTool.Create(m => (WM)m.Msg == WM.CHAR && !KeyHandler.IsDown(Key.LCtrl), m => Close()));
        }
예제 #3
0
 /// <summary>Call a delegate on the form's thread for safe form handling</summary>
 public T Execute <T>(Func <T> action) => GuiTool.Execute(GenericForm, action);
예제 #4
0
 /// <summary>Call a delegate on the form's thread for safe form handling</summary>
 public async Task <T> Execute <T>(Func <Task <T> > asyncAction) => await GuiTool.Execute(GenericForm, asyncAction);
예제 #5
0
 /// <summary>Call a delegate on the form's thread for safe form handling</summary>
 public void Execute(Action action) => GuiTool.Execute(GenericForm, action);