diff --git a/Core/Abstracts/AbstractContent.cs b/Core/Abstracts/AbstractContent.cs index 836808b..a5342bf 100644 --- a/Core/Abstracts/AbstractContent.cs +++ b/Core/Abstracts/AbstractContent.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Runtime.Remoting.Contexts; using System.Windows.Controls; + using Core.Utilities; @@ -20,10 +21,14 @@ public abstract class AbstractContent : IAbstractService, IAbstractContent /* ------------------------------------------------------------------*/ // public classes - public class Settings : IAbstractSettings + /// + /// Class defining the settings required for restoring content. + /// + public class Settings : IAbstractSettingData { - public string ContentID { get; set; } - public string ContentType { get; set; } + public string ID { get; set; } + public string Type { get; set; } + /// TODO Add additional settings that should be saved here... } @@ -31,10 +36,8 @@ public class Settings : IAbstractSettings // public properties public abstract string Name { get; } - public abstract bool MultipleIntances { get; } + public abstract bool MultipleInstances { get; } public abstract List DependingServices { get; } - - public bool IsAttached { get { return _attached; } } public string ID { get { return _id; } set { _id = value; } } @@ -42,17 +45,20 @@ public class Settings : IAbstractSettings /* ------------------------------------------------------------------*/ // public functions + /// + /// Ctor. + /// public AbstractContent() { _id = UniqueID.Generate(); _timer = new TimeBenchmark(); } - /// - /// If derived class might requires additional data on initialization (declaring Initialize taking parameter(s)), - /// throw error when method of base class is called instead. + /// If derived class might requires additional data on initialization (declaring Initialize taking parameter(s)) ... /// + /// True on success, false otherwise. + /// ...throw error when method of base class is called instead. public virtual bool Initialize() { throw new InvalidOperationException("Call Initialize method of derived class"); @@ -83,7 +89,10 @@ public override bool Initialize() } */ - + /// + /// Called to actually create the WPF content. + /// + /// True on success, false otherwise. public abstract bool Create(); /* { @@ -107,10 +116,10 @@ public override bool Initialize() } */ - /// - /// Attach content to provided content_element. + /// Called when content element is being attached to a parent element. /// + /// The WPF control element holding the content. public abstract Control Attach(); /* TEMPLATE { @@ -132,7 +141,10 @@ public override bool Initialize() } */ - + /// + /// Called when content has been detached. + /// + /// True on success, false otherwise. public virtual bool Detach() { if (!_attached) @@ -144,7 +156,10 @@ public virtual bool Detach() return true; } - + /// + /// Called when content should be terminated. Should implement counterpart to Initialize(). + /// + /// True on success, false otherwise. public abstract bool Terminate(); /* TEMPLATE { @@ -162,7 +177,7 @@ public virtual bool Detach() /* ------------------------------------------------------------------*/ // protected variables - protected bool _initilized = false; + protected bool _initialized = false; protected bool _created = false; protected bool _attached = false; diff --git a/Core/Abstracts/IAbstractContent.cs b/Core/Abstracts/IAbstractContent.cs index cc90f21..8a9a293 100644 --- a/Core/Abstracts/IAbstractContent.cs +++ b/Core/Abstracts/IAbstractContent.cs @@ -20,24 +20,51 @@ public interface IAbstractContent /* ------------------------------------------------------------------*/ // interface properties + /// + /// The name of the content. + /// string Name { get; } - bool MultipleIntances { get; } + /// + /// True if multiple instances of the content would be created, false otherwise. + /// + bool MultipleInstances { get; } + /// + /// Services the content depends on. + /// List DependingServices { get; } + /// + /// Returns whether WPF content is attached or not. + /// bool IsAttached { get; } + /// + /// The id string of the content. + /// string ID { get; } /* ------------------------------------------------------------------*/ // interface functions + /// + /// Create the content. To be called only once. + /// + /// True on success, false otherwise. bool Create(); + /// + /// Called when content element should be attached. + /// + /// The content to be attached by the caller. Control Attach(); + /// + /// Called when the content element has been detached. Should implement counterpart to Attach(). + /// + /// True on success, false otherwise. bool Detach(); } } diff --git a/Core/Abstracts/IAbstractService.cs b/Core/Abstracts/IAbstractService.cs index 15f2a87..79b1442 100644 --- a/Core/Abstracts/IAbstractService.cs +++ b/Core/Abstracts/IAbstractService.cs @@ -19,8 +19,16 @@ public interface IAbstractService /* ------------------------------------------------------------------*/ // interface functions + /// + /// Initialize the service. + /// + /// True on success, false otherwise. bool Initialize(); + /// + /// Terminate the service. Should implement counterpart to Initialize(). + /// + /// True on success, false otherwise. bool Terminate(); } } diff --git a/Core/Abstracts/IAbstractSetting.cs b/Core/Abstracts/IAbstractSetting.cs new file mode 100644 index 0000000..4067cc1 --- /dev/null +++ b/Core/Abstracts/IAbstractSetting.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Core.GUI; + + + +/* + * Abstract Settings Interfaces for data and classes providing settings + * + */ +namespace Core +{ + namespace Abstracts + { + public interface IAbstractSettingData + { + /// Empty so far + } + + + public interface IAbstractSettings + { + /// + /// Called for collecting all settings. + /// + /// The serialized settings as JSON string. + string CollectSettings(); + + /// + /// Called for applying all settings. + /// + /// The settings as JSON string. + /// True on success, false otherwise. + bool ApplySettings(string settings); + } + } +} diff --git a/Core/Abstracts/IAbstractSettings.cs b/Core/Abstracts/IAbstractSettings.cs deleted file mode 100644 index 7405656..0000000 --- a/Core/Abstracts/IAbstractSettings.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - - - -/* - * Abstract Settings Interface - * - */ -namespace Core -{ - namespace Abstracts - { - public interface IAbstractSettings - { - - - - } - } -} diff --git a/Core/Core.csproj b/Core/Core.csproj index 908c5a7..a7ff95f 100644 --- a/Core/Core.csproj +++ b/Core/Core.csproj @@ -85,7 +85,7 @@ - + diff --git a/Core/GUI/Content/LogContent.cs b/Core/GUI/Content/LogContent.cs index 599f7e3..c61a606 100644 --- a/Core/GUI/Content/LogContent.cs +++ b/Core/GUI/Content/LogContent.cs @@ -25,8 +25,8 @@ public class LogContent : AbstractContent /* ------------------------------------------------------------------*/ // properties - public override string Name { get { return "Log"; } } - public override bool MultipleIntances { get { return false; } } + public override string Name { get { return "Log Console"; } } + public override bool MultipleInstances { get { return false; } } public override List DependingServices { get { return new List() { }; } } @@ -35,7 +35,7 @@ public class LogContent : AbstractContent public override bool Initialize() { - if (_initilized) + if (_initialized) { Terminate(); } @@ -47,18 +47,17 @@ public override bool Initialize() Log.Default.RegisterListener(this.LogListener); _timer.Stop(); - _initilized = true; - if (_initilized) + _initialized = true; + if (_initialized) { Log.Default.Msg(Log.Level.Info, "Successfully initialized: " + this.GetType().Name); } - return _initilized; + return _initialized; } - public override bool Create() { - if (!_initilized) + if (!_initialized) { Log.Default.Msg(Log.Level.Error, "Initialization required prior to execution"); return false; @@ -86,10 +85,9 @@ public override bool Create() return _created; } - public override Control Attach() { - if (!_initilized) + if (!_initialized) { Log.Default.Msg(Log.Level.Error, "Initialization required prior to execution"); return null; @@ -106,21 +104,23 @@ public override Control Attach() return _content; } - public override bool Terminate() { - if (_initilized) + if (_initialized) { _content = null; _textblock = null; Log.Default.UnRegisterListener(this.LogListener); - _initilized = false; + _initialized = false; } return true; } - + /// + /// Log listener callback which should be called whenever new messages are available. + /// + /// provide only the new log messages public void LogListener(List msglist) { // Is called before Initialize() therefore _textblock needs to be not null diff --git a/Core/GUI/MenuBar.cs b/Core/GUI/MenuBar.cs index 682a053..097403b 100644 --- a/Core/GUI/MenuBar.cs +++ b/Core/GUI/MenuBar.cs @@ -27,7 +27,7 @@ public class MenuBar : AbstractService // public delegates /// - /// Function provided by the interface (= Grasshopper) which allows to trigger relaoding of the interface + /// Callback provided by the main WPF application on closing. /// public delegate void WindowClose_Delegate(); @@ -59,7 +59,6 @@ public bool Initialize(WindowClose_Delegate close_callback, SettingsService.Save return _initilized; } - public Control Attach() { if (!_initilized) @@ -124,7 +123,6 @@ public Control Attach() return _content; } - public override bool Terminate() { if (_initilized) @@ -143,6 +141,11 @@ public override bool Terminate() /* ------------------------------------------------------------------*/ // private functions + /// + /// Called when menu item is clicked. Same for all menu items. + /// + /// The sender object. + /// The routed event arguments. private void menuitem_click(object sender, RoutedEventArgs e) { var sender_content = sender as MenuItem; @@ -175,11 +178,15 @@ private void menuitem_click(object sender, RoutedEventArgs e) } } - + /// + /// Called to open URL in new browser tab. + /// + /// The sender object. + /// The request navigate event arguments. private void hyperlink_requestnavigate(object sender, RequestNavigateEventArgs e) { - Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); System.Diagnostics.Process.Start(e.Uri.ToString()); + /// or Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); e.Handled = true; } diff --git a/Core/GUI/SettingsService.cs b/Core/GUI/SettingsService.cs index 6b598d3..c5aff2c 100644 --- a/Core/GUI/SettingsService.cs +++ b/Core/GUI/SettingsService.cs @@ -38,13 +38,24 @@ public class SettingsService : AbstractService /* ------------------------------------------------------------------*/ // static functions + /// + /// [STATIC] Provides static serialization of settings to JSON string. + /// + /// The settings type. + /// The actual settings object. + /// The serialized settings. public static string Serialize(T window_data) { string settings = JsonConvert.SerializeObject(window_data); //, Formatting.Indented); return settings; } - + /// + /// [STATIC] Provides static deserialization contained in JSON string. + /// + /// The settings type. + /// The JSON string. + /// The settings object. public static T Deserialize(string content) { T settings = JsonConvert.DeserializeObject(content); @@ -75,8 +86,6 @@ public override bool Initialize() return _initilized; } - - public override bool Terminate() { if (_initilized) @@ -92,10 +101,12 @@ public override bool Terminate() return true; } - /// - /// Unique name of requesting caller is required in order to create separate JSON entries + /// Register object that provides settings. Unique name of requesting caller is required in order to create separate JSON entries. /// + /// Unique name of the caller. + /// Callback for collecting all settings. + /// callback for applying all settings. public void RegisterSettings(string name, RegisterCollect_Delegate collect_callback, RegisterApply_Delegate apply_callback) { if (!_initilized) @@ -113,13 +124,16 @@ public void RegisterSettings(string name, RegisterCollect_Delegate collect_callb _apply_callbacks.Add(name, apply_callback); } - + /// + /// Request saving all settings to a JSON file. + /// + /// True on success, false otherwise. public bool Save() { var _serialize_strucutre = new Dictionary(); foreach (var collect_callback in _collect_callbacks) { - // Call Collect Settings + // Call callback for collecting all settings _serialize_strucutre.Add(collect_callback.Key, collect_callback.Value()); } string settings = Serialize>(_serialize_strucutre); @@ -127,7 +141,10 @@ public bool Save() return true; } - + /// + /// Request loading of settings from a JSON file. + /// + /// True on success, false otherwise. public bool Load() { string settings = openfile_dialog(); @@ -137,6 +154,7 @@ public bool Load() { if (_apply_callbacks.ContainsKey(apply_callback.Key)) { + // Call callback for applying settings _apply_callbacks[apply_callback.Key](apply_callback.Value); } } @@ -147,6 +165,10 @@ public bool Load() /* ------------------------------------------------------------------*/ // private functions + /// + /// File dialog for saving provided string to a JSON file. + /// + /// The content of the file as string. private void savefile_dialog(string output_content) { Stream ouput_stream; @@ -173,7 +195,10 @@ private void savefile_dialog(string output_content) } } - + /// + /// File dialog for loading content from a JSON file. + /// + /// The content of the file as string. private string openfile_dialog() { var input_content = string.Empty; @@ -199,7 +224,6 @@ private string openfile_dialog() } } } - return input_content; } diff --git a/Core/GUI/Windows/WindowBranch.cs b/Core/GUI/Windows/WindowBranch.cs index ea0b41d..ced6d95 100644 --- a/Core/GUI/Windows/WindowBranch.cs +++ b/Core/GUI/Windows/WindowBranch.cs @@ -9,19 +9,15 @@ /* * Window Branch * - * - * NOTE: - * The canvas actually contains the content and is passed on to sub grids - * - * main_grid - * | - * ChildBranch: grid (= Root) - * | | - * ChildBranch: grid ChildBranch: grid - * | | | - * ChildLeaf: canvas ChildBranch: grid ChildBranch: grid - * | | - * ChildLeaf: canvas ChildLeaf: canvas + * main_grid + * | + * Branch: grid (= Root) + * | | + * Branch: grid Branch: grid + * | | | + * Leaf: grid Branch: grid Branch: grid + * | | + * Leaf: grid Leaf: grid */ namespace Core { @@ -33,7 +29,10 @@ public class WindowBranch : AbstractWindow /* ------------------------------------------------------------------*/ // public classes - public class Settings : IAbstractSettings + /// + /// Settings data. + /// + public class Settings : IAbstractSettingData { public WindowBranch.SplitOrientation Orientation { get; set; } public WindowBranch.ChildLocation Location { get; set; } @@ -47,13 +46,9 @@ public class Settings : IAbstractSettings // public properties public Tuple Children { get { return _children; } } - public WindowLeaf Leaf { get { return _child_leaf; } } - public SplitOrientation Orientation { get { return _orientation; } } - public ChildLocation Location { get { return _location; } } - public double Position { get { return calculate_position(); } } @@ -61,8 +56,10 @@ public class Settings : IAbstractSettings // public functions /// - /// Content callbacks are piped to each leaf where they are used + /// Ctor. /// + /// Content callbacks are piped to each window leaf. + /// Content element of root window. public Grid CreateRoot(ContentCallbacks_Type content_callbacks) { if (content_callbacks == null) @@ -85,14 +82,22 @@ public Grid CreateRoot(ContentCallbacks_Type content_callbacks) return _content; } - + /// + /// Split branch and attach two new branches. + /// + /// The orientation the window should be split. + /// The location the existing window should be moved to. + /// The relative position of the splitter. + /// The first child branch if present. + /// The second child branch if present. + /// public bool Split(SplitOrientation orientation, ChildLocation location, double position = 0.5, WindowBranch child_branch_1 = null, WindowBranch child_branch_2 = null) { bool create_new_childs = ((child_branch_1 == null) && (child_branch_2 == null)); bool use_existing_childs = ((child_branch_1 != null) && (child_branch_2 != null)); if (!create_new_childs && !use_existing_childs) { - Log.Default.Msg(Log.Level.Error, "No valid child paramter set"); + Log.Default.Msg(Log.Level.Error, "No valid child parameter set"); return false; } @@ -206,6 +211,13 @@ public void DeleteLeaf() /* ------------------------------------------------------------------*/ // private functions + /// + /// Add window leaf to this branch. + /// + /// The parent branch. + /// The content callbacks. + /// The content element the child is located in. + /// The actual child leaf object if present. private void add_leafchild(WindowBranch parent_branch, ContentCallbacks_Type content_callbacks, Grid grid, WindowLeaf child_leaf) { _parent_is_root = false; @@ -285,11 +297,14 @@ private void clear_content(Grid cotent_element) cotent_element.UpdateLayout(); } - + /// + /// Calculate the relative position of the splitter. + /// + /// The relative position of the splitter. private double calculate_position() { - /// NOTE: GridUnitType is fixed and always Star independant of the actual value, - /// so we have to check for the actual value to determine whenter the value is absolute or relative. + /// NOTE: GridUnitType is fixed and always Star independent of the actual value, + /// so we have to check for the actual value to determine whether the value is absolute or relative. double value = 0.0; switch (_orientation) { diff --git a/Core/GUI/Windows/WindowLeaf.cs b/Core/GUI/Windows/WindowLeaf.cs index efacacb..e6c2601 100644 --- a/Core/GUI/Windows/WindowLeaf.cs +++ b/Core/GUI/Windows/WindowLeaf.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.Remoting.Contexts; +using System.Text.RegularExpressions; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -22,7 +23,10 @@ public class WindowLeaf : AbstractWindow /* ------------------------------------------------------------------*/ // public classes - public class Settings : IAbstractSettings + /// + /// Settings data. + /// + public class Settings : IAbstractSettingData { public string ContentID { get; set; } public string ContentType { get; set; } @@ -33,13 +37,18 @@ public class Settings : IAbstractSettings // public properties public AttachedContent_Type AttachedContent { get { return _attached_content; } } - public Grid ContentElement { get { return _content; } } /* ------------------------------------------------------------------*/ // public functions + /// + /// Ctor. + /// + /// The parent window branch. + /// Flag indicating whether branch is root. + /// The content callbacks required in the window leaf. public WindowLeaf(WindowBranch parent_branch, bool parent_is_root, ContentCallbacks_Type content_callbacks) { _parent_branch = parent_branch; @@ -47,12 +56,12 @@ public WindowLeaf(WindowBranch parent_branch, bool parent_is_root, ContentCallba _content_callbacks = content_callbacks; if (_parent_branch == null) { - Log.Default.Msg(Log.Level.Error, "Paramter parent_branch should not be null"); + Log.Default.Msg(Log.Level.Error, "Parameter parent_branch should not be null"); return; } if (_content_callbacks == null) { - Log.Default.Msg(Log.Level.Error, "Paramter content_callbacks should not be null"); + Log.Default.Msg(Log.Level.Error, "Parameter content_callbacks should not be null"); return; } @@ -80,7 +89,12 @@ public WindowLeaf(WindowBranch parent_branch, bool parent_is_root, ContentCallba contextmenu_setup(); } - + /// + /// Request creation of new content. + /// + /// Provide ID of existing content or invalid id otherwise. + /// The type of the content as string. + /// The id of the attached content. public string CreateContent(string content_id, string content_type) { // Call Create Content @@ -106,25 +120,32 @@ public string CreateContent(string content_id, string content_type) return UniqueID.Invalid; } - + /// + /// Set new parent branch. + /// + /// The new parent branch. + /// Flag indicating if parent is root (required to prevent window deletion on top most level). public void SetParent(WindowBranch parent_branch, bool parent_is_root) { _parent_branch = parent_branch; _parent_is_root = parent_is_root; if (_parent_branch == null) { - Log.Default.Msg(Log.Level.Error, "Paramter parent_branch should not be null"); + Log.Default.Msg(Log.Level.Error, "Parameter parent_branch should not be null"); return; } // Recreate context menu due to changed root - contextmenu_setup(); + ///contextmenu_setup(); } /* ------------------------------------------------------------------*/ // private functions + /// + /// Used to setup the context menu once. + /// private void contextmenu_setup() { ContextMenu contextmenu = new ContextMenu(); @@ -134,7 +155,11 @@ private void contextmenu_setup() _content.ContextMenu = contextmenu; } - + /// + /// Callback called whenever context menu is opened. + /// + /// The sender object. + /// The routed event arguments. private void contextmenu_loaded(object sender, RoutedEventArgs e) { var contextmenu = sender as ContextMenu; @@ -210,7 +235,7 @@ private void contextmenu_loaded(object sender, RoutedEventArgs e) var content_item = new MenuItem(); content_item.Style = ColorTheme.MenuItemStyle(); - // Repalcement of spaces is necessary for Name property + // Replacement of spaces is necessary for Name property content_item.Header = content_data.Item1; content_item.Name = conform_name(content_data.Item1); // Name content_item.IsEnabled = content_data.Item2; // Available @@ -251,7 +276,11 @@ private void contextmenu_loaded(object sender, RoutedEventArgs e) contextmenu.Items.Add(item_content_dad); } - + /// + /// Called when a menu item in the context menu is clicked. + /// + /// The sender object. + /// The routed event arguments. private void menuitem_click(object sender, RoutedEventArgs e) { var sender_content = sender as MenuItem; @@ -292,7 +321,7 @@ private void menuitem_click(object sender, RoutedEventArgs e) AvailableContentList_Type available_contents = _content_callbacks.Item1(); foreach (var content_data in available_contents) { - // Repalcement of spaces is necessary for Name property + // Replacement of spaces is necessary for Name property string name = conform_name(content_data.Item1); if (content_id == name) { @@ -302,7 +331,9 @@ private void menuitem_click(object sender, RoutedEventArgs e) } } - + /// + /// Delete attached content permanently. + /// private void delete_content() { _content.Children.Clear(); @@ -318,7 +349,11 @@ private void delete_content() } } - + /// + /// Callback called when middle mouse button is pressed and mouse is moved. + /// + /// The sender object. + /// The mouse event arguments. private void content_mousemove(object sender, MouseEventArgs e) { var sender_grid = sender as Grid; @@ -334,7 +369,11 @@ private void content_mousemove(object sender, MouseEventArgs e) } } - + /// + /// Callback called when content is started to be dragged. + /// + /// The sender object. + /// The drag event arguments. private void content_dragover(object sender, DragEventArgs e) { var sender_grid = sender as Grid; @@ -351,7 +390,11 @@ private void content_dragover(object sender, DragEventArgs e) } } - + /// + /// Callback called when dragged content is dropped. + /// + /// The sender object. + /// The drag event arguments. private void content_drop(object sender, DragEventArgs e) { var sender_grid = sender as Grid; @@ -379,11 +422,18 @@ private void content_drop(object sender, DragEventArgs e) } } - + /// + /// Convert string to WPF conform 'Name' + /// + /// The input name. + /// The conform output name. private string conform_name(string name) { - // There are no spaces ' ' allowed in Control.Name - return name.Replace(' ', '_'); + var conform_name = name.Replace(" ", ""); ; + conform_name = conform_name.Replace("(", ""); + conform_name = conform_name.Replace(")", ""); + conform_name = Regex.Replace(conform_name, "[0-9]", ""); + return conform_name; } diff --git a/Core/GUI/Windows/WindowManager.cs b/Core/GUI/Windows/WindowManager.cs index 586c8c8..22826c8 100644 --- a/Core/GUI/Windows/WindowManager.cs +++ b/Core/GUI/Windows/WindowManager.cs @@ -19,7 +19,7 @@ namespace Core { namespace GUI { - public class WindowManager : AbstractService + public class WindowManager : AbstractService, IAbstractSettingData { /* ------------------------------------------------------------------*/ // public functions @@ -49,7 +49,6 @@ public bool Initialize(ContentCallbacks_Type content_callbacks) return _initilized; } - public Panel Attach() { if (!_initilized) @@ -60,7 +59,6 @@ public Panel Attach() return _content; } - public override bool Terminate() { bool terminated = true; @@ -75,7 +73,6 @@ public override bool Terminate() return terminated; } - public string CollectSettings() { var settings = new WindowBranch.Settings(); @@ -83,7 +80,6 @@ public string CollectSettings() return SettingsService.Serialize(settings); } - public bool ApplySettings(string settings) { var windowbranch_settings = SettingsService.Deserialize(settings); @@ -100,8 +96,10 @@ public bool ApplySettings(string settings) // private functions /// - /// Traverse window tree in breadth first order to gather all settings + /// Traverse window tree in breadth first order to gather all settings recursively. /// + /// The current branch object + /// The settings are appended according to the branch settings. void collect_settings(WindowBranch branch, WindowBranch.Settings settings) { if (branch == null) @@ -142,8 +140,10 @@ void collect_settings(WindowBranch branch, WindowBranch.Settings settings) /// - /// Traverse window tree in breadth first order to set branch settings + /// Traverse window tree in breadth first order and set branch settings recursively. /// + /// The initial branch object. + /// The settings object. void apply_settings(WindowBranch branch, WindowBranch.Settings settings) { if (settings == null) @@ -173,5 +173,4 @@ void apply_settings(WindowBranch branch, WindowBranch.Settings settings) private ContentCallbacks_Type _content_callbacks = null; } } - } diff --git a/Core/Utilities/ColorTheme.cs b/Core/Utilities/ColorTheme.cs index 9ff808b..b43e13a 100644 --- a/Core/Utilities/ColorTheme.cs +++ b/Core/Utilities/ColorTheme.cs @@ -11,7 +11,7 @@ /* - * Global GUI Color Theme + * Global GUI Color Theme for WPF * */ namespace Core @@ -23,6 +23,7 @@ public class ColorTheme /* ------------------------------------------------------------------*/ // static functions + // BACKGROUND ----------------------------------------------------- public static Brush BackgroundWhite { get { return Brushes.White; } } @@ -39,7 +40,6 @@ public class ColorTheme public static Brush GridBackground { get { return Brushes.AliceBlue; } } - // HYPER LINK ---------------------------------------------------- public static Style HyperlinkStyle() diff --git a/Core/Utilities/GUIHelpers.cs b/Core/Utilities/GUIHelpers.cs index f380c93..e9f7844 100644 --- a/Core/Utilities/GUIHelpers.cs +++ b/Core/Utilities/GUIHelpers.cs @@ -24,8 +24,11 @@ public class ImageHelper // static functions /// - /// Returns ImageSource + /// [STATIC] Create WPF __ImageSource__ for given resource location and file name. /// + /// One of the predefined resource locations. + /// The file name of the image. + /// The image source. public static ImageSource ImageSourceFromFile(WorkingDirectory.Locations resource_location, string filename) { var file_path = WorkingDirectory.ResourcePath(resource_location, filename); @@ -44,10 +47,12 @@ public static ImageSource ImageSourceFromFile(WorkingDirectory.Locations resourc return null; } - /// - /// Returns Image + /// [STATIC] Create WPF __Image__ for given resource location and file name. /// + /// One of the predefined resource locations. + /// The file name of the image. + /// The image. public static Image ImageFromFile(WorkingDirectory.Locations resource_location, string filename) { var image = new Image(); diff --git a/Core/Utilities/Log.cs b/Core/Utilities/Log.cs index 307bd1a..35187d5 100644 --- a/Core/Utilities/Log.cs +++ b/Core/Utilities/Log.cs @@ -43,7 +43,9 @@ public struct MessageData /* ------------------------------------------------------------------*/ // public functions - // Create singelton when Log.Default is called frist + /// + /// [STATIC] Create singelton when Log.Default is called the first time. + /// public static Log Default { get @@ -60,14 +62,21 @@ public static Log Default } } - + /// + /// Ctor. + /// public Log() { _messages = new List(); _listeners = new List(); } - + /// + /// Log new message. + /// + /// Log level of message. + /// The actual log message. + /// Pass separate stack trace instance. public void Msg(Log.Level level, string log, StackTrace custom_stacktrace = null) { #if DEBUG @@ -129,7 +138,10 @@ public void Msg(Log.Level level, string log, StackTrace custom_stacktrace = null #endif } - + /// + /// Register new log message listener. + /// + /// The log listener to register. public void RegisterListener(LogListener_Delegate listener) { _listeners.Add(listener); @@ -137,7 +149,11 @@ public void RegisterListener(LogListener_Delegate listener) listener(_messages); } - + /// + /// Unregister log listener. + /// + /// The listener that should be removed. + /// True on success, false otherwise. public bool UnRegisterListener(LogListener_Delegate listener) { return _listeners.Remove(listener); diff --git a/Core/Utilities/TimeBenchmark.cs b/Core/Utilities/TimeBenchmark.cs index fac8bf2..f6be338 100644 --- a/Core/Utilities/TimeBenchmark.cs +++ b/Core/Utilities/TimeBenchmark.cs @@ -5,7 +5,7 @@ /* * Benchmark Timer * - * >>> Only executed in DEBUG build + * Only executed in DEBUG build */ namespace Core { @@ -17,13 +17,18 @@ public class TimeBenchmark /* ------------------------------------------------------------------*/ // public functions + /// + /// Ctor. + /// public TimeBenchmark() { _started = false; _watch = new System.Diagnostics.Stopwatch(); } - + /// + /// Start benchmark timer. + /// public void Start() { #if DEBUG @@ -32,9 +37,17 @@ public void Start() _watch = System.Diagnostics.Stopwatch.StartNew(); _started = true; } + else + { + Log.Default.Msg(Log.Level.Warn, "Timer already started..."); + + } #endif } + /// + /// Stop the benchmark timer and log the elapsed time. + /// public void Stop() { #if DEBUG @@ -45,6 +58,11 @@ public void Stop() Log.Default.Msg(Log.Level.Debug, "Elapsed Time (ms): " + elapsed_ms.ToString(), new StackTrace(true)); _started = false; } + else + { + Log.Default.Msg(Log.Level.Warn, "Start timer before stopping it..."); + + } #endif } diff --git a/Core/Utilities/TypeAliases.cs b/Core/Utilities/TypeAliases.cs index 73e5ac2..95820e3 100644 --- a/Core/Utilities/TypeAliases.cs +++ b/Core/Utilities/TypeAliases.cs @@ -9,7 +9,7 @@ /* - * Type Aliases + * Globally available type aliases * */ namespace Core diff --git a/Core/Utilities/UniqueID.cs b/Core/Utilities/UniqueID.cs index bf31574..2baae2f 100644 --- a/Core/Utilities/UniqueID.cs +++ b/Core/Utilities/UniqueID.cs @@ -17,17 +17,23 @@ public class UniqueID /* ------------------------------------------------------------------*/ // static functions + /// + /// [STATIC] Generate unique string id. + /// + /// The id as string. public static string Generate() { var random = new Random(); string id = Guid.NewGuid().ToString("N"); const string letters = "abcdefghijklmnopqrstuvwxyz"; - // Prepend letter to get valid WPF names + // Prefix letter to get valid WPF names id = letters[random.Next(letters.Length)] + id; return id; } - + /// + /// [STATIC] Variable representing an invalid id. + /// public static string Invalid { get { return "invalid"; } } } } diff --git a/Core/Utilities/WorkingDirectory.cs b/Core/Utilities/WorkingDirectory.cs index 68bb214..3f6d222 100644 --- a/Core/Utilities/WorkingDirectory.cs +++ b/Core/Utilities/WorkingDirectory.cs @@ -27,16 +27,22 @@ public enum Locations // static functions /// - /// Returns the path of the VisFroG plugin - /// e.g. C:\Users\...\AppData\Roaming\Grasshopper\Libraries\VisFrog - /// + /// [STATIC] Returns the location from which the application is executed + /// E.g. location of the GHA plug-in: "C:\Users\...\AppData\Roaming\Grasshopper\Libraries\VisFrog" + /// + /// The absolute path as string. public static string Path() { return System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); // Alternative: System.AppContext.CoreDirectory; } - + /// + /// [STATIC] Create application specific file name. + /// + /// The file name body. + /// The file extension. + /// The file name. public static string FileName(string body, string extension) { // Append unified prefix @@ -44,13 +50,23 @@ public static string FileName(string body, string extension) return prefix + body + "." + extension; ; } - + /// + /// [STATIC] Create application specific file path. + /// + /// The body of the file name. + /// The file extension. + /// The absolute file path. public static string FilePath(string body, string extension) { return System.IO.Path.Combine(Utilities.WorkingDirectory.Path(), Utilities.WorkingDirectory.FileName(body, extension)); } - + /// + /// [STATIC] The application specific path to the file resource location. + /// + /// Specify the required resource location. + /// The file name of the resource. + /// The absolute resource file path. public static string ResourcePath(Locations resource, string filename) { // resource == WorkingDirectory: diff --git a/EntityFrameworkDatabase/App.config b/EntityFrameworkDatabase/App.config deleted file mode 100644 index 21e0a85..0000000 --- a/EntityFrameworkDatabase/App.config +++ /dev/null @@ -1,23 +0,0 @@ - - - - - -
- - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/EntityFrameworkDatabase/DatabaseService.cs b/EntityFrameworkDatabase/DatabaseService.cs deleted file mode 100644 index fe0c1b5..0000000 --- a/EntityFrameworkDatabase/DatabaseService.cs +++ /dev/null @@ -1,67 +0,0 @@ -using EntityFrameworkDatabase.Models; -using System.Linq; -using Core.Utilities; -using Core.Abstracts; - - - -/* - * Entity Framework Database - * - */ -/* TEST -Execute: - IQueryable query = _database_context.Entites.Where(e => e.Id == 4); - foreach (Entity obj in query) - { - Log.Default.Msg(Log.Level.Debug, obj.Title); - } -*/ -namespace EntityFrameworkDatabase -{ - public class DatabaseService : AbstractService - { - - /* ------------------------------------------------------------------*/ - // public functions - - public override bool Initialize() - { - if (_initilized) - { - Terminate(); - } - _timer.Start(); - - _database_context = new DatabaseContext(); - - _timer.Stop(); - _initilized = true; - if (_initilized) - { - Log.Default.Msg(Log.Level.Info, "Successfully initialized: " + this.GetType().Name); - } - return _initilized; - } - - - public override bool Terminate() - { - if (_initilized) - { - _database_context.Dispose(); - _database_context = null; - - _initilized = false; - } - return true; - } - - - /* ------------------------------------------------------------------*/ - // private variables - - private DatabaseContext _database_context = null; - - } -} diff --git a/EntityFrameworkDatabase/EntityFrameworkDatabase.csproj b/EntityFrameworkDatabase/EntityFrameworkDatabase.csproj deleted file mode 100644 index cc564fd..0000000 --- a/EntityFrameworkDatabase/EntityFrameworkDatabase.csproj +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - Debug - AnyCPU - {25E78628-3ABC-441B-B8C3-1B4E451CAD2B} - Library - EntityFrameworkDatabase - EntityFrameworkDatabase - v4.8 - 512 - true - true - - - false - false - $(SolutionDir)bin - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - 7.3 - prompt - true - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - 7.3 - prompt - true - - - - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - 7.3 - prompt - true - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - 7.3 - prompt - true - - - - ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll - - - ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll - - - - - - - - - - - - - - - 202308160813576_Initial.cs - - - - - - - - - - - - - - {8da3258e-49cf-483f-a100-3a12304bde0e} - Core - - - - - 202308160813576_Initial.cs - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - \ No newline at end of file diff --git a/EntityFrameworkDatabase/Migrations/202308160813576_Initial.Designer.cs b/EntityFrameworkDatabase/Migrations/202308160813576_Initial.Designer.cs deleted file mode 100644 index 5fb0c1a..0000000 --- a/EntityFrameworkDatabase/Migrations/202308160813576_Initial.Designer.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -namespace EntityFrameworkDatabase.Migrations -{ - using System.CodeDom.Compiler; - using System.Data.Entity.Migrations; - using System.Data.Entity.Migrations.Infrastructure; - using System.Resources; - - [GeneratedCode("EntityFramework.Migrations", "6.4.4")] - public sealed partial class Initial : IMigrationMetadata - { - private readonly ResourceManager Resources = new ResourceManager(typeof(Initial)); - - string IMigrationMetadata.Id - { - get { return "202308160813576_Initial"; } - } - - string IMigrationMetadata.Source - { - get { return null; } - } - - string IMigrationMetadata.Target - { - get { return Resources.GetString("Target"); } - } - } -} diff --git a/EntityFrameworkDatabase/Migrations/202308160813576_Initial.cs b/EntityFrameworkDatabase/Migrations/202308160813576_Initial.cs deleted file mode 100644 index 2ec88f0..0000000 --- a/EntityFrameworkDatabase/Migrations/202308160813576_Initial.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Data.Entity.Migrations; - - - -/* - * Database Migration - * - */ -namespace EntityFrameworkDatabase -{ - namespace Migrations - { - public partial class Initial : DbMigration - { - public override void Up() - { - CreateTable( - "dbo.Entities", - c => new - { - Id = c.Int(nullable: false, identity: true), - Title = c.String(nullable: false), - Name = c.String(), - }) - .PrimaryKey(t => t.Id); - - } - - public override void Down() - { - DropTable("dbo.Entities"); - } - } - } -} diff --git a/EntityFrameworkDatabase/Migrations/202308160813576_Initial.resx b/EntityFrameworkDatabase/Migrations/202308160813576_Initial.resx deleted file mode 100644 index bce6b15..0000000 --- a/EntityFrameworkDatabase/Migrations/202308160813576_Initial.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - H4sIAAAAAAAEAM1X227bOBB9X2D/geBTF0jNXF52A7lF6iSLYOskqNK+09JYIcqLlqSy9rf1oZ/UX9ihdbXkW9KiKAIENjlz5szRXORvX75GbxdKkiewThg9piejY0pAJyYVOhvTws9f/0nfvvn9t+gqVQvyqbY7C3boqd2YPnqfnzPmkkdQ3I2USKxxZu5HiVGMp4adHh//xU5OGCAERSxCog+F9kLB6gt+nRidQO4LLqcmBemqc7yJV6jklitwOU9gTK/Q0y+vLZ78Z+znS+75jDsYlZ6UXEjBkVUMck4J19p47pHz+UcHsbdGZ3GOB1w+LHNAuzmXDqpczlvzQ9M6Pg1psdaxhkoK5416JuDJWaUT67u/SG3a6IhKlrqFrFdq1kJS0g91PpE2mO2TelReH5EtZkdNuWBVhb8jMimkLyyMNRTecnlE7ouZFMk/sHwwn0GPdSFllzTSxru1Azy6tyYH65cfYF6lcpNSwtb9WN+xcev4lGneaH92SsktBuczCU1NdCSJvbHwN2iw3EN6z70HqwMGVCKynbEehJdQh8MqxOaiZMoX70Fn/nFM8SMl12IBaX1SUfioBfYiOnlbwAaKu8OG/z8gajdIxNo6GlYX9rHnAlWqCNSlEM5h4TfUGnZlVW6uCreeUYkbg+8WLWCbtzTKXh9dbXgSNduGVztYWDlZ6gnEtoygaMrzHIXrjKTqhMTlPJq8jp/fnKrEYInb0KMN2yYSVh/PoHeLoZHptbDO1zpTMknVwKz/FLYoXEdbF7rffK3utX343J0oe+ZFH7FVFB0zhQ21yhcaXs2kGjiu9gOX3G5o7YmRhdLbxsMu76pZuwDV0eEYZed1IcqTIULEetn3BWcDxXuDrv8Ad9V/36SJ3vRBr96jqvb27+VBMZYmlKA0TyINhRgvnQc1Cgaj+F85kQLzbQ2mXIs5OF/uAorr8LS3zn+d1cqcS+VB+/WnrzMRNN27sJ65StY2mH7iNnnk9pXiiz++ayttRfrezTMcjQfsleWOtVJW85imM4PkS5KrOxG20QuXzrC5ItZ9NY4uwYmshQgvyhqSULUtaG1zo+emlhoT6zKqTXpPYgqep6jPhfVizhOP1wk4t3pP+MRlEVJUM0hv9F3h88JfOAdqJteWbMR2x19t1nXO0V0evrkfkQLSFJgC3Ol3hZBpw/t6WInbIEKpVJ2CrPA9CeGyZYN0a/SBQJV8l5CDDn32ACqXCObudMyf4CXc8PXoPWQ8WdYzcjvI/gexLnt0KXiGq9pVGK1/+LnHwu+9N/8DGVj7iCEOAAA= - - - dbo - - \ No newline at end of file diff --git a/EntityFrameworkDatabase/Migrations/Configuration.cs b/EntityFrameworkDatabase/Migrations/Configuration.cs deleted file mode 100644 index 7c48932..0000000 --- a/EntityFrameworkDatabase/Migrations/Configuration.cs +++ /dev/null @@ -1,48 +0,0 @@ -using EntityFrameworkDatabase.Models; -using System; -using System.Data.Entity.Migrations; -using Core.Utilities; - - - -/* - * Database Configuration - * - */ -namespace EntityFrameworkDatabase -{ - namespace Migrations - { - - internal sealed class Configuration : DbMigrationsConfiguration - { - - /* ------------------------------------------------------------------*/ - // public functions - - public Configuration() - { - // Set data directory variable given in connection string of DatabaseContext - AppDomain.CurrentDomain.SetData("DataDirectory", WorkingDirectory.Path()); - - AutomaticMigrationsEnabled = false; - } - - protected override void Seed(EntityFrameworkDatabase.Models.DatabaseContext context) - { - // This method will be called after migrating to the latest version. - - // You can use the DbSet.AddOrUpdate() helper extension method - // to avoid creating duplicate seed data. - context.Entites.AddOrUpdate( - new Entity[] { - new Entity() { Id = 1, Title = "Title1", Name = "One" }, - new Entity() { Id = 2, Title = "Title2", Name = "Two" }, - new Entity() { Id = 3, Title = "Title3", Name = "Three" }, - new Entity() { Id = 4, Title = "Title4", Name = "Four" } - } - ); - } - } - } -} diff --git a/EntityFrameworkDatabase/Models/DatabaseContext.cs b/EntityFrameworkDatabase/Models/DatabaseContext.cs deleted file mode 100644 index 5c0dbf9..0000000 --- a/EntityFrameworkDatabase/Models/DatabaseContext.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Data.Entity; -using EntityFrameworkDatabase.Migrations; -using Core.Utilities; - - - -/* - * Database Context - * - */ -namespace EntityFrameworkDatabase -{ - namespace Models - { - - public class DatabaseContext : DbContext - { - - /* ------------------------------------------------------------------*/ - // public functions - - // You can add custom code to this file. Changes will not be overwritten. - // - // If you want Entity Framework to drop and regenerate your database - // automatically whenever you change your model schema, please use data migrations. - // For more information refer to the documentation: - // http://msdn.microsoft.com/en-us/data/jj591621.aspx - - - /// - /// Use base("name=DatabaseContext") to look for connectionString in App.config - /// => But App.config can not be used by Grasshopper component - /// DataDirectory is defined in CTOR of Configuration - /// - public DatabaseContext() : base("Data Source=(localdb)\\MSSQLLocalDB; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|" + WorkingDirectory.FileName("database", "mdf")) - { - Database.SetInitializer(new MigrateDatabaseToLatestVersion()); - } - - - /* ------------------------------------------------------------------*/ - // public variables - - public System.Data.Entity.DbSet Entites { get; set; } - - } - } -} diff --git a/EntityFrameworkDatabase/Models/Entity.cs b/EntityFrameworkDatabase/Models/Entity.cs deleted file mode 100644 index eb347e1..0000000 --- a/EntityFrameworkDatabase/Models/Entity.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.ComponentModel.DataAnnotations; - - - -/* - * Database Model - * - */ -namespace EntityFrameworkDatabase -{ - namespace Models - { - public class Entity - { - - /* ------------------------------------------------------------------*/ - // public variables - - public int Id { get; set; } - [Required] - - - public string Title { get; set; } - - - public string Name { get; set; } - - } - } -} diff --git a/EntityFrameworkDatabase/Properties/AssemblyInfo.cs b/EntityFrameworkDatabase/Properties/AssemblyInfo.cs deleted file mode 100644 index 073a58b..0000000 --- a/EntityFrameworkDatabase/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Database")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Universität Stuttgart")] -[assembly: AssemblyProduct("Database")] -[assembly: AssemblyCopyright("Copyright © Universität Stuttgart 2023")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("25e78628-3abc-441b-b8c3-1b4e451cad2b")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// 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.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/EntityFrameworkDatabase/packages.config b/EntityFrameworkDatabase/packages.config deleted file mode 100644 index 8c50e8b..0000000 --- a/EntityFrameworkDatabase/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GrasshopperComponent/GrasshopperComponent.csproj b/GrasshopperComponent/GrasshopperComponent.csproj index b56cc91..fe880a3 100644 --- a/GrasshopperComponent/GrasshopperComponent.csproj +++ b/GrasshopperComponent/GrasshopperComponent.csproj @@ -17,7 +17,6 @@ - diff --git a/GrasshopperComponent/Utilities/ConvertData.cs b/GrasshopperComponent/Utilities/ConvertData.cs index 8e74924..9675c67 100644 --- a/GrasshopperComponent/Utilities/ConvertData.cs +++ b/GrasshopperComponent/Utilities/ConvertData.cs @@ -27,6 +27,11 @@ public class ConvertData /* ------------------------------------------------------------------*/ // static functions + /// + /// [STATIC] Convert data provided by the interface to data type not depending on interface specific type. + /// + /// Reference to the data. + /// The converted data. public static XYData_Type GH_to_List(ref GH_Structure input) { var output = new XYData_Type(); @@ -63,7 +68,11 @@ public static XYData_Type GH_to_List(ref GH_Structure input) return output; } - + /// + /// [STATIC] Convert data provided by the application to interface specific data type. + /// + /// Reference to the data. + /// The converted data. public static GH_Structure list_to_gh(ref XYData_Type input) { var ouptut = new GH_Structure(); diff --git a/GrasshopperComponent/Utilities/RuntimeMessages.cs b/GrasshopperComponent/Utilities/RuntimeMessages.cs index 736e8b9..bd9fa0b 100644 --- a/GrasshopperComponent/Utilities/RuntimeMessages.cs +++ b/GrasshopperComponent/Utilities/RuntimeMessages.cs @@ -25,13 +25,21 @@ public class RuntimeMessages /* ------------------------------------------------------------------*/ // public functions + /// + /// Ctor. + /// + /// The parent Grasshopper component to access the runtime message interface. public RuntimeMessages(GH_Component ghcomponent) { _parent = ghcomponent; _messages = new List<(GH_RuntimeMessageLevel, string)>(); } - + /// + /// Add new message to the Grasshopper specific log. + /// + /// The log level. + /// The actual log message. public void Add(Log.Level level, string message) { switch (level) @@ -53,7 +61,9 @@ public void Add(Log.Level level, string message) Log.Default.Msg(level, message, new StackTrace(true)); } - + /// + /// Send all messages to the Grasshopper component. + /// public void Show() { if (_parent == null) diff --git a/GrasshopperComponent/VisFroG.cs b/GrasshopperComponent/VisFroG.cs index e268999..4885b90 100644 --- a/GrasshopperComponent/VisFroG.cs +++ b/GrasshopperComponent/VisFroG.cs @@ -43,7 +43,6 @@ public VisFroG() _exec_count = 0; } - /// /// Registers all the input parameters for this component. /// @@ -54,7 +53,6 @@ protected override void RegisterInputParams(GH_InputParamManager pManager) pManager[0].Optional = true; } - /// /// Registers all the output parameters for this component. /// @@ -63,7 +61,6 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) pManager.AddGenericParameter("Generic Output Data", "Output Data", "Generic output data from interaction.", GH_ParamAccess.tree); } - /// /// This is the method that actually does the work. /// @@ -115,16 +112,16 @@ protected override void SolveInstance(IGH_DataAccess DataAccess) /* // Provide wrappers for DataAccess.S/GetDataTree, DataAccess.S/GetDataList, and DataAccess.S/GetData - // Access all input paramters + // Access all input parameters foreach (var input_param in Params.Input) { - _runtimemessages.Add(Log.Level.Warn, "Input Paramter Name: " + input_param.Name + " | Type: " + input_param.Type.ToString()); + _runtimemessages.Add(Log.Level.Warn, "Input Parameter Name: " + input_param.Name + " | Type: " + input_param.Type.ToString()); Tuple } - // Access all ouput paramters + // Access all output parameters foreach (var output_param in Params.Output) { - _runtimemessages.Add(Log.Level.Warn, "Input Paramter Name: " + output_param.Name + " | Type: " + output_param.Type.ToString()); + _runtimemessages.Add(Log.Level.Warn, "Input Parameter Name: " + output_param.Name + " | Type: " + output_param.Type.ToString()); Tuple } @@ -150,12 +147,18 @@ protected override void SolveInstance(IGH_DataAccess DataAccess) /* ------------------------------------------------------------------*/ // private functions + /// + /// Callback to trigger reloading of the Grasshopper solution. + /// public void reload_instance() { ExpireSolution(true); } - + /// + /// Callback for retrieving new output data. + /// + /// Reference to the new output data. public void retrieve_output_data(ref XYData_Type ouput_data) { _output_data = ConvertData.list_to_gh(ref ouput_data); diff --git a/PythonInterface/PythonCallback.cs b/PythonInterface/PythonCallback.cs index 247bc17..0cabc9f 100644 --- a/PythonInterface/PythonCallback.cs +++ b/PythonInterface/PythonCallback.cs @@ -1,4 +1,5 @@ using System; + using Core.Utilities; @@ -17,12 +18,20 @@ public static class PythonCallback /* ------------------------------------------------------------------*/ // static functions + /// + /// [STATIC] Callback called from within Python script to print message (DEBUG). + /// + /// public static void PrintMessage(string message) { /// TODO Runs in parallel thread which is currently not supported by Log.Default.Msg Console.WriteLine("PythonCallback>>> Message = " + message); } + /// + /// [STATIC] Callback called from within Python script to get output file for Bokeh (DEBUG). + /// + /// public static string GetBokehOutputFilePath() { return WorkingDirectory.FilePath("bokeh", "html"); diff --git a/PythonInterface/PythonInterfaceService.cs b/PythonInterface/PythonInterfaceService.cs index f9b9fd8..78cdbaa 100644 --- a/PythonInterface/PythonInterfaceService.cs +++ b/PythonInterface/PythonInterfaceService.cs @@ -13,7 +13,6 @@ */ /* TEST Execute: - _worker.Start(); */ namespace Visualizations @@ -71,7 +70,6 @@ public override bool Initialize() return _initilized; } - public override bool Terminate() { if (_initilized) diff --git a/PythonInterface/PythonScript.cs b/PythonInterface/PythonScript.cs index e8ee607..703b7d8 100644 --- a/PythonInterface/PythonScript.cs +++ b/PythonInterface/PythonScript.cs @@ -16,12 +16,21 @@ namespace PythonInterface public class PythonScript { + /* ------------------------------------------------------------------*/ + // public property + + public string _StringID { get; set; } + + /* ------------------------------------------------------------------*/ // public functions + /// + /// Load script from file (DEBUG). + /// + /// public bool Initialize() { - /// DEBUG Load script from file try { _source = File.ReadAllText(@"bokeh-template.py"); @@ -37,7 +46,9 @@ public bool Initialize() return _initilized; } - + /// + /// Execute script. + /// public void Execute() { // Global Interpreter Lock @@ -55,7 +66,7 @@ public void Execute() scope.Exec(_source); - /// DEBUG Get 'Start' fuction as PyObject + /// DEBUG Get 'Start' function as PyObject dynamic start = scope.Get("Start"); start(); } @@ -66,18 +77,11 @@ public void Execute() } - /* ------------------------------------------------------------------*/ - // public variables - - public string _StringID { get; set; } - - /* ------------------------------------------------------------------*/ // private variables private bool _initilized = false; private string _source = null; } - } } diff --git a/SciChartInterface/SciChartInterfaceService.cs b/SciChartInterface/SciChartInterfaceService.cs index 2d7c054..dc35958 100644 --- a/SciChartInterface/SciChartInterfaceService.cs +++ b/SciChartInterface/SciChartInterfaceService.cs @@ -19,7 +19,6 @@ namespace SciChartInterface { public class SciChartInterfaceService : AbstractService { - /* ------------------------------------------------------------------*/ // public functions @@ -56,7 +55,6 @@ public override bool Initialize() return _initilized; } - public override bool Terminate() { if (_initilized) diff --git a/VisFroG.sln b/VisFroG.sln index 6c8f10c..623c38e 100644 --- a/VisFroG.sln +++ b/VisFroG.sln @@ -20,15 +20,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAPI", "WebAPI\WebAPI.csp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core", "Core\Core.csproj", "{8DA3258E-49CF-483F-A100-3A12304BDE0E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFrameworkDatabase", "EntityFrameworkDatabase\EntityFrameworkDatabase.csproj", "{25E78628-3ABC-441B-B8C3-1B4E451CAD2B}" - ProjectSection(ProjectDependencies) = postProject - {8DA3258E-49CF-483F-A100-3A12304BDE0E} = {8DA3258E-49CF-483F-A100-3A12304BDE0E} - EndProjectSection -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Visualizations", "Visualizations\Visualizations.csproj", "{73CD0EC1-44DA-469C-B382-42479D3DE8EF}" ProjectSection(ProjectDependencies) = postProject {1233EAB1-DB38-4264-830A-A40FC694D44D} = {1233EAB1-DB38-4264-830A-A40FC694D44D} - {25E78628-3ABC-441B-B8C3-1B4E451CAD2B} = {25E78628-3ABC-441B-B8C3-1B4E451CAD2B} {349A7EEE-74E9-44F5-8404-0DDB7B74DB6A} = {349A7EEE-74E9-44F5-8404-0DDB7B74DB6A} {8DA3258E-49CF-483F-A100-3A12304BDE0E} = {8DA3258E-49CF-483F-A100-3A12304BDE0E} {AC9A69F3-1273-46CD-BDD2-14BC512C8413} = {AC9A69F3-1273-46CD-BDD2-14BC512C8413} @@ -118,18 +112,6 @@ Global {8DA3258E-49CF-483F-A100-3A12304BDE0E}.Release|x64.Build.0 = Release|x64 {8DA3258E-49CF-483F-A100-3A12304BDE0E}.Release|x86.ActiveCfg = Release|x86 {8DA3258E-49CF-483F-A100-3A12304BDE0E}.Release|x86.Build.0 = Release|x86 - {25E78628-3ABC-441B-B8C3-1B4E451CAD2B}.Debug|Any CPU.ActiveCfg = Debug|x64 - {25E78628-3ABC-441B-B8C3-1B4E451CAD2B}.Debug|Any CPU.Build.0 = Debug|x64 - {25E78628-3ABC-441B-B8C3-1B4E451CAD2B}.Debug|x64.ActiveCfg = Debug|x64 - {25E78628-3ABC-441B-B8C3-1B4E451CAD2B}.Debug|x64.Build.0 = Debug|x64 - {25E78628-3ABC-441B-B8C3-1B4E451CAD2B}.Debug|x86.ActiveCfg = Debug|x86 - {25E78628-3ABC-441B-B8C3-1B4E451CAD2B}.Debug|x86.Build.0 = Debug|x86 - {25E78628-3ABC-441B-B8C3-1B4E451CAD2B}.Release|Any CPU.ActiveCfg = Release|x64 - {25E78628-3ABC-441B-B8C3-1B4E451CAD2B}.Release|Any CPU.Build.0 = Release|x64 - {25E78628-3ABC-441B-B8C3-1B4E451CAD2B}.Release|x64.ActiveCfg = Release|x64 - {25E78628-3ABC-441B-B8C3-1B4E451CAD2B}.Release|x64.Build.0 = Release|x64 - {25E78628-3ABC-441B-B8C3-1B4E451CAD2B}.Release|x86.ActiveCfg = Release|x86 - {25E78628-3ABC-441B-B8C3-1B4E451CAD2B}.Release|x86.Build.0 = Release|x86 {73CD0EC1-44DA-469C-B382-42479D3DE8EF}.Debug|Any CPU.ActiveCfg = Debug|x64 {73CD0EC1-44DA-469C-B382-42479D3DE8EF}.Debug|Any CPU.Build.0 = Debug|x64 {73CD0EC1-44DA-469C-B382-42479D3DE8EF}.Debug|x64.ActiveCfg = Debug|x64 @@ -175,7 +157,6 @@ Global {F7EA1364-BB72-4A5C-8D18-B17FB1259CEC} = {5F95C4A3-F007-44BD-8F70-AD62BB3E0DF5} {349A7EEE-74E9-44F5-8404-0DDB7B74DB6A} = {E582AB98-05BD-42D1-B7FD-1C3429A1B3BF} {8DA3258E-49CF-483F-A100-3A12304BDE0E} = {E34DEBB4-3461-4181-AD7D-98FED63E2A97} - {25E78628-3ABC-441B-B8C3-1B4E451CAD2B} = {E34DEBB4-3461-4181-AD7D-98FED63E2A97} {73CD0EC1-44DA-469C-B382-42479D3DE8EF} = {F33F180B-EA53-432F-BCCF-421EC014710C} {F33F180B-EA53-432F-BCCF-421EC014710C} = {E34DEBB4-3461-4181-AD7D-98FED63E2A97} {19CB362F-8A13-4920-B9F4-065EA01A2BD6} = {F33F180B-EA53-432F-BCCF-421EC014710C} diff --git a/Visualizations/Abstracts/AbstractSciChart.cs b/Visualizations/Abstracts/AbstractSciChart.cs index 2773a6c..6f3e270 100644 --- a/Visualizations/Abstracts/AbstractSciChart.cs +++ b/Visualizations/Abstracts/AbstractSciChart.cs @@ -13,7 +13,7 @@ /* - * Abstract Visualization + * Abstract Visualization for SciChart based visualizations relying on the SciChartSurface. * */ namespace Visualizations @@ -34,7 +34,7 @@ public abstract class AbstractSciChart : AbstractVisualization public sealed override bool Initialize() { - if (_initilized) + if (_initialized) { Terminate(); } @@ -44,15 +44,14 @@ public sealed override bool Initialize() _content.Name = ID; _timer.Stop(); - _initilized = true; - if (_initilized) + _initialized = true; + if (_initialized) { Log.Default.Msg(Log.Level.Info, "Successfully initialized: " + this.GetType().FullName); } - return _initilized; + return _initialized; } - public sealed override Control Attach() { if (!_created) @@ -67,7 +66,6 @@ public sealed override Control Attach() return _content; } - public sealed override bool Detach() { // Required to release mouse handling @@ -76,15 +74,14 @@ public sealed override bool Detach() return true; } - public sealed override bool Terminate() { - if (_initilized) + if (_initialized) { _content.Dispose(); _content = null; - _initilized = false; + _initialized = false; } return true; } diff --git a/Visualizations/Abstracts/AbstractSciChartParallel.cs b/Visualizations/Abstracts/AbstractSciChartParallel.cs new file mode 100644 index 0000000..6057b4e --- /dev/null +++ b/Visualizations/Abstracts/AbstractSciChartParallel.cs @@ -0,0 +1,96 @@ +using System; +using System.Runtime.Remoting.Contexts; +using System.Windows.Controls; +using System.Windows.Media; +using System.Collections.Generic; +using Core.Abstracts; +using Visualizations.Management; +using Visualizations.SciChartInterface; +using Core.Utilities; +using SciChart.Charting.Visuals; +using SciChart.Charting.Model.DataSeries; + + + +/* + * Abstract Visualization for SciChart based visualizations relying on the SciChartParallelCoordinateSurface. + * + */ +namespace Visualizations +{ + namespace Abstracts + { + public abstract class AbstractSciChartParallel : AbstractVisualization + { + + /* ------------------------------------------------------------------*/ + // properties + + public sealed override List DependingServices { get { return new List() { typeof(SciChartInterfaceService) }; } } + + + /* ------------------------------------------------------------------*/ + // public functions + + public sealed override bool Initialize() + { + if (_initialized) + { + Terminate(); + } + _timer.Start(); + + _content = new SciChartParallelCoordinateSurface(); + _content.Name = ID; + + _timer.Stop(); + _initialized = true; + if (_initialized) + { + Log.Default.Msg(Log.Level.Info, "Successfully initialized: " + this.GetType().FullName); + } + return _initialized; + } + + public sealed override Control Attach() + { + if (!_created) + { + Log.Default.Msg(Log.Level.Error, "Creation of content required prior to execution"); + return null; + } + + _content.ChartModifier.IsAttached = true; + + _attached = true; + return _content; + } + + public sealed override bool Detach() + { + // Required to release mouse handling + _content.ChartModifier.IsAttached = false; + + return true; + } + + public sealed override bool Terminate() + { + if (_initialized) + { + _content.Dispose(); + _content = null; + + _initialized = false; + } + return true; + } + + + /* ------------------------------------------------------------------*/ + // protected variables + + protected SciChartParallelCoordinateSurface _content = null; + } + } +} diff --git a/Visualizations/Abstracts/AbstractVisualization.cs b/Visualizations/Abstracts/AbstractVisualization.cs index dea8654..097ac49 100644 --- a/Visualizations/Abstracts/AbstractVisualization.cs +++ b/Visualizations/Abstracts/AbstractVisualization.cs @@ -23,22 +23,25 @@ public abstract class AbstractVisualization : AbstractContent /* ------------------------------------------------------------------*/ // properties - public sealed override bool MultipleIntances - { - get { return true; } - } + /// + /// All visualizations should be able to be used multiple times. + /// + public sealed override bool MultipleInstances { get { return true; } } /* ------------------------------------------------------------------*/ // public functions + /// + /// Visualizations need access to data of specific type. + /// + /// Callback from data manager to request data of specific type. public void SetRequestDataCallback(DataManager.RequestDataCallback_Delegate request_data_callback) { _request_data_callback = request_data_callback; } - /* ------------------------------------------------------------------*/ // private variables diff --git a/Visualizations/App.config b/Visualizations/App.config index c91a377..221552c 100644 --- a/Visualizations/App.config +++ b/Visualizations/App.config @@ -1,23 +1,10 @@  - -
- - - - - - - - - - - - - - + + + @@ -46,4 +33,5 @@ + \ No newline at end of file diff --git a/Visualizations/Interaction/FilterContent.cs b/Visualizations/Interaction/FilterContent.cs new file mode 100644 index 0000000..b0d41cd --- /dev/null +++ b/Visualizations/Interaction/FilterContent.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Media; +using System.Windows; +using Core.Abstracts; +using Core.Utilities; + + + +/* + * Content for Data Filtering + * + */ +namespace Visualizations +{ + namespace Interaction + { + public class FilterContent : AbstractContent + { + /* ------------------------------------------------------------------*/ + // properties + + public override string Name { get { return "Data Filtering"; } } + public override bool MultipleInstances { get { return true; } } + public override List DependingServices { get { return new List() { }; } } + + + /* ------------------------------------------------------------------*/ + // public functions + + public override bool Initialize() + { + if (_initialized) + { + Terminate(); + } + _timer.Start(); + + + + _timer.Stop(); + _initialized = true; + if (_initialized) + { + Log.Default.Msg(Log.Level.Info, "Successfully initialized: " + this.GetType().FullName); + } + return _initialized; + } + + public override bool Create() + { + if (!_initialized) + { + Log.Default.Msg(Log.Level.Error, "Initialization required prior to execution"); + return false; + } + if (_created) + { + Log.Default.Msg(Log.Level.Warn, "Content already created, skipping..."); + return false; + } + _timer.Start(); + + + + + _timer.Stop(); + + _created = true; + return _created; + } + + public override Control Attach() + { + if (!_initialized) + { + Log.Default.Msg(Log.Level.Error, "Initialization required prior to execution"); + return null; + } + if (!_created) + { + Log.Default.Msg(Log.Level.Error, "Creation of content required prior to execution"); + return null; + } + + + _content.Background = ColorTheme.BackgroundBlack; + + _attached = true; + return _content; + } + + public override bool Terminate() + { + if (_initialized) + { + _content = null; + + + _initialized = false; + } + return true; + } + + + /* ------------------------------------------------------------------*/ + // private variables + + private ScrollViewer _content = null; + + /// TODO Connected visualizations... + } + } +} diff --git a/Visualizations/Interaction/Filtering/FilterContent.cs b/Visualizations/Interaction/Filtering/FilterContent.cs deleted file mode 100644 index 7f45966..0000000 --- a/Visualizations/Interaction/Filtering/FilterContent.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Media; -using System.Windows; -using Core.Abstracts; -using Core.Utilities; - - - -/* - * Data Filtering Window Content - * - */ -namespace Visualizations -{ - - namespace Interaction - { - namespace Filtering - { - internal class FilterContent : AbstractContent - { - /* ------------------------------------------------------------------*/ - // properties - - public override string Name { get { return "Data Filtering"; } } - public override bool MultipleIntances { get { return true; } } - public override List DependingServices { get { return new List() { }; } } - - - /* ------------------------------------------------------------------*/ - // public functions - - public override bool Initialize() - { - if (_initilized) - { - Terminate(); - } - _timer.Start(); - - - - _timer.Stop(); - _initilized = true; - if (_initilized) - { - Log.Default.Msg(Log.Level.Info, "Successfully initialized: " + this.GetType().FullName); - } - return _initilized; - } - - - public override bool Create() - { - if (!_initilized) - { - Log.Default.Msg(Log.Level.Error, "Initialization required prior to execution"); - return false; - } - if (_created) - { - Log.Default.Msg(Log.Level.Warn, "Content already created, skipping..."); - return false; - } - _timer.Start(); - - - - - _timer.Stop(); - - _created = true; - return _created; - } - - - public override Control Attach() - { - if (!_initilized) - { - Log.Default.Msg(Log.Level.Error, "Initialization required prior to execution"); - return null; - } - if (!_created) - { - Log.Default.Msg(Log.Level.Error, "Creation of content required prior to execution"); - return null; - } - - - _content.Background = ColorTheme.BackgroundBlack; - - _attached = true; - return _content; - } - - - public override bool Terminate() - { - if (_initilized) - { - _content = null; - - - _initilized = false; - } - return true; - } - - - /* ------------------------------------------------------------------*/ - // private variables - - private ScrollViewer _content = null; - - // connected visualization ??? - } - } - } -} diff --git a/Visualizations/Interaction/Metadata.cs b/Visualizations/Interaction/Metadata.cs index 4178dc5..536790d 100644 --- a/Visualizations/Interaction/Metadata.cs +++ b/Visualizations/Interaction/Metadata.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; + using SciChart.Charting.Model.DataSeries; @@ -13,24 +14,32 @@ */ namespace Visualizations { - namespace Interaction { - public class Metadata : SciChart.Charting.Model.DataSeries.IPointMetadata + public class MetaData : SciChart.Charting.Model.DataSeries.IPointMetadata { /* ------------------------------------------------------------------*/ // public events + /// + /// Event to indicated changed properties. + /// public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; /* ------------------------------------------------------------------*/ // public properties + /// + /// Index of the data point. + /// public int Index { get; set; } + /// + /// Flag indicating whether data point is selected or not. + /// public bool IsSelected { get @@ -55,5 +64,4 @@ public bool IsSelected private bool _selected = false; } } - } diff --git a/Visualizations/Interaction/Selection/PointSelection.cs b/Visualizations/Interaction/PointSelection.cs similarity index 60% rename from Visualizations/Interaction/Selection/PointSelection.cs rename to Visualizations/Interaction/PointSelection.cs index a62191b..6b67f9b 100644 --- a/Visualizations/Interaction/Selection/PointSelection.cs +++ b/Visualizations/Interaction/PointSelection.cs @@ -17,22 +17,32 @@ namespace Visualizations namespace Interaction { /// - /// SciChart specific + /// SciChart specific stroke palette for column plots. /// public class Selection_StrokePaletteProvider : IStrokePaletteProvider { - /* ------------------------------------------------------------------*/ // public functions + /// + /// Callback called when drawing of series begins. + /// + /// The renderable series. public void OnBeginSeriesDraw(IRenderableSeries rSeries) { } - - public Color? OverrideStrokeColor(IRenderableSeries rSeries, int index, IPointMetadata metadata) + /// + /// Callback called when strike color should be overridden. + /// + /// The renderable series. + /// The index of the data point. + /// The meta data of the data point. + /// + public Color? OverrideStrokeColor(IRenderableSeries rSeries, int index, IPointMetadata meta_data) { - return ((metadata != null) && (metadata.IsSelected)) ? _selected_stroke : _default_stroke; + return ((meta_data != null) && (meta_data.IsSelected)) ? _selected_stroke : _default_stroke; } + /* ------------------------------------------------------------------*/ // private variables @@ -41,15 +51,17 @@ public void OnBeginSeriesDraw(IRenderableSeries rSeries) { } } - /// - /// SciChart specific + /// SciChart specific Point Marker. /// public class Selection_PointMarker { /* ------------------------------------------------------------------*/ // static properties + /// + /// [STATIC] Default point marker for lines series. + /// public static SciChart.Charting.Visuals.PointMarkers.EllipsePointMarker Default { get @@ -63,17 +75,20 @@ public static SciChart.Charting.Visuals.PointMarkers.EllipsePointMarker Default } } + /// + /// [STATIC] Point marker for selected data points for lines series. + /// public static SciChart.Charting.Visuals.PointMarkers.EllipsePointMarker Selected { get { return new EllipsePointMarker() { - Stroke = Colors.Red, + Stroke = Colors.SteelBlue, StrokeThickness = 5, - Fill = Color.FromArgb(0x00, 0x00, 0x00, 0x00), - Width = 15.0, - Height = 15.0 + Fill = Colors.LightSteelBlue, // Color.FromArgb(0x00, 0x00, 0x00, 0x00), + Width = 10.0, + Height = 10.0 }; } } diff --git a/Visualizations/Management/ContentManager.cs b/Visualizations/Management/ContentManager.cs index 48b0753..d276676 100644 --- a/Visualizations/Management/ContentManager.cs +++ b/Visualizations/Management/ContentManager.cs @@ -15,6 +15,7 @@ using Visualizations.Abstracts; using Visualizations.Management; using System.Runtime.InteropServices; +using Visualizations.Interaction; @@ -28,7 +29,6 @@ namespace Management { public class ContentManager : AbstractService { - /* ------------------------------------------------------------------*/ // public functions @@ -46,19 +46,23 @@ public bool Initialize(DataManager.RequestDataCallback_Delegate request_data_cal _timer.Start(); _request_data_callback = request_data_callback; - _contents = new Dictionary>(); + + /// TODO Register new visualizations here: register_content(typeof(LogContent)); - register_content(typeof(DEBUGLines)); - register_content(typeof(DEBUGColumns)); + register_content(typeof(FilterContent)); + register_content(typeof(ScatterPlotVisualization)); + register_content(typeof(ParallelCoordinatesPlotVisualization)); + register_content(typeof(LinesVisualization)); + register_content(typeof(ColumnsVisualization)); + //register_content(typeof(...)); _timer.Stop(); _initilized = true; return _initilized; } - public override bool Terminate() { if (_initilized) @@ -84,13 +88,12 @@ public string CollectSettings() { foreach (var content_data in content_types.Value) { - settings.Add(new AbstractContent.Settings() { ContentID = content_data.Value.ID, ContentType = content_types.Key.FullName }); + settings.Add(new AbstractContent.Settings() { ID = content_data.Value.ID, Type = content_types.Key.FullName }); } } return SettingsService.Serialize>(settings); } - public bool ApplySettings(string settings) { var visualizations_settings = SettingsService.Deserialize>(settings); @@ -98,10 +101,10 @@ public bool ApplySettings(string settings) { foreach (var content_settings in visualizations_settings) { - var type = get_type(content_settings.ContentType); + var type = get_type(content_settings.Type); if (_contents.ContainsKey(type)) { - var id = content_settings.ContentID; + var id = content_settings.ID; if (id == UniqueID.Invalid) { Log.Default.Msg(Log.Level.Warn, "Invalid content id: " + id); @@ -115,14 +118,16 @@ public bool ApplySettings(string settings) { ((AbstractVisualization)new_content).SetRequestDataCallback(_request_data_callback); } + new_content.ID = id; new_content.Initialize(); new_content.Create(); + _contents[type].Add(id, new_content); } else { - Log.Default.Msg(Log.Level.Error, "Content " + content_settings.ContentType + " with ID " + id + " already exists"); + Log.Default.Msg(Log.Level.Error, "Content " + content_settings.Type + " with ID " + id + " already exists"); } } else @@ -135,10 +140,10 @@ public bool ApplySettings(string settings) return false; } - /// - /// Returns distinct list of vaild services required by the registered contents + /// Returns distinct list of valid services required by the registered contents. /// + /// List of service types. public List DependingServices() { var depending_services = new List(); @@ -175,11 +180,10 @@ public List DependingServices() return depending_services; } - /// - /// Provide necessary information of available window content - /// >> Called by WindowLeaf + /// Provide necessary information of available window content (called by window leaf). /// + /// List of available content meta data. public AvailableContentList_Type AvailableContents() { var content_ids = new AvailableContentList_Type(); @@ -198,9 +202,9 @@ public AvailableContentList_Type AvailableContents() // Create temporary instance of content var tmp_content = (AbstractContent)Activator.CreateInstance(content_type); string header = tmp_content.Name; - bool multiple_instances = tmp_content.MultipleIntances; + bool multiple_instances = tmp_content.MultipleInstances; - // Content is only available if multiple instance are allowed or has not been instanciated yet + // Content is only available if multiple instance are allowed or has not been instantiated yet bool available = (multiple_instances || (content_types.Value.IsEmpty() && !multiple_instances)); content_ids.Add(new AvailableContent_Type(header, available, multiple_instances, content_type.FullName)); @@ -209,11 +213,12 @@ public AvailableContentList_Type AvailableContents() return content_ids; } - /// - /// Attach requested content to provided parent content element. - /// >> Called by WindowLeaf + /// Attach requested content to provided parent content element (called by window leaf). /// + /// The string ID of the content if present. + /// Using string for content type to allow cross project compatibility. + /// The WPF Control element holding the actual content. public Control CreateContent(string content_id, string content_type) { if (!_initilized) @@ -240,8 +245,10 @@ public Control CreateContent(string content_id, string content_type) { ((AbstractVisualization)new_content).SetRequestDataCallback(_request_data_callback); } + new_content.Initialize(); new_content.Create(); + id = new_content.ID; _contents[type].Add(id, new_content); } @@ -256,11 +263,10 @@ public Control CreateContent(string content_id, string content_type) return null; } - /// - /// Delete content. - /// >> Called by WindowLeaf + /// Delete the content requested by id (called by window leaf). /// + /// The id of the content to be deleted. public void DeleteContent(string content_id) { // Loop over registered types @@ -278,6 +284,10 @@ public void DeleteContent(string content_id) /* ------------------------------------------------------------------*/ // private functions + /// + /// Register new content type. + /// + /// The content type. private void register_content(Type content_type) { // Check for required base type @@ -299,8 +309,15 @@ private void register_content(Type content_type) } if (valid_type) { - _contents.Add(content_type, new Dictionary()); - Log.Default.Msg(Log.Level.Info, "Registered content type: " + content_type.FullName); + if (_contents.ContainsKey(content_type)) + { + Log.Default.Msg(Log.Level.Warn, "Content type already added: " + content_type.FullName); + } + else + { + _contents.Add(content_type, new Dictionary()); + Log.Default.Msg(Log.Level.Info, "Registered content type: " + content_type.FullName); + } } else { @@ -308,7 +325,12 @@ private void register_content(Type content_type) } } - + /// + /// Check recursively for base type. + /// + /// The type to look into. + /// The base type to check for. + /// True on success, false otherwise. bool recursive_basetype(Type check_type, Type reference_base_type) { Type base_type = check_type; @@ -329,16 +351,17 @@ bool recursive_basetype(Type check_type, Type reference_base_type) return valid_base_type; } - /// - /// Convert type from string + /// Convert string to type. /// + /// The type as string. + /// The requested type, default(?) otherwise. public Type get_type(string type_string) { Type type = default(Type); try { - // Try to load type from current assmebly (supress errors -> return null on error) + // Try to load type from current assembly (suppress errors -> return null on error) type = Type.GetType(type_string); if (type == null) { @@ -357,7 +380,7 @@ public Type get_type(string type_string) /* ------------------------------------------------------------------*/ // private variables - // separate dict for each content type + // Separate dictionary for each content type private Dictionary> _contents = null; private DataManager.RequestDataCallback_Delegate _request_data_callback = null; } diff --git a/Visualizations/Management/DataManager.cs b/Visualizations/Management/DataManager.cs index 7ddd90e..914938b 100644 --- a/Visualizations/Management/DataManager.cs +++ b/Visualizations/Management/DataManager.cs @@ -22,7 +22,7 @@ namespace Visualizations namespace Management { - // data types + // Data Types public class SciChartUniformData_Type : SciChart.Charting.Model.DataSeries.UniformXyDataSeries { } public class SciChartData_Type : SciChart.Charting.Model.DataSeries.XyDataSeries { } @@ -33,7 +33,7 @@ public class DataManager : AbstractService // public delegates /// - /// Function provided by the data manager for passng on the inpout data to the visualizations + /// Function provided by the data manager for passing on the input data to the visualizations /// public delegate void InputData_Delegate(ref XYData_Type input_data); @@ -48,7 +48,6 @@ public class DataManager : AbstractService public delegate object RequestDataCallback_Delegate(Type t); - /* ------------------------------------------------------------------*/ // public functions @@ -64,7 +63,7 @@ public override bool Initialize() _data_x = new List(); _data_y = new List(); - _data_meta = new List(); + _data_meta = new List(); _library_data = new Dictionary(); // SciChart @@ -84,7 +83,6 @@ public override bool Initialize() return _initilized; } - public override bool Terminate() { bool terminated = true; @@ -113,7 +111,10 @@ public override bool Terminate() return terminated; } - + /// + /// Callback for new input data. + /// + /// Reference to the new input data. public void InputData(ref XYData_Type input_data) { _data_x.Clear(); @@ -139,9 +140,9 @@ public void InputData(ref XYData_Type input_data) _data_x.Add(y); _data_y.Add(input_data[x][y]); - var metadata = new Metadata() { Index = y, IsSelected = false }; - metadata.PropertyChanged += metadata_changed; - _data_meta.Add(metadata); + var meta_data = new MetaData() { Index = y, IsSelected = false }; + meta_data.PropertyChanged += metadata_changed; + _data_meta.Add(meta_data); } //} if ((_data_x.Count != _data_y.Count) || (_data_x.Count != _data_meta.Count) || (_data_y.Count != _data_meta.Count)) @@ -150,7 +151,6 @@ public void InputData(ref XYData_Type input_data) return; } - // Create library dependent data foreach (var data_type in _library_data) { @@ -185,19 +185,29 @@ public void InputData(ref XYData_Type input_data) Log.Default.Msg(Log.Level.Debug, "... done."); } - + /// + /// Set the callback to provide new output data to the interface. + /// + /// public void SetOutputDataCallback(OutputData_Delegate outputdata_callback) { _outputdata_callback = outputdata_callback; } - + /// + /// Callback for visualizations to ask for library specific data. + /// + /// The callback for requesting data. public RequestDataCallback_Delegate GetRequestDataCallback() { return request_data; } - + /// + /// Return the data for the requested type. + /// + /// The type the data would be required. + /// The data as generic object. Cast to requested type manually. private object request_data(Type t) { if (!_initilized) @@ -217,10 +227,14 @@ private object request_data(Type t) return null; } - + /// + /// Callback provided for getting notified on changed meta data + /// + /// The sender object. + /// The property changed event arguments. private void metadata_changed(object sender, PropertyChangedEventArgs e) { - var sender_selection = sender as Metadata; + var sender_selection = sender as MetaData; if ((sender_selection == null) || (e.PropertyName != "IsSelected")) { return; @@ -273,7 +287,7 @@ private void metadata_changed(object sender, PropertyChangedEventArgs e) private OutputData_Delegate _outputdata_callback = null; private List _data_x = null; private List _data_y = null; - private List _data_meta = null; + private List _data_meta = null; private Dictionary _library_data = null; } } diff --git a/Visualizations/Management/ServiceManager.cs b/Visualizations/Management/ServiceManager.cs index 7d82e3d..dfaa4fb 100644 --- a/Visualizations/Management/ServiceManager.cs +++ b/Visualizations/Management/ServiceManager.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using Core.Utilities; using Core.Abstracts; -using EntityFrameworkDatabase; using Visualizations.SciChartInterface; @@ -21,7 +20,10 @@ public class ServiceManager : AbstractService /* ------------------------------------------------------------------*/ // public functions - + /// + /// Add new service. + /// + /// The service object. public void AddService(AbstractService service) { if (_services == null) @@ -37,11 +39,10 @@ public void AddService(AbstractService service) } else { - Log.Default.Msg(Log.Level.Warn, "Service was already added: " + service_type.FullName); + Log.Default.Msg(Log.Level.Warn, "Service has already been added: " + service_type.FullName); } } - public override bool Initialize() { if (_initilized) @@ -64,7 +65,6 @@ public override bool Initialize() return _initilized; } - public override bool Terminate() { bool terminated = true; diff --git a/Visualizations/Types/Other/DEBUGColumns.cs b/Visualizations/Types/ColumnsVisualization.cs similarity index 96% rename from Visualizations/Types/Other/DEBUGColumns.cs rename to Visualizations/Types/ColumnsVisualization.cs index 1671ce2..743b9ad 100644 --- a/Visualizations/Types/Other/DEBUGColumns.cs +++ b/Visualizations/Types/ColumnsVisualization.cs @@ -32,20 +32,19 @@ /* - * Test Visualization + * Visualization: Columns (Bar Chart) (2D) * */ namespace Visualizations { namespace Types { - public class DEBUGColumns : AbstractSciChart + public class ColumnsVisualization : AbstractSciChart { - /* ------------------------------------------------------------------*/ // properties - public override string Name { get { return "DEBUG Columns"; } } + public override string Name { get { return "Columns (2D)"; } } /* ------------------------------------------------------------------*/ @@ -53,7 +52,7 @@ public class DEBUGColumns : AbstractSciChart public override bool Create() { - if (!_initilized) + if (!_initialized) { Log.Default.Msg(Log.Level.Error, "Initialization required prior to execution"); return false; @@ -70,9 +69,10 @@ public override bool Create() } _timer.Start(); + _content.Padding = new Thickness(0.0, 0.0, 0.0, 0.0); _content.BorderThickness = new Thickness(0.0, 0.0, 0.0, 0.0); - _content.ZoomExtents(); + // Data Series ------------------------------------- var render_series = new FastColumnRenderableSeries(); @@ -104,9 +104,7 @@ public override bool Create() { render_series.DataSeries = data; } - _content.RenderableSeries.Add(render_series); - _content.ZoomExtents(); @@ -173,7 +171,6 @@ public override bool Create() _created = true; return _created; } - } } } diff --git a/Visualizations/Types/Other/DEBUGLines.cs b/Visualizations/Types/LinesVisualization.cs similarity index 96% rename from Visualizations/Types/Other/DEBUGLines.cs rename to Visualizations/Types/LinesVisualization.cs index bf0b937..2609d99 100644 --- a/Visualizations/Types/Other/DEBUGLines.cs +++ b/Visualizations/Types/LinesVisualization.cs @@ -31,20 +31,19 @@ /* - * Test Visualization + * Visualization: Lines (2D) * */ namespace Visualizations { namespace Types { - public class DEBUGLines : AbstractSciChart + public class LinesVisualization : AbstractSciChart { - /* ------------------------------------------------------------------*/ // properties - public override string Name { get { return "DEBUG Lines"; } } + public override string Name { get { return "Lines (2D)"; } } /* ------------------------------------------------------------------*/ @@ -52,7 +51,7 @@ public class DEBUGLines : AbstractSciChart public override bool Create() { - if (!_initilized) + if (!_initialized) { Log.Default.Msg(Log.Level.Error, "Initialization required prior to execution"); return false; @@ -69,9 +68,11 @@ public override bool Create() } _timer.Start(); + _content.Padding = new Thickness(0.0, 0.0, 0.0, 0.0); _content.BorderThickness = new Thickness(0.0, 0.0, 0.0, 0.0); + // Data Series ------------------------------------- var render_series = new FastLineRenderableSeries(); render_series.Name = "line_series_" + ID; @@ -94,7 +95,6 @@ public override bool Create() render_series.DataSeries = data; } _content.RenderableSeries.Add(render_series); - _content.ZoomExtents(); diff --git a/Visualizations/Types/ParallelCoordinatesPlotVisualization.cs b/Visualizations/Types/ParallelCoordinatesPlotVisualization.cs new file mode 100644 index 0000000..e18d45c --- /dev/null +++ b/Visualizations/Types/ParallelCoordinatesPlotVisualization.cs @@ -0,0 +1,86 @@ +using System; +using Core.Abstracts; +using System.Windows.Controls; +using System.Windows.Media; +using System.Collections.Generic; +using Visualizations.SciChartInterface; +using System.Windows; +using Core.Utilities; +using System.Runtime.Remoting.Contexts; +using SciChart.Charting.Visuals; +using SciChart.Charting.Visuals.Annotations; +using SciChart.Charting.Visuals.Axes; +using SciChart.Charting.Model.DataSeries; +using SciChart.Drawing; +using SciChart.Core; +using SciChart.Data; +using System.Windows.Data; +using SciChart.Charting.Visuals.RenderableSeries; +using SciChart.Charting.Visuals.RenderableSeries.Animations; +using SciChart.Charting.Model.ChartSeries; +using System.ComponentModel; +using System.Linq; +using SciChart.Charting.Visuals.PointMarkers; +using System.Windows.Input; +using Visualizations.Abstracts; +using Visualizations.Interaction; +using Visualizations.Management; +using SciChart.Charting.ChartModifiers; +using SciChart.Core.Utility.Mouse; + + +/* + * Visualization: Parallel Coordinates Plot (2D) + * + */ +namespace Visualizations +{ + namespace Types + { + public class ParallelCoordinatesPlotVisualization : AbstractSciChartParallel + { + /* ------------------------------------------------------------------*/ + // properties + + public override string Name { get { return "Parallel Coordinates Plot (2D)"; } } + + + /* ------------------------------------------------------------------*/ + // public functions + + public override bool Create() + { + if (!_initialized) + { + Log.Default.Msg(Log.Level.Error, "Initialization required prior to execution"); + return false; + } + if (_created) + { + Log.Default.Msg(Log.Level.Warn, "Content already created, skipping..."); + return false; + } + if (_request_data_callback == null) + { + Log.Default.Msg(Log.Level.Error, "Missing request data callback"); + return false; + } + _timer.Start(); + + _content.Padding = new Thickness(0.0, 0.0, 0.0, 0.0); + _content.BorderThickness = new Thickness(0.0, 0.0, 0.0, 0.0); + _content.ZoomExtents(); + + + + + + + + _timer.Stop(); + _created = true; + return _created; + } + } + } +} diff --git a/Visualizations/Types/ScatterPlotVisualization.cs b/Visualizations/Types/ScatterPlotVisualization.cs new file mode 100644 index 0000000..fe3d17e --- /dev/null +++ b/Visualizations/Types/ScatterPlotVisualization.cs @@ -0,0 +1,159 @@ +using System; +using Core.Abstracts; +using System.Windows.Controls; +using System.Windows.Media; +using System.Collections.Generic; +using Visualizations.SciChartInterface; +using System.Windows; +using Core.Utilities; +using System.Runtime.Remoting.Contexts; +using SciChart.Charting.Visuals; +using SciChart.Charting.Visuals.Annotations; +using SciChart.Charting.Visuals.Axes; +using SciChart.Charting.Model.DataSeries; +using SciChart.Drawing; +using SciChart.Core; +using SciChart.Data; +using System.Windows.Data; +using SciChart.Charting.Visuals.RenderableSeries; +using SciChart.Charting.Visuals.RenderableSeries.Animations; +using SciChart.Charting.Model.ChartSeries; +using System.ComponentModel; +using System.Linq; +using SciChart.Charting.Visuals.PointMarkers; +using System.Windows.Input; +using Visualizations.Abstracts; +using Visualizations.Interaction; +using Visualizations.Management; +using SciChart.Charting.ChartModifiers; +using SciChart.Core.Utility.Mouse; + + + +/* + * Visualization: Scatter Plot Matrices (SPLOM) (2D) + * + */ +namespace Visualizations +{ + namespace Types + { + public class ScatterPlotVisualization : AbstractSciChart + { + /* ------------------------------------------------------------------*/ + // properties + + public override string Name { get { return "Scatter Plot (2D)"; } } + + + /* ------------------------------------------------------------------*/ + // public functions + + public override bool Create() + { + if (!_initialized) + { + Log.Default.Msg(Log.Level.Error, "Initialization required prior to execution"); + return false; + } + if (_created) + { + Log.Default.Msg(Log.Level.Warn, "Content already created, skipping..."); + return false; + } + if (_request_data_callback == null) + { + Log.Default.Msg(Log.Level.Error, "Missing request data callback"); + return false; + } + _timer.Start(); + + + _content.Padding = new Thickness(0.0, 0.0, 0.0, 0.0); + _content.BorderThickness = new Thickness(0.0, 0.0, 0.0, 0.0); + + + // Data Series ------------------------------------- + var render_series = new XyScatterRenderableSeries(); + render_series.Name = "scatter_series_" + ID; + render_series.Stroke = Colors.Aquamarine; + render_series.StrokeThickness = 2; + render_series.PointMarker = Selection_PointMarker.Default; + render_series.SelectedPointMarker = Selection_PointMarker.Selected; + + var data = (SciChartUniformData_Type)_request_data_callback(typeof(SciChartUniformData_Type)); + if (data != null) + { + render_series.DataSeries = data; + } + _content.RenderableSeries.Add(render_series); + _content.ZoomExtents(); + + + // Axis -------------------------------------------- + var xAxis = new NumericAxis() + { + AxisTitle = "Sample No", + GrowBy = new SciChart.Data.Model.DoubleRange(0.2, 0.2), + DrawMajorBands = false + }; + _content.XAxis = xAxis; + + var yAxis = new NumericAxis() + { + AxisTitle = "Value", + GrowBy = new SciChart.Data.Model.DoubleRange(0.2, 0.2), + DrawMajorBands = false, + }; + _content.YAxis = yAxis; + + + // Modifiers --------------------------------------- + _content.ChartModifier = new SciChart.Charting.ChartModifiers.ModifierGroup( + new SciChart.Charting.ChartModifiers.RubberBandXyZoomModifier() + { + IsEnabled = false + }, + new SciChart.Charting.ChartModifiers.ZoomExtentsModifier() + { + IsEnabled = false + }, + new SciChart.Charting.ChartModifiers.ZoomPanModifier() + { + IsEnabled = true, + ExecuteOn = SciChart.Charting.ChartModifiers.ExecuteOn.MouseRightButton, + ClipModeX = SciChart.Charting.ClipMode.None + }, + new SciChart.Charting.ChartModifiers.MouseWheelZoomModifier() + { + IsEnabled = true, + ActionType = SciChart.Charting.ActionType.Zoom, + XyDirection = SciChart.Charting.XyDirection.XYDirection + }, + new SciChart.Charting.ChartModifiers.DataPointSelectionModifier() + { + IsEnabled = true + } + ); + + + // Annotation -------------------------------------- + var textAnnotation = new TextAnnotation() + { + Text = "|----------[Interaction]----------|" + Environment.NewLine + + "Left Mouse: Select/Box-Select" + Environment.NewLine + + "Mouse Wheel: Zoom" + Environment.NewLine + + "Right Mouse: Pan", + X1 = 6.0, + Y1 = 9.0 + }; + _content.Annotations.Add(textAnnotation); + + + _timer.Stop(); + _created = true; + return _created; + } + } + } +} diff --git a/Visualizations/VisualizationManager.cs b/Visualizations/VisualizationManager.cs index 30faa35..09c011c 100644 --- a/Visualizations/VisualizationManager.cs +++ b/Visualizations/VisualizationManager.cs @@ -11,7 +11,6 @@ using Microsoft.Owin.Hosting; using Core.Utilities; using Core.Abstracts; -using EntityFrameworkDatabase; using System.Windows.Controls; using Visualizations.Types; using Core.GUI; @@ -37,7 +36,6 @@ public VisualizationManager() _datamanager = new DataManager(); } - public override bool Initialize() { if (_initilized) @@ -68,7 +66,6 @@ public override bool Initialize() return _initilized; } - public override bool Terminate() { bool terminated = true; @@ -82,19 +79,16 @@ public override bool Terminate() return terminated; } - public string CollectSettings() { return _contentmanager.CollectSettings(); } - public bool ApplySettings(string settings) { return _contentmanager.ApplySettings(settings); } - public ContentCallbacks_Type GetContentCallbacks() { return new ContentCallbacks_Type(_contentmanager.AvailableContents, _contentmanager.CreateContent, _contentmanager.DeleteContent); diff --git a/Visualizations/Visualizations.csproj b/Visualizations/Visualizations.csproj index 9afb5c2..2adf70b 100644 --- a/Visualizations/Visualizations.csproj +++ b/Visualizations/Visualizations.csproj @@ -116,16 +116,19 @@ + - - - + + + - - + + + + @@ -133,20 +136,12 @@ - - - - - + {8da3258e-49cf-483f-a100-3a12304bde0e} Core - - {25e78628-3abc-441b-b8c3-1b4e451cad2b} - EntityFrameworkDatabase - {1233eab1-db38-4264-830a-a40fc694d44d} PythonInterface diff --git a/WPFApplication/App.config b/WPFApplication/App.config index 247e98f..c4a2696 100644 --- a/WPFApplication/App.config +++ b/WPFApplication/App.config @@ -1,15 +1,6 @@  - - - -
- - - - - @@ -42,11 +33,5 @@ - - - - - - - + \ No newline at end of file diff --git a/WPFApplication/MainWindow.xaml.cs b/WPFApplication/MainWindow.xaml.cs index e3862da..79c79e9 100644 --- a/WPFApplication/MainWindow.xaml.cs +++ b/WPFApplication/MainWindow.xaml.cs @@ -11,16 +11,12 @@ using Core.GUI; using Visualizations.Types; using Visualizations.Management; -using static Core.GUI.SettingsService; /* * Main WPF Application * - * - * Interaction logic for MainWindow.xaml - * */ namespace Frontend { @@ -33,7 +29,7 @@ public partial class MainWindow : Window // public delegates /// - /// Function provided by the interface (= Grasshopper) which allows to trigger relaoding of the interface + /// Function provided by the interface (= Grasshopper) which allows to trigger reloading of the interface /// public delegate void ReloadInterface_Delegate(); @@ -42,11 +38,15 @@ public partial class MainWindow : Window // public functions /// - /// Used for detached execution - /// that use the old ID will partially fail during loading. + /// Ctor. Used for detached execution. /// public MainWindow() : this("[detached] Visualization Framework for Grasshopper (VisFroG)", true) { } + /// + /// Ctor. + /// + /// + /// public MainWindow(string app_name, bool detached = false) { /// DEBUG get C# version, see compile output (C# Language Version 7.3) @@ -58,7 +58,9 @@ public MainWindow(string app_name, bool detached = false) create(); } - + /// + /// Dtor. + /// ~MainWindow() { _settingsservice.Terminate(); @@ -67,28 +69,28 @@ public MainWindow(string app_name, bool detached = false) _menubar.Terminate(); } - /// /// Callback to trigger reloading the interface (= Grasshopper). /// + /// Reload callback provided by the interface. public void SetReloadInterface(ReloadInterface_Delegate reload_callback) { _reloadinterface_callback = reload_callback; } - /// /// Callback to pass output data to the interface (= Grasshopper). /// + /// callback from the DataManager to pipe new output data to the interface. public void SetOutputDataCallback(DataManager.OutputData_Delegate output_data_callback) { _vismanager.SetOutputDataCallback(output_data_callback); } - /// /// Get input data from interface (= Grasshopper). /// + /// Reference to the input data hold by the interface. public void InputData(ref XYData_Type input_data) { if (_inputdata_callback != null) @@ -109,6 +111,7 @@ public void InputData(ref XYData_Type input_data) /// Soft close is used when called from interface (= Grasshopper), see CTOR /// Only change visibility and abort closing for being able to restore closed window /// + /// Cancel event arguments protected override void OnClosing(CancelEventArgs cancel_args) { if (_soft_close) @@ -126,6 +129,11 @@ protected override void OnClosing(CancelEventArgs cancel_args) /* ------------------------------------------------------------------*/ // private functions + /// + /// Initialize the main WPF window, the services and the managers... + /// + /// The name of the WPF application. + /// True on successful initialization, false otherwise. public bool initialize(string app_name) { if (_initilized) @@ -160,6 +168,7 @@ public bool initialize(string app_name) // Register additional callbacks + /// Do not reorder since applying settings might be order dependent! _settingsservice.RegisterSettings(_vismanager.Name, _vismanager.CollectSettings, _vismanager.ApplySettings); _settingsservice.RegisterSettings(_winmanager.Name, _winmanager.CollectSettings, _winmanager.ApplySettings); @@ -167,6 +176,7 @@ public bool initialize(string app_name) // Get callbacks _inputdata_callback = _vismanager.GetInputDataCallback(); + _timer.Stop(); _initilized = initilized; if (_initilized) @@ -176,7 +186,10 @@ public bool initialize(string app_name) return _initilized; } - + /// + /// Create the WPF content of the application. + /// + /// True on successful creation of the content, false otherwise public bool create() { if (!_initilized) @@ -214,19 +227,21 @@ public bool create() return true; } - /// /// Callback additionally invoked on loading of main window. /// + /// Sender object. + /// Routed event arguments. private void on_loaded(object sender, RoutedEventArgs routedEventArgs) { // so far unused ... } - /// - /// Callback invoked once per frame + /// Callback invoked once per frame. /// + /// Sender object. + /// Event arguments. private void once_per_frame(object sender, EventArgs args) { // so far unused ... diff --git a/WPFApplication/WPFApplication.csproj b/WPFApplication/WPFApplication.csproj index 2d91375..bf9d5f0 100644 --- a/WPFApplication/WPFApplication.csproj +++ b/WPFApplication/WPFApplication.csproj @@ -1,6 +1,5 @@  - Debug @@ -72,12 +71,6 @@ Always - - ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll - - - ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll - ..\packages\Microsoft.Owin.4.2.2\lib\net45\Microsoft.Owin.dll @@ -172,14 +165,6 @@ - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - robocopy "$(SolutionDir)resources" "$(ProjectDir)$(OutDir)resources" /E if %25errorlevel%25 leq 3 exit 0 else exit %25errorlevel%25 diff --git a/WPFApplication/packages.config b/WPFApplication/packages.config index 4d31575..7d3d5b2 100644 --- a/WPFApplication/packages.config +++ b/WPFApplication/packages.config @@ -1,6 +1,5 @@  - diff --git a/WebAPI/Controllers/RequestController.cs b/WebAPI/Controllers/RequestController.cs index 11d3558..2ed623d 100644 --- a/WebAPI/Controllers/RequestController.cs +++ b/WebAPI/Controllers/RequestController.cs @@ -16,7 +16,6 @@ namespace WebAPI { namespace Controllers { - [RoutePrefix("api/request")] public class RequestController : ApiController { @@ -24,6 +23,9 @@ public class RequestController : ApiController /* ------------------------------------------------------------------*/ // public functions + /// + /// Ctor. + /// public RequestController() { _requests = new Request[] @@ -34,14 +36,21 @@ public RequestController() }; } - + /// + /// Answer all available requests. + /// + /// Enumerated requests. [Route("")] public IEnumerable GetAllRequests() { return _requests; } - + /// + /// Answer request by ID. + /// + /// The ID of the request. + /// The requested request. [Route("{id:int}")] [ResponseType(typeof(Request))] public IHttpActionResult GetRequest(int id) @@ -54,19 +63,29 @@ public IHttpActionResult GetRequest(int id) return Ok(request); } - + /// + /// Post request. + /// + /// // POST api/request public void Post([FromBody] string value) { } - + /// + /// Put request. + /// + /// + /// // PUT api/values/5 public void Put(int id, [FromBody] string value) { } - + /// + /// Delete request. + /// + /// // DELETE api/values/5 public void Delete(int id) { @@ -74,7 +93,7 @@ public void Delete(int id) /* ------------------------------------------------------------------*/ - // private varaiables + // private variables /// DEBUG private Request[] _requests = null; diff --git a/WebAPI/Models/Request.cs b/WebAPI/Models/Request.cs index a198043..e6a0694 100644 --- a/WebAPI/Models/Request.cs +++ b/WebAPI/Models/Request.cs @@ -18,10 +18,15 @@ public class Request /* ------------------------------------------------------------------*/ // public variables + /// + /// Request ID (DEBUG) + /// public int Id { get; set; } + /// + /// Request name (DEBUG) + /// public string Name { get; set; } - } } } diff --git a/WebAPI/StartUp.cs b/WebAPI/StartUp.cs index 4ed49c2..b6fcc60 100644 --- a/WebAPI/StartUp.cs +++ b/WebAPI/StartUp.cs @@ -21,6 +21,7 @@ public class StartUp /// This code configures Web API. /// The Startup class is specified as a type parameter in the WebApp.Start method. /// + /// The app builder. public void Configuration(IAppBuilder appBuilder) { // Configure Web API for self-host. diff --git a/WebAPI/WebAPIService.cs b/WebAPI/WebAPIService.cs index a610044..320341b 100644 --- a/WebAPI/WebAPIService.cs +++ b/WebAPI/WebAPIService.cs @@ -12,7 +12,6 @@ */ /* TEST Execute: - bool received_response = false; var response = _client.GetAsync(_base_address + "api/request").Result; if (response != null) @@ -63,7 +62,6 @@ public override bool Initialize() return _initilized; } - public override bool Terminate() { if (_initilized)