-
-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BiLinkDialog with option to hide
- Loading branch information
1 parent
32ad7f5
commit c0ae047
Showing
5 changed files
with
3,221 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
//************************************************************************************************ | ||
// Copyright © 2024 Steven M Cohn. All rights reserved. | ||
//************************************************************************************************ | ||
|
||
namespace River.OneMoreAddIn.Commands | ||
{ | ||
using River.OneMoreAddIn.Settings; | ||
using River.OneMoreAddIn.UI; | ||
using System.Drawing; | ||
using System.Windows.Forms; | ||
using Resx = Properties.Resources; | ||
|
||
|
||
internal partial class BiLinkDialog : MoreForm | ||
{ | ||
|
||
public BiLinkDialog() | ||
{ | ||
InitializeComponent(); | ||
|
||
if (NeedsLocalizing()) | ||
{ | ||
Text = Resx.ProgramName; | ||
|
||
Localize(new string[] | ||
{ | ||
"okButton=word_OK" | ||
}); | ||
} | ||
|
||
iconBox.Image = SystemIcons.Information.ToBitmap(); | ||
messageBox.Clear(); | ||
} | ||
|
||
|
||
public void SetAnchorText(string text) | ||
{ | ||
text = string.Format(Resx.BiLinkCommand_Marked, text); | ||
|
||
var size = TextRenderer.MeasureText( | ||
text, messageBox.Font, messageBox.Size, TextFormatFlags.NoClipping); | ||
|
||
// leave a little room (is this good?) | ||
var preferred = size.Height + messageBox.Font.Height; | ||
if (preferred > messageBox.Height) | ||
{ | ||
Height += preferred - messageBox.Height; | ||
} | ||
|
||
messageBox.Text = text; | ||
} | ||
|
||
|
||
private void HideSelection(object sender, System.EventArgs e) | ||
{ | ||
// move the cursor to the end | ||
if (messageBox.SelectionStart != messageBox.TextLength) | ||
{ | ||
messageBox.SelectionStart = messageBox.TextLength; | ||
okButton.Focus(); | ||
} | ||
} | ||
|
||
|
||
private void DoKeyDown(object sender, KeyEventArgs e) | ||
{ | ||
if (e.Modifiers != Keys.None) | ||
{ | ||
return; | ||
} | ||
|
||
if (e.KeyCode == Keys.Escape) | ||
{ | ||
e.Handled = true; | ||
DialogResult = DialogResult.Cancel; | ||
Close(); | ||
} | ||
} | ||
|
||
|
||
private void DoClick(object sender, System.EventArgs e) | ||
{ | ||
// check if user wants to hide this in the future | ||
if (hideBox.Checked) | ||
{ | ||
var settings = new SettingsProvider(); | ||
var collection = settings.GetCollection(BiLinkCommand.SettingsName); | ||
collection.Add("hideStartMessage", true); | ||
settings.SetCollection(collection); | ||
settings.Save(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.