public ToolForm(Control target, EPin pin, Point ofs, Size size, bool modal) { m_ofs = ofs; m_pin = pin; Owner = target?.TopLevelControl as Form; Icon = Owner?.Icon; AutoScaleDimensions = new SizeF(6F, 13F); AutoScaleMode = AutoScaleMode.Font; StartPosition = FormStartPosition.Manual; HideOnClose = !modal; AutoFade = false; FadeRange = new RangeF(1.0, 1.0); SetStyle(ControlStyles.SupportsTransparentBackColor, true); if (size != Size.Empty) { Size = size; } // Pin to the target window PinWindow = true; PinTarget = target; // Calling CreateHandle here prevents this window appearing over the parent if the parent is TopMost //if (!modal) // CreateHandle(); }
// Notes: // - Dispose is called when 'window' is closed // // Usage: // In your window class: // ctor() // { // // Dispose is handled by 'PinData' // PinState = new PinData(this, EPin.Centre); // } // // /// <summary>Support pinning this window</summary> // private PinData PinState { get; } // public PinData(Window window, EPin pin_site = EPin.Centre, bool pinned = true) { m_pin_window = null !; PinSite = pin_site; PinWindow = window; PinTarget = window.Owner ?? Application.Current.MainWindow; Pinned = pinned; }
public FindUI(Control target = null, EPin pin = EPin.Centre) : base(target, pin) { InitializeComponent(); KeyPreview = true; m_pat = new Pattern(); m_pat.PropertyChanged += UpdateUI; // Button images m_il.TransparentColor = Color.Transparent; m_il.Images.Add("prev", Resources.green_left); m_il.Images.Add("next", Resources.green_right); // Search pattern m_cb_pattern.TextChanged += (s, a) => { m_pat.Expr = m_cb_pattern.Text; }; // Radio buttons m_radio_substr.Click += (s, a) => { if (m_radio_substr.Checked) { m_pat.PatnType = EPattern.Substring; } }; m_radio_wildcard.Click += (s, a) => { if (m_radio_wildcard.Checked) { m_pat.PatnType = EPattern.Wildcard; } }; m_radio_regexp.Click += (s, a) => { if (m_radio_regexp.Checked) { m_pat.PatnType = EPattern.RegularExpression; } }; // Search options m_chk_ignore_case.CheckedChanged += (s, a) => { m_pat.IgnoreCase = m_chk_ignore_case.Checked; }; m_chk_invert.CheckedChanged += (s, a) => { m_pat.Invert = m_chk_invert.Checked; }; // Find buttons m_btn_find_next.Click += (s, a) => OnFind(new FindEventArgs(+1)); m_btn_find_prev.Click += (s, a) => OnFind(new FindEventArgs(-1)); UpdateUI(); }
public HelpUI(Control parent, EContent type, string title, string content, Point?ofs = null, Size?size = null, EPin pin = EPin.TopRight, bool modal = false) : base(parent, pin, ofs ?? Point.Empty, size ?? Size.Empty, modal) { InitializeComponent(); Type = type; Text = title; Content = content; m_btn_back.Enabled = false; m_btn_forward.Enabled = false; SetStatusText(null); switch (Type) { default: throw new Exception("Unknown content type"); case EContent.Text: { var txt = new TextBox { Dock = DockStyle.Fill, BorderStyle = BorderStyle.None, Multiline = true, ScrollBars = ScrollBars.Both, ReadOnly = true, }; txt.Text = Content; TextCtrl = txt; break; } case EContent.Rtf: { var rtb = new RichTextBox { Dock = DockStyle.Fill, BorderStyle = BorderStyle.None, DetectUrls = true, ReadOnly = true, }; rtb.Rtf = Content; rtb.LinkClicked += OnLinkClicked; TextCtrl = rtb; break; } case EContent.Html: { var web = new BrowserCtrl { Dock = DockStyle.Fill, AllowNavigation = true }; web.CanGoForwardChanged += (s, a) => m_btn_forward.Enabled = web.CanGoForward; web.CanGoBackChanged += (s, a) => m_btn_back.Enabled = web.CanGoBack; web.ResolveContent += (s, a) => ResolveContent(a); web.StatusTextChanged += (s, a) => SetStatusText(web.StatusText != "Done" ? web.StatusText : string.Empty); web.UrlHistory.Add(new BrowserCtrl.Visit(HelpUrl)); TextCtrl = web; ShowNavigationButtons = true; break; } } TextCtrl.BackColor = SystemColors.Window; m_panel.Controls.Add(TextCtrl); m_btn_ok.Click += Close; m_btn_forward.Click += OnForward; m_btn_back.Click += OnBack; }
/// <summary>Show a modal help dialog from plain text, RTF, or html</summary> public static DialogResult ShowDialog(Control parent, EContent type, string title, string content, Point?ofs = null, Size?size = null, EPin pin = EPin.TopRight) { using (var ui = new HelpUI(parent, type, title, content, ofs, size, pin, true)) return(ui.ShowDialog(parent)); }
public ToolForm(Control target, EPin pin, Point ofs) : this(target, pin, ofs, Size.Empty, false) { }
public OnShowPin(EPin iPin, bool iState) { targetPin = iPin; targetState = iState; }