diff --git a/Plugins/Discord/source/Plugin.Common/PluginHelper.cs b/Plugins/Discord/source/Plugin.Common/PluginHelper.cs index 7319b613..20c1ea03 100644 --- a/Plugins/Discord/source/Plugin.Common/PluginHelper.cs +++ b/Plugins/Discord/source/Plugin.Common/PluginHelper.cs @@ -198,6 +198,18 @@ namespace ServerManagerTool.Plugin.Common Plugins.Add(new PluginItem { Plugin = plugin, PluginFile = pluginFile, PluginType = nameof(IAlertPlugin) }); } } + else if (type.GetInterface(typeof(IPlugin).Name) != null) + { + var plugin = assembly.CreateInstance(type.FullName) as IPlugin; + if (plugin != null && plugin.Enabled) + { + if (type.GetInterface(typeof(IBeta).Name) != null) + ((IBeta)plugin).BetaEnabled = BetaEnabled; + plugin.Initialize(); + + Plugins.Add(new PluginItem { Plugin = plugin, PluginFile = pluginFile, PluginType = nameof(IPlugin) }); + } + } } catch (Exception ex) { diff --git a/Plugins/Discord/source/Plugin.Discord/Art/Drag.ico b/Plugins/Discord/source/Plugin.Discord/Art/Drag.ico new file mode 100644 index 00000000..34f7816a Binary files /dev/null and b/Plugins/Discord/source/Plugin.Discord/Art/Drag.ico differ diff --git a/Plugins/Discord/source/Plugin.Discord/Models/ObservableList.cs b/Plugins/Discord/source/Plugin.Discord/Models/ObservableList.cs index 8b8e1850..6f7e922b 100644 --- a/Plugins/Discord/source/Plugin.Discord/Models/ObservableList.cs +++ b/Plugins/Discord/source/Plugin.Discord/Models/ObservableList.cs @@ -96,6 +96,17 @@ namespace ServerManagerTool.Plugin.Discord OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item)); } + public void Move(int oldIndex, int newIndex) + { + var item = _listObject.ElementAt(oldIndex); + if (item != null) + { + _listObject.Remove(item); + _listObject.Insert(newIndex, item); + OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, item, newIndex, oldIndex)); + } + } + public bool Remove(T item) { int index = _listObject.IndexOf(item); diff --git a/Plugins/Discord/source/Plugin.Discord/Plugin.Discord.csproj b/Plugins/Discord/source/Plugin.Discord/Plugin.Discord.csproj index 24bec9e6..72a4460e 100644 --- a/Plugins/Discord/source/Plugin.Discord/Plugin.Discord.csproj +++ b/Plugins/Discord/source/Plugin.Discord/Plugin.Discord.csproj @@ -26,6 +26,7 @@ + @@ -53,6 +54,7 @@ + diff --git a/Plugins/Discord/source/Plugin.Discord/Properties/AssemblyInfo.cs b/Plugins/Discord/source/Plugin.Discord/Properties/AssemblyInfo.cs index 6cfb03ee..d7975adb 100644 --- a/Plugins/Discord/source/Plugin.Discord/Properties/AssemblyInfo.cs +++ b/Plugins/Discord/source/Plugin.Discord/Properties/AssemblyInfo.cs @@ -30,5 +30,5 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.17.1")] -[assembly: AssemblyFileVersion("1.0.17.1")] +[assembly: AssemblyVersion("1.0.17.2")] +[assembly: AssemblyFileVersion("1.0.17.2")] diff --git a/Plugins/Discord/source/Plugin.Discord/Utils/WindowUtils.cs b/Plugins/Discord/source/Plugin.Discord/Utils/WindowUtils.cs new file mode 100644 index 00000000..6c765945 --- /dev/null +++ b/Plugins/Discord/source/Plugin.Discord/Utils/WindowUtils.cs @@ -0,0 +1,122 @@ +using System.Linq; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Media; + +namespace ServerManagerTool.Plugin.Discord +{ + public static class WindowUtils + { + public static void RemoveDefaultResourceDictionary(Window window, string defaultDictionary) + { + if (window == null) + return; + + var dictToRemove = window.Resources.MergedDictionaries.FirstOrDefault(d => d.Source.OriginalString.Contains(defaultDictionary)); + if (dictToRemove != null) + { + window.Resources.MergedDictionaries.Remove(dictToRemove); + } + } + + public static void RemoveDefaultResourceDictionary(UserControl control, string defaultDictionary) + { + if (control == null) + return; + + var dictToRemove = control.Resources.MergedDictionaries.FirstOrDefault(d => d.Source.OriginalString.Contains(defaultDictionary)); + if (dictToRemove != null) + { + control.Resources.MergedDictionaries.Remove(dictToRemove); + } + } + + /// + /// Finds a parent of a given item on the visual tree. + /// + /// The type of the queried item. + /// A direct or indirect child of the queried item. + /// The first parent item that matches the submitted type parameter. If not matching item can be found, a null reference is being returned. + public static T TryFindParent(DependencyObject child) + where T : DependencyObject + { + //get parent item + DependencyObject parentObject = GetParentObject(child); + + //we've reached the end of the tree + if (parentObject == null) return null; + + //check if the parent matches the type we're looking for + T parent = parentObject as T; + if (parent != null) + return parent; + + //use recursion to proceed with next level + return TryFindParent(parentObject); + } + + /// + /// This method is an alternative to WPF's method, which also supports content elements. + /// Do note, that for content element, this method falls back to the logical tree of the element. + /// + /// The item to be processed. + /// The submitted item's parent, if available. Otherwise null. + public static DependencyObject GetParentObject(DependencyObject child) + { + if (child == null) return null; + var contentElement = child as ContentElement; + + if (contentElement != null) + { + var parent = ContentOperations.GetParent(contentElement); + if (parent != null) return parent; + + var fce = contentElement as FrameworkContentElement; + return fce?.Parent; + } + + //if it's not a ContentElement, rely on VisualTreeHelper + return VisualTreeHelper.GetParent(child); + } + + /// + /// Recursively processes a given dependency object and all its children, and updates sources of all objects that use a binding expression on a given property. + /// + /// The dependency object that marks a starting point. This could be a dialog window or a panel control that hosts bound controls. + /// The properties to be updated if + /// or one of its childs provide it along with a binding expression. + public static void UpdateBindingSources(DependencyObject obj, params DependencyProperty[] properties) + { + foreach (var depProperty in properties) + { + //check whether the submitted object provides a bound property that matches the property parameters + var be = BindingOperations.GetBindingExpression(obj, depProperty); + be?.UpdateSource(); + } + + int count = VisualTreeHelper.GetChildrenCount(obj); + for (int i = 0; i < count; i++) + { + //process child items recursively + var childObject = VisualTreeHelper.GetChild(obj, i); + UpdateBindingSources(childObject, properties); + } + } + + /// + /// Tries to locate a given item within the visual tree, starting with the dependency object at a given position. + /// + /// The type of the element to be found on the visual tree of the element at the given location. + /// The main element which is used to perform hit testing. + /// The position to be evaluated on the origin. + public static T TryFindFromPoint(UIElement reference, Point point) + where T : DependencyObject + { + var element = reference.InputHitTest(point) as DependencyObject; + if (element == null) return null; + if (element is T) return (T)element; + return TryFindParent(element); + } + } +} diff --git a/Plugins/Discord/source/Plugin.Discord/VersionFeed.xml b/Plugins/Discord/source/Plugin.Discord/VersionFeed.xml index 9b8651ab..82e77d98 100644 --- a/Plugins/Discord/source/Plugin.Discord/VersionFeed.xml +++ b/Plugins/Discord/source/Plugin.Discord/VersionFeed.xml @@ -9,8 +9,8 @@ urn:uuid:D8974ABF-8444-4D40-A594-D4443921B3B8 - 1.0.17 (1.0.17.1) - 1.0.17.1 + 1.0.17 (1.0.17.2) + 1.0.17.2 2020-07-13T00:00:00Z @@ -20,6 +20,7 @@
  • Profile name has been converted to a droplist and is now populated with the Server Manager Profile Names for selection.
  • +
  • Added drag/drop feature to the config window.

diff --git a/Plugins/Discord/source/Plugin.Discord/VersionFeedBeta.xml b/Plugins/Discord/source/Plugin.Discord/VersionFeedBeta.xml index eae3c759..de95f6f5 100644 --- a/Plugins/Discord/source/Plugin.Discord/VersionFeedBeta.xml +++ b/Plugins/Discord/source/Plugin.Discord/VersionFeedBeta.xml @@ -5,14 +5,37 @@ Discord Plugin Version Feed This is the Discord Plugin beta version feed. - 2020-07-13T00:00:00Z + 2020-07-12T02:00:00Z + + + urn:uuid:4750D17C-2C8F-4D8C-AA17-B3512F002170 + 1.0.17 (1.0.17.2) + 1.0.17.2 + + 2020-07-12T02:00:00Z + +
+

+ CHANGE +
+

    +
  • Added drag/drop feature to the config window.
  • +
+

+
+
+ + bletch + bletch1971@hotmail.com + +
urn:uuid:D8974ABF-8444-4D40-A594-D4443921B3B8 1.0.17 (1.0.17.1) 1.0.17.1 - 2020-07-13T00:00:00Z + 2020-07-12T00:00:00Z

diff --git a/Plugins/Discord/source/Plugin.Discord/Windows/ConfigProfileWindow.xaml b/Plugins/Discord/source/Plugin.Discord/Windows/ConfigProfileWindow.xaml index 7b2b4b4d..d1ce9835 100644 --- a/Plugins/Discord/source/Plugin.Discord/Windows/ConfigProfileWindow.xaml +++ b/Plugins/Discord/source/Plugin.Discord/Windows/ConfigProfileWindow.xaml @@ -132,7 +132,7 @@ - + - - + + @@ -64,7 +64,7 @@ - + - +