This commit is contained in:
parent
2d30a26f49
commit
835c1c7362
@ -68,6 +68,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion
|
||||
#region Properties and Variables
|
||||
|
||||
private static FontFamily _MyFontFamily = null;
|
||||
public static FontFamily MyFontFamily
|
||||
{
|
||||
@ -247,7 +248,7 @@ namespace Volian.Controls.Library
|
||||
FindAllLinks();
|
||||
}
|
||||
SelectAll();
|
||||
SelectionHangingIndent = 0;
|
||||
if (SelectionHangingIndent !=0) SelectionHangingIndent = 0;
|
||||
int indchar = 0;
|
||||
string indentToken = _MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IndentToken;
|
||||
if (indentToken == null) indentToken = "\x5";
|
||||
@ -395,12 +396,39 @@ namespace Volian.Controls.Library
|
||||
this.KeyUp += new KeyEventHandler(StepRTB_KeyUp);
|
||||
this.TextChanged += new EventHandler(StepRTB_TextChanged);
|
||||
this.MouseUp += new MouseEventHandler(StepRTB_MouseUp);
|
||||
this.MouseDown += new MouseEventHandler(StepRTB_MouseDown);
|
||||
this.MouseDown += new MouseEventHandler(StepRTB_MouseDown);
|
||||
this.MouseLeave += new EventHandler(StepRTB_MouseLeave);
|
||||
this.SelectionChanged +=new EventHandler(StepRTB_SelectionChanged);
|
||||
this.ContextMenuStripChanged += new EventHandler(StepRTB_ContextMenuStripChanged);
|
||||
this.RTBSelectionChanged += new StepRTBEvent(StepRTB_RTBSelectionChanged);
|
||||
}
|
||||
|
||||
void StepRTB_RTBSelectionChanged(object sender, EventArgs args)
|
||||
{
|
||||
//Console.WriteLine("RTBSelectionChanged id= {0}", MyItemInfo.ItemID);
|
||||
if (!Focused) Focus();
|
||||
}
|
||||
|
||||
void StepRTB_ContextMenuStripChanged(object sender, EventArgs e)
|
||||
{
|
||||
//Console.WriteLine("********** StepRTB_ContextMenuStripChanged");
|
||||
try
|
||||
{
|
||||
Console.WriteLine("{0}", ContextMenuStrip.GetType().FullName);
|
||||
this.MyStepItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ClearContextMenu();
|
||||
_ContextMenuStripChanged = true;
|
||||
_ContextMenuStepRTB = this;
|
||||
_ContextMenuStrip = ContextMenuStrip;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("{0} - {1}", ex.GetType().Name, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetUpStepRTB()
|
||||
{
|
||||
C1SpellChecker2.SetActiveSpellChecking(this, true);
|
||||
this.Height = 10; // initialize the height to 10, the default height was too big for the cells in grid tables
|
||||
BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.ScrollBars = RichTextBoxScrollBars.None;
|
||||
@ -425,19 +453,31 @@ namespace Volian.Controls.Library
|
||||
public bool inRoAdd = false;
|
||||
void StepRTB_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
//Console.WriteLine("StepRTB_SelectionChanged id= {0}", MyItemInfo.ItemID);
|
||||
if (_InitializingRTB) return;
|
||||
HandleSelectionChange();
|
||||
}
|
||||
private bool _MouseDown = false;
|
||||
private bool _ContextMenuStripChanged = false;
|
||||
private void StepRTB_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
_MouseDown = true;
|
||||
//Console.WriteLine("vvvvvvvvvv StepRTB Mouse Down id= {0}",MyItemInfo.ItemID);
|
||||
if (!_ContextMenuStripChanged)
|
||||
this.MyStepItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetContextMenu();
|
||||
_ContextMenuStripChanged = false;
|
||||
}
|
||||
void StepRTB_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
_MouseDown = false;
|
||||
if(this.Focused) // Only HandleSelectionChange if this control has focus.
|
||||
//Console.WriteLine("^^^^^^^^^^ StepRTB Mouse Up id= {0}", MyItemInfo.ItemID);
|
||||
|
||||
if (this.Focused) // Only HandleSelectionChange if this control has focus.
|
||||
{
|
||||
HandleSelectionChange();
|
||||
// save our context menu to add to the spell checker's context menu
|
||||
ThisContextMenuStrip = this.ContextMenuStrip;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region ApplicationSupport
|
||||
@ -2466,6 +2506,97 @@ namespace Volian.Controls.Library
|
||||
SelectedRtf = SelectedRtf.Replace(" " + charToBeReplaced, "");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region SpellChecker
|
||||
// We made the Spell Checker method a static so that all of the StepRTB boxes will sbare the same instace of the dictionary.
|
||||
// This allow all the StepRTB's to automatically update when a new word is added.
|
||||
private static C1.Win.C1SpellChecker.C1SpellChecker _C1SpellChecker2;
|
||||
|
||||
private static C1.Win.C1SpellChecker.C1SpellChecker C1SpellChecker2
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_C1SpellChecker2 == null)
|
||||
{
|
||||
_C1SpellChecker2 = new C1.Win.C1SpellChecker.C1SpellChecker();
|
||||
_C1SpellChecker2.ContextMenuCreated += new C1.Win.C1SpellChecker.ContextMenuEventHandler(_C1SpellChecker2_ContextMenuCreated);
|
||||
//_C1SpellChecker2.UserDictionary.FileName = @"C:\Development\proms\VEPROMS User Interface\bin\Debug\MYDictionary.dct";
|
||||
}
|
||||
return StepRTB._C1SpellChecker2;
|
||||
}
|
||||
}
|
||||
|
||||
// Get or Save our context menu
|
||||
// This is added to the the spell checker's context menu for a mis-spelled word
|
||||
private static ContextMenuStrip _ThisContextMenuStrip;
|
||||
public ContextMenuStrip ThisContextMenuStrip
|
||||
{
|
||||
get { return _ThisContextMenuStrip; }
|
||||
set { _ThisContextMenuStrip = value; }
|
||||
}
|
||||
|
||||
private static StepRTB _ContextMenuStepRTB;
|
||||
private static object _ContextMenuStrip;
|
||||
|
||||
static void _C1SpellChecker2_ContextMenuCreated(object sender, C1.Win.C1SpellChecker.ContextMenuEventArgs e)
|
||||
{
|
||||
// Adjust their bad word context menu
|
||||
//Console.WriteLine("==========> spell check context menu {0}",e.Menu.Items[0].Text);
|
||||
if (e.Menu.Equals(_ContextMenuStrip))
|
||||
{
|
||||
// Add an item for our "Edit Menu" context menu on their spell check context menu
|
||||
// This gives the user access to our regular context menu when on a mis-spelled word
|
||||
ToolStripItem tsi = e.Menu.Items.Add("Edit Menu");
|
||||
tsi.Click += new EventHandler(tsi_Click);
|
||||
//Now replace their "Spell" item with ours, so that we can display our custom spell check dialog
|
||||
for (int i = 0; i < e.Menu.Items.Count; i++)
|
||||
{
|
||||
ToolStripItem tsi1 = e.Menu.Items[i];
|
||||
if (tsi1 is ToolStripMenuItem && tsi1.Text == "Spell")
|
||||
{
|
||||
e.Menu.Items.RemoveAt(i); // remove their spell check dialog item
|
||||
ToolStripMenuItem tsi2 = new ToolStripMenuItem("Spell");
|
||||
tsi2.Click += new EventHandler(tsi2_Click);
|
||||
e.Menu.Items.Insert(i, tsi2); // add our spell check dialog item
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void tsi2_Click(object sender, EventArgs e)
|
||||
{
|
||||
C1SpellChecker2.CheckControl(_ContextMenuStepRTB, true, MySpellCheckDlg);
|
||||
}
|
||||
|
||||
// Click event to display our "Edit Menu" (StepRTB context menu)
|
||||
static void tsi_Click(object sender, EventArgs e)
|
||||
{
|
||||
ToolStripMenuItem tsmi = sender as ToolStripMenuItem;
|
||||
_ContextMenuStepRTB.MyStepItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.OpenContextMenu(tsmi.Owner.Location);
|
||||
}
|
||||
|
||||
// This is our customized Spell Check dialog
|
||||
// This is display when the use clicks the Spell button from the Ribbon
|
||||
// or when the "Spell" item is selected from the context menu when on a mis-spelled word
|
||||
static VlnSpellCheckDlg _MySpellCheckDlg;
|
||||
public static VlnSpellCheckDlg MySpellCheckDlg
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_MySpellCheckDlg == null)
|
||||
_MySpellCheckDlg = new VlnSpellCheckDlg();
|
||||
return _MySpellCheckDlg;
|
||||
}
|
||||
}
|
||||
|
||||
// This is used when walking through the section doing a spell check
|
||||
// (from the Spell button on the ribbon)
|
||||
public bool SpellCheckNext()
|
||||
{
|
||||
int nBad = C1SpellChecker2.CheckControl(this, false, MySpellCheckDlg);
|
||||
return (nBad >= 0); // nBad = -1 means user pressed Cancel button
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region Debug
|
||||
private bool _ShowDebug = false;
|
||||
@ -2491,6 +2622,7 @@ namespace Volian.Controls.Library
|
||||
|
||||
private void StepRTB_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
||||
{
|
||||
Console.WriteLine("StepRTB_PreviewKeyDown");
|
||||
if ((e.KeyCode == Keys.Tab) && (!e.Alt && !e.Control))
|
||||
e.IsInputKey = true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user