-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delay updating description incase it changes quickly, this means it bubbles up the tree slower, but also wastes less cpu time. Only create context menus when they are needed. This makes it a ton faster.
- Loading branch information
Showing
12 changed files
with
125 additions
and
52 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
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
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
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
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
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
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,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace StructuredXmlEditor | ||
{ | ||
public static class Future | ||
{ | ||
private static object m_locker = new object(); | ||
private static Dictionary<object, Tuple<Action, Timer>> m_futures = new Dictionary<object, Tuple<Action, Timer>>(); | ||
|
||
public static void Call(Action func, int ms, object key = null) | ||
{ | ||
if (key == null) key = new object(); | ||
|
||
lock (m_locker) | ||
{ | ||
if (m_futures.ContainsKey(key)) | ||
{ | ||
m_futures[key].Item2.Change(ms, Timeout.Infinite); | ||
} | ||
else | ||
{ | ||
var timer = new Timer(TimerElapsed, key, ms, Timeout.Infinite); | ||
m_futures[key] = new Tuple<Action, Timer>(func, timer); | ||
} | ||
} | ||
} | ||
|
||
private static void TimerElapsed(object key) | ||
{ | ||
lock (m_locker) | ||
{ | ||
var data = m_futures[key]; | ||
m_futures.Remove(key); | ||
|
||
Application.Current.Dispatcher.BeginInvoke(data.Item1); | ||
data.Item2.Dispose(); | ||
} | ||
} | ||
} | ||
} |
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
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
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
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
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,34 @@ | ||
using StructuredXmlEditor.Data; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace StructuredXmlEditor.View | ||
{ | ||
partial class DataGridViewStyle : ResourceDictionary | ||
{ | ||
public DataGridViewStyle() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void Grid_ContextMenuOpening(object sender, System.Windows.Controls.ContextMenuEventArgs e) | ||
{ | ||
FrameworkElement fe = e.Source as FrameworkElement; | ||
|
||
if (fe.ContextMenu == null) | ||
{ | ||
e.Handled = true; | ||
fe.ContextMenu = ((DataItem)fe.DataContext).CreateContextMenu(); | ||
fe.ContextMenu.IsOpen = true; | ||
} | ||
else | ||
{ | ||
fe.ContextMenu = ((DataItem)fe.DataContext).CreateContextMenu(); | ||
} | ||
} | ||
} | ||
} |