Skip to content

Commit 99788d1

Browse files
committed
Revert "Merge pull request #974 from wise0704/MainForm"
This reverts commit 38a21fb, reversing changes made to 97ff70c.
1 parent ee70c71 commit 99788d1

File tree

7 files changed

+153
-231
lines changed

7 files changed

+153
-231
lines changed

External/Plugins/AS3Context/PluginMain.cs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -265,23 +265,25 @@ public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
265265
else if (inMXML)
266266
{
267267
DataEvent de = e as DataEvent;
268-
switch (de.Action)
268+
if (de.Action == "XMLCompletion.Element")
269269
{
270-
case "XMLCompletion.Element":
271-
de.Handled = MxmlComplete.HandleElement(de.Data);
272-
break;
273-
case "XMLCompletion.Namespace":
274-
de.Handled = MxmlComplete.HandleNamespace(de.Data);
275-
break;
276-
case "XMLCompletion.CloseElement":
277-
de.Handled = MxmlComplete.HandleElementClose(de.Data);
278-
break;
279-
case "XMLCompletion.Attribute":
280-
de.Handled = MxmlComplete.HandleAttribute(de.Data);
281-
break;
282-
case "XMLCompletion.AttributeValue":
283-
de.Handled = MxmlComplete.HandleAttributeValue(de.Data);
284-
break;
270+
de.Handled = MxmlComplete.HandleElement(de.Data);
271+
}
272+
if (de.Action == "XMLCompletion.Namespace")
273+
{
274+
de.Handled = MxmlComplete.HandleNamespace(de.Data);
275+
}
276+
else if (de.Action == "XMLCompletion.CloseElement")
277+
{
278+
de.Handled = MxmlComplete.HandleElementClose(de.Data);
279+
}
280+
else if (de.Action == "XMLCompletion.Attribute")
281+
{
282+
de.Handled = MxmlComplete.HandleAttribute(de.Data);
283+
}
284+
else if (de.Action == "XMLCompletion.AttributeValue")
285+
{
286+
de.Handled = MxmlComplete.HandleAttributeValue(de.Data);
285287
}
286288
}
287289
}

External/Plugins/ProjectManager/Helpers/LineEntryDialog.cs

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Drawing;
33
using System.Collections;
4-
using System.Collections.Generic;
54
using System.ComponentModel;
65
using System.Windows.Forms;
76
using PluginCore;
@@ -14,12 +13,13 @@ namespace ProjectManager.Helpers
1413
/// </summary>
1514
public class LineEntryDialog : Form
1615
{
16+
readonly Keys shortcutToLowercase;
17+
readonly Keys shortcutToUppercase;
1718
string line;
18-
readonly Dictionary<Keys, string> shortcuts;
1919

2020
#region Form Designer Components
2121

22-
private System.Windows.Forms.TextBox lineBox;
22+
protected System.Windows.Forms.TextBox lineBox;
2323
private System.Windows.Forms.Button btnOK;
2424
private System.Windows.Forms.Button btnCancel;
2525
/// <summary>
@@ -40,15 +40,17 @@ public string Line
4040

4141
public LineEntryDialog(string captionText, string labelText, string defaultLine)
4242
{
43+
shortcutToLowercase = PluginBase.MainForm.GetShortcutItemKeys("EditMenu.ToLowercase");
44+
shortcutToUppercase = PluginBase.MainForm.GetShortcutItemKeys("EditMenu.ToUppercase");
4345
InitializeComponent();
4446
InititalizeLocalization();
4547
this.Font = PluginBase.Settings.DefaultFont;
4648
this.Text = " " + captionText;
4749
titleLabel.Text = labelText;
48-
lineBox.Text = defaultLine ?? string.Empty;
50+
lineBox.KeyDown += OnLineBoxOnKeyDown;
51+
lineBox.Text = (defaultLine != null) ? defaultLine : string.Empty;
4952
lineBox.SelectAll();
5053
lineBox.Focus();
51-
shortcuts = PluginBase.MainForm.GetShortcutItemsByKeys();
5254
}
5355

5456
#region Dispose
@@ -98,7 +100,6 @@ private void InitializeComponent()
98100
this.lineBox.Name = "lineBox";
99101
this.lineBox.Size = new System.Drawing.Size(260, 20);
100102
this.lineBox.TabIndex = 0;
101-
this.lineBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.LineBox_KeyDown);
102103
//
103104
// btnOK
104105
//
@@ -171,22 +172,18 @@ private void btnCancel_Click(object sender, System.EventArgs e)
171172
this.Close();
172173
}
173174

174-
void LineBox_KeyDown(object sender, KeyEventArgs e)
175+
void OnLineBoxOnKeyDown(object sender, KeyEventArgs args)
175176
{
176-
string shortcutId;
177-
if (!shortcuts.TryGetValue(e.KeyData, out shortcutId)) return;
178-
switch (shortcutId)
179-
{
180-
case "EditMenu.ToLowercase":
181-
case "EditMenu.ToUppercase":
182-
string text = lineBox.SelectedText;
183-
if (string.IsNullOrEmpty(text)) break;
184-
text = shortcutId == "EditMenu.ToLowercase" ? text.ToLower() : text.ToUpper();
185-
int selectionStart = lineBox.SelectionStart;
186-
lineBox.Paste(text);
187-
SelectRange(selectionStart, text.Length);
188-
break;
189-
}
177+
string selectedText = lineBox.SelectedText;
178+
if (string.IsNullOrEmpty(selectedText)) return;
179+
Keys keys = args.KeyData;
180+
if (keys == shortcutToLowercase) selectedText = selectedText.ToLower();
181+
else if (keys == shortcutToUppercase) selectedText = selectedText.ToUpper();
182+
else return;
183+
int selectionStart = lineBox.SelectionStart;
184+
int selectionLength = lineBox.SelectionLength;
185+
lineBox.Paste(selectedText);
186+
SelectRange(selectionStart, selectionLength);
190187
}
191188

192189
public void SelectRange(int start, int length)

External/Plugins/ProjectManager/PluginMain.cs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -561,38 +561,38 @@ private bool HandleKeyEvent(KeyEvent ke)
561561
{
562562
if (activeProject == null) return false;
563563

564-
switch (PluginBase.MainForm.GetShortcutItemId(ke.Value))
564+
if (ke.Value == PluginBase.MainForm.GetShortcutItemKeys("ProjectMenu.ConfigurationSelector"))
565565
{
566-
case "ProjectMenu.ConfigurationSelector":
567-
pluginUI.menus.ConfigurationSelector.Focus();
568-
break;
569-
case "ProjectMenu.ConfigurationSelectorToggle":
570-
pluginUI.menus.ToggleDebugRelease();
571-
break;
572-
case "ProjectMenu.TargetBuildSelector":
573-
pluginUI.menus.TargetBuildSelector.Focus();
574-
break;
575-
case "ProjectTree.LocateActiveFile":
576-
ToggleTrackActiveDocument();
577-
break;
578-
default:
579-
if (Tree.Focused && !pluginUI.IsEditingLabel)
580-
{
581-
if (ke.Value == (Keys.Control | Keys.C) && pluginUI.Menu.Contains(pluginUI.Menu.Copy)) TreeCopyItems();
582-
else if (ke.Value == (Keys.Control | Keys.X) && pluginUI.Menu.Contains(pluginUI.Menu.Cut)) TreeCutItems();
583-
else if (ke.Value == (Keys.Control | Keys.V) && pluginUI.Menu.Contains(pluginUI.Menu.Paste)) TreePasteItems();
584-
else if (ke.Value == Keys.Delete && pluginUI.Menu.Contains(pluginUI.Menu.Delete)) TreeDeleteItems();
585-
else if (ke.Value == Keys.Enter && pluginUI.Menu.Contains(pluginUI.Menu.Open)) TreeOpenItems();
586-
else if (ke.Value == Keys.Enter && pluginUI.Menu.Contains(pluginUI.Menu.Insert)) TreeInsertItem();
587-
else return false;
588-
}
589-
else return false;
590-
break;
566+
pluginUI.menus.ConfigurationSelector.Focus();
567+
}
568+
else if (ke.Value == PluginBase.MainForm.GetShortcutItemKeys("ProjectMenu.ConfigurationSelectorToggle"))
569+
{
570+
pluginUI.menus.ToggleDebugRelease();
571+
}
572+
else if (ke.Value == PluginBase.MainForm.GetShortcutItemKeys("ProjectMenu.TargetBuildSelector"))
573+
{
574+
pluginUI.menus.TargetBuildSelector.Focus();
575+
}
576+
else if (ke.Value == PluginBase.MainForm.GetShortcutItemKeys("ProjectTree.LocateActiveFile"))
577+
{
578+
ToggleTrackActiveDocument();
591579
}
592580

581+
// Handle tree-level simple shortcuts like copy/paste/del
582+
else if (Tree.Focused && !pluginUI.IsEditingLabel && ke != null)
583+
{
584+
if (ke.Value == (Keys.Control | Keys.C) && pluginUI.Menu.Contains(pluginUI.Menu.Copy)) TreeCopyItems();
585+
else if (ke.Value == (Keys.Control | Keys.X) && pluginUI.Menu.Contains(pluginUI.Menu.Cut)) TreeCutItems();
586+
else if (ke.Value == (Keys.Control | Keys.V) && pluginUI.Menu.Contains(pluginUI.Menu.Paste)) TreePasteItems();
587+
else if (ke.Value == Keys.Delete && pluginUI.Menu.Contains(pluginUI.Menu.Delete)) TreeDeleteItems();
588+
else if (ke.Value == Keys.Enter && pluginUI.Menu.Contains(pluginUI.Menu.Open)) TreeOpenItems();
589+
else if (ke.Value == Keys.Enter && pluginUI.Menu.Contains(pluginUI.Menu.Insert)) TreeInsertItem();
590+
else return false;
591+
}
592+
else return false;
593593
return true;
594594
}
595-
595+
596596
#endregion
597597

598598
#region Custom Methods

FlashDevelop/Dialogs/ShortcutDialog.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ private void PopulateListView(String filter, Boolean viewCustom)
284284
this.listView.BeginUpdate();
285285
this.listView.Items.Clear();
286286
this.listView.ListViewItemSorter = new ListViewComparer();
287-
foreach (ShortcutItem item in ShortcutManager.RegisteredItems.Values)
287+
foreach (ShortcutItem item in ShortcutManager.RegisteredItems)
288288
{
289289
if (!this.listView.Items.ContainsKey(item.Id) &&
290290
(item.Id.ToLower().Contains(filter.ToLower()) ||

FlashDevelop/MainForm.cs

Lines changed: 6 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,7 +1710,8 @@ public Color GetThemeColor(String id)
17101710
public Color GetThemeColor(String id, Color fallback)
17111711
{
17121712
Color color = ThemeManager.GetThemeColor(id);
1713-
return color.IsEmpty ? fallback : color;
1713+
if (color != Color.Empty) return color;
1714+
else return fallback;
17141715
}
17151716

17161717
/// <summary>
@@ -1727,54 +1728,8 @@ public String GetThemeValue(String id)
17271728
public String GetThemeValue(String id, String fallback)
17281729
{
17291730
String value = ThemeManager.GetThemeValue(id);
1730-
return String.IsNullOrEmpty(value) ? fallback : value;
1731-
}
1732-
1733-
/// <summary>
1734-
/// Gets a theme flag value.
1735-
/// </summary>
1736-
public Boolean GetThemeFlag(String id)
1737-
{
1738-
return GetThemeFlag(id, false);
1739-
}
1740-
1741-
/// <summary>
1742-
/// Gets a theme flag value with a fallback.
1743-
/// </summary>
1744-
public Boolean GetThemeFlag(String id, Boolean fallback)
1745-
{
1746-
String value = ThemeManager.GetThemeValue(id);
1747-
if (String.IsNullOrEmpty(value)) return fallback;
1748-
switch (value.ToLower())
1749-
{
1750-
case "true": return true;
1751-
case "false": return false;
1752-
default: return fallback;
1753-
}
1754-
}
1755-
1756-
/// <summary>
1757-
/// Gets a theme enumeration value.
1758-
/// </summary>
1759-
public T GetThemeValue<T>(String id) where T : struct
1760-
{
1761-
return GetThemeValue(id, default(T));
1762-
}
1763-
1764-
/// <summary>
1765-
/// Gets a theme enumeration value with a fallback.
1766-
/// </summary>
1767-
public T GetThemeValue<T>(String id, T fallback) where T : struct
1768-
{
1769-
String value = ThemeManager.GetThemeValue(id);
1770-
try
1771-
{
1772-
return (T) Enum.Parse(typeof(T), value);
1773-
}
1774-
catch
1775-
{
1776-
return fallback;
1777-
}
1731+
if (!String.IsNullOrEmpty(value)) return value;
1732+
else return fallback;
17781733
}
17791734

17801735
/// <summary>
@@ -1808,32 +1763,8 @@ public void AutoUpdateMenuItem(ToolStripItem item, String action)
18081763
public Keys GetShortcutItemKeys(String id)
18091764
{
18101765
ShortcutItem item = ShortcutManager.GetRegisteredItem(id);
1811-
return item != null ? item.Custom : Keys.None;
1812-
}
1813-
1814-
/// <summary>
1815-
/// Gets the shortcut id associated the keys.
1816-
/// </summary>
1817-
public string GetShortcutItemId(Keys keys)
1818-
{
1819-
ShortcutItem item = ShortcutManager.GetRegisteredItem(keys);
1820-
return item != null ? item.Id : null;
1821-
}
1822-
1823-
/// <summary>
1824-
/// Returns a <see cref="Dictionary{TKey, TValue}"/> object containing all registered
1825-
/// shortcuts with the shortcut values as keys.
1826-
/// </summary>
1827-
public Dictionary<Keys, String> GetShortcutItemsByKeys()
1828-
{
1829-
Dictionary<String, ShortcutItem>.ValueCollection list = ShortcutManager.RegisteredItems.Values;
1830-
Dictionary<Keys, String> items = new Dictionary<Keys, String>(list.Count);
1831-
foreach (ShortcutItem item in list)
1832-
{
1833-
if (item.Custom == Keys.None) continue;
1834-
items[item.Custom] = item.Id;
1835-
}
1836-
return items;
1766+
if (item != null) return item.Custom;
1767+
else return Keys.None;
18371768
}
18381769

18391770
/// <summary>

0 commit comments

Comments
 (0)