view ServerMonitor/Forms/QuickHelpForm.cs @ 5:b6fe203af9d5

Private key passwords and validation
author Brad Greco <brad@bgreco.net>
date Thu, 28 Feb 2019 21:19:32 -0500
parents 3e1a2131f897
children 2db36ab759de
line wrap: on
line source

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ServerMonitorApp
{
    public partial class QuickHelpForm : Form
    {
        private string Rtf;

        public QuickHelpForm()
        {
            InitializeComponent();
        }

        public QuickHelpForm(string rtf)
        {
            InitializeComponent();
            Rtf = rtf;
        }

        private void QuickHelpForm_Load(object sender, EventArgs e)
        {
            (Owner as CheckForm).HelpLocationChanged += Owner_HelpPositionChanged;
            HelpTextBox.ContentsResized += HelpTextBox_ContentsResized; // Causes form to resize after Rtf is assigned
            HelpTextBox.Rtf = Rtf;
        }

        private void HelpTextBox_ContentsResized(object sender, ContentsResizedEventArgs e)
        {
            Height = e.NewRectangle.Height + 12;
        }

        private void Owner_HelpPositionChanged(object sender, HelpLocationChangedEventArgs e)
        {
            Point location = e.HelpLocation;
            location.Offset(24, 0);
            Location = location;
        }

        private void Control_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
                Close();
        }

        private void Control_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}