Commit b0eeb519 authored by JoyJ's avatar JoyJ

hint when use different card code at function

parent 44764797
...@@ -83,6 +83,7 @@ void InitForm() ...@@ -83,6 +83,7 @@ void InitForm()
{ {
MinFragmentLength = 2 MinFragmentLength = 2
}; };
this.fctb.TextChanged += this.Fctb_TextChanged;
this.popupMenu.ToolTip.Popup += this.ToolTip_Popup; this.popupMenu.ToolTip.Popup += this.ToolTip_Popup;
this.popupMenu.Items.Font = ft; this.popupMenu.Items.Font = ft;
this.popupMenu.AutoSize = true; this.popupMenu.AutoSize = true;
...@@ -92,25 +93,39 @@ void InitForm() ...@@ -92,25 +93,39 @@ void InitForm()
this.popupMenu.Closed += new ToolStripDropDownClosedEventHandler(this.popupMenu_Closed); this.popupMenu.Closed += new ToolStripDropDownClosedEventHandler(this.popupMenu_Closed);
this.popupMenu.SelectedColor = Color.LightGray; this.popupMenu.SelectedColor = Color.LightGray;
this.popupMenu.VisibleChanged += this.PopupMenu_VisibleChanged; this.popupMenu.VisibleChanged += this.PopupMenu_VisibleChanged;
this.popupMenu.Opened += this.PopupMenu_VisibleChanged;
this.popupMenu.Items.FocussedItemIndexChanged += this.Items_FocussedItemIndexChanged; this.popupMenu.Items.FocussedItemIndexChanged += this.Items_FocussedItemIndexChanged;
this.title = this.Text; this.title = this.Text;
} }
private void Fctb_TextChanged(object sender, TextChangedEventArgs e)
{
this.PopupMenu_VisibleChanged(null, null);
}
private void ToolTip_Popup(object sender, PopupEventArgs e) private void ToolTip_Popup(object sender, PopupEventArgs e)
{ {
e.Cancel = true; e.Cancel = true;
} }
private void PopupMenu_VisibleChanged(object sender, EventArgs e) private void PopupMenu_VisibleChanged(object sender, EventArgs e)
{
if (!this.popupMenu.Visible)
{ {
this.AdjustPopupMenuSize(); this.AdjustPopupMenuSize();
if (!this.popupMenu.Visible || this.popupMenu.Items.FocussedItem == null) return;
}
if (this.popupMenu.Items.FocussedItem == null)
{
if (this.popupMenu.Items.Count == 0)
{ {
return; return;
} }
this.popupMenu.Items.FocussedItemIndex = 0;
}
this.fctb.ShowTooltipWithLabel(this.popupMenu.Items.FocussedItem.ToolTipTitle, this.fctb.ShowTooltipWithLabel(this.popupMenu.Items.FocussedItem.ToolTipTitle,
this.popupMenu.Items.FocussedItem.ToolTipText); this.popupMenu.Items.FocussedItem.ToolTipText);
this.AdjustPopupMenuSize();
} }
private void AdjustPopupMenuSize() private void AdjustPopupMenuSize()
{ {
...@@ -118,6 +133,7 @@ private void AdjustPopupMenuSize() ...@@ -118,6 +133,7 @@ private void AdjustPopupMenuSize()
{ {
this.popupMenu.Size = new Size(300, 0); this.popupMenu.Size = new Size(300, 0);
this.popupMenu.MinimumSize = new Size(300, 0); this.popupMenu.MinimumSize = new Size(300, 0);
return;
} }
Size s = TextRenderer.MeasureText(this.popupMenu.Items.FocussedItem.ToolTipTitle, Size s = TextRenderer.MeasureText(this.popupMenu.Items.FocussedItem.ToolTipTitle,
this.popupMenu.Items.Font, new Size(0, 0), TextFormatFlags.NoPadding); this.popupMenu.Items.Font, new Size(0, 0), TextFormatFlags.NoPadding);
...@@ -176,6 +192,12 @@ public bool Open(string file) ...@@ -176,6 +192,12 @@ public bool Open(string file)
fs.Close(); fs.Close();
} }
this.nowFile = file; this.nowFile = file;
FileInfo fi = new FileInfo(file);
if (fi.Name.ToUpper().EndsWith(".LUA"))
{
(this.fctb.SyntaxHighlighter as MySyntaxHighlighter).cCode
= fi.Name.Substring(0, fi.Name.Length - 4);
}
string cdb = MyPath.Combine( string cdb = MyPath.Combine(
Path.GetDirectoryName(file), "../cards.cdb"); Path.GetDirectoryName(file), "../cards.cdb");
this.SetCardDB(cdb);//后台加载卡片数据 this.SetCardDB(cdb);//后台加载卡片数据
......
...@@ -15,7 +15,6 @@ public class FastColoredTextBoxEx : FastColoredTextBox ...@@ -15,7 +15,6 @@ public class FastColoredTextBoxEx : FastColoredTextBox
{ {
public Label lbTooltip; public Label lbTooltip;
Point lastMouseCoord; Point lastMouseCoord;
public FastColoredTextBoxEx() : base() public FastColoredTextBoxEx() : base()
{ {
this.SyntaxHighlighter = new MySyntaxHighlighter(); this.SyntaxHighlighter = new MySyntaxHighlighter();
...@@ -67,7 +66,10 @@ protected override void OnToolTip() ...@@ -67,7 +66,10 @@ protected override void OnToolTip()
this.ShowTooltipWithLabel(ea.ToolTipTitle, ea.ToolTipText); this.ShowTooltipWithLabel(ea.ToolTipTitle, ea.ToolTipText);
} }
} }
public void ShowTooltipWithLabel(AutocompleteItem item)
{
this.ShowTooltipWithLabel(item.ToolTipTitle, item.ToolTipText);
}
public void ShowTooltipWithLabel(string title, string text, int height) public void ShowTooltipWithLabel(string title, string text, int height)
{ {
this.lbTooltip.Visible = true; this.lbTooltip.Visible = true;
......
...@@ -14,13 +14,14 @@ namespace FastColoredTextBoxNS ...@@ -14,13 +14,14 @@ namespace FastColoredTextBoxNS
/// </summary> /// </summary>
public class MySyntaxHighlighter : SyntaxHighlighter public class MySyntaxHighlighter : SyntaxHighlighter
{ {
public string cCode = "";
readonly TextStyle mNumberStyle = new TextStyle(Brushes.Orange, null, FontStyle.Regular); readonly TextStyle mNumberStyle = new TextStyle(Brushes.Orange, null, FontStyle.Regular);
readonly TextStyle mStrStyle = new TextStyle(Brushes.Gold, null, FontStyle.Regular); readonly TextStyle mStrStyle = new TextStyle(Brushes.Gold, null, FontStyle.Regular);
readonly TextStyle conStyle = new TextStyle(Brushes.YellowGreen, null, FontStyle.Regular); readonly TextStyle conStyle = new TextStyle(Brushes.YellowGreen, null, FontStyle.Regular);
readonly TextStyle mKeywordStyle = new TextStyle(Brushes.DeepSkyBlue, null, FontStyle.Regular); readonly TextStyle mKeywordStyle = new TextStyle(Brushes.DeepSkyBlue, null, FontStyle.Regular);
readonly TextStyle mGrayStyle = new TextStyle(Brushes.Gray, null, FontStyle.Regular); readonly TextStyle mGrayStyle = new TextStyle(Brushes.Gray, null, FontStyle.Regular);
readonly TextStyle mFunStyle = new TextStyle(Brushes.LightGray, null, FontStyle.Bold); readonly TextStyle mFunStyle = new TextStyle(Brushes.LightGray, null, FontStyle.Bold);
readonly TextStyle mErrorStyle = new TextStyle(Brushes.Red, null, FontStyle.Bold);
/// <summary> /// <summary>
/// Highlights Lua code /// Highlights Lua code
...@@ -39,7 +40,7 @@ public override void LuaSyntaxHighlight(Range range) ...@@ -39,7 +40,7 @@ public override void LuaSyntaxHighlight(Range range)
= @"^\s*[\w\.]+(\s\w+)?\s*(?<range>=)\s*(?<range>.+)"; = @"^\s*[\w\.]+(\s\w+)?\s*(?<range>=)\s*(?<range>.+)";
//clear style of changed range //clear style of changed range
range.ClearStyle(this.mStrStyle, this.mGrayStyle, this.conStyle, this.mNumberStyle, this.mKeywordStyle, this.mFunStyle); range.ClearStyle(this.mStrStyle, this.mGrayStyle, this.conStyle, this.mNumberStyle, this.mKeywordStyle, this.mFunStyle, this.mErrorStyle);
// //
if (this.LuaStringRegex == null) if (this.LuaStringRegex == null)
{ {
...@@ -58,7 +59,8 @@ public override void LuaSyntaxHighlight(Range range) ...@@ -58,7 +59,8 @@ public override void LuaSyntaxHighlight(Range range)
range.SetStyle(this.mKeywordStyle, this.LuaKeywordRegex); range.SetStyle(this.mKeywordStyle, this.LuaKeywordRegex);
//functions highlighting //functions highlighting
range.SetStyle(this.mFunStyle, this.LuaFunctionsRegex); range.SetStyle(this.mFunStyle, this.LuaFunctionsRegex);
range.SetStyle(this.mNumberStyle, @"\bc\d+\b"); range.SetStyle(this.mErrorStyle, @"\bc\d+\b");
range.SetStyle(this.mNumberStyle, $@"\b{cCode}\b");
range.SetStyle(this.conStyle, @"[\s|\(|+|,]{0,1}(?<range>[A-Z_]+?)[\)|+|\s|,|;]"); range.SetStyle(this.conStyle, @"[\s|\(|+|,]{0,1}(?<range>[A-Z_]+?)[\)|+|\s|,|;]");
//range.SetStyle(mFunStyle, @"[:|\.|\s](?<range>[a-zA-Z0-9_]*?)[\(|\)|\s]"); //range.SetStyle(mFunStyle, @"[:|\.|\s](?<range>[a-zA-Z0-9_]*?)[\(|\)|\s]");
......
...@@ -67,16 +67,9 @@ public static void Error(LMSG msg) ...@@ -67,16 +67,9 @@ public static void Error(LMSG msg)
} }
public static bool Question(LMSG msg) public static bool Question(LMSG msg)
{ {
if (MessageBox.Show(LanguageHelper.GetMsg(msg), _question, return (MessageBox.Show(LanguageHelper.GetMsg(msg), _question,
MessageBoxButtons.OKCancel, MessageBoxButtons.OKCancel,
MessageBoxIcon.Question) == DialogResult.OK) MessageBoxIcon.Question) == DialogResult.OK);
{
return true;
}
else
{
return false;
}
} }
} }
} }
...@@ -535,7 +535,6 @@ private void bgWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventAr ...@@ -535,7 +535,6 @@ private void bgWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventAr
this.Init(); this.Init();
} }
private void bgWorker1_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) private void bgWorker1_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
{ {
//更新UI //更新UI
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment