Skip to content

Commit

Permalink
first version of independent data manipulation via UI
Browse files Browse the repository at this point in the history
(= transpose generic data)
  • Loading branch information
braunms committed May 16, 2024
1 parent 1336f8c commit 87a5b4c
Show file tree
Hide file tree
Showing 32 changed files with 552 additions and 467 deletions.
13 changes: 10 additions & 3 deletions Core/Abstracts/AbstractDataType.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;

using System.Windows.Controls;
using Core.Data;
using Core.GUI;
using Core.Utilities;


Expand Down Expand Up @@ -39,7 +40,13 @@ public AbstractDataType(PropertyChangedEventHandler update_metadata_handler, Pro

public abstract void UpdateMetaDataEntry(IMetaData updated_meta_data);

protected bool CompatibleTypes(List<Type> value_types)
public abstract List<MenuItem> GetMenu();


/* ------------------------------------------------------------------*/
// protected functions

protected bool compatible_types(List<Type> value_types)
{
bool incompatible = false;
foreach (Type t in value_types)
Expand All @@ -56,7 +63,7 @@ protected bool CompatibleTypes(List<Type> value_types)
return !incompatible;
}

protected bool CompatibleDimensionality(uint data_dimension)
protected bool compatible_dimensionality(uint data_dimension)
{
bool compatible = false;
foreach (Dimension dim in _SupportedDimensions)
Expand Down
146 changes: 146 additions & 0 deletions Core/Abstracts/AbstractMenuBar.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
using System.Windows;
using System.Windows.Controls;
using Core.Utilities;
using System.Windows.Documents;
using System;
using System.Windows.Navigation;
using System.Collections.Generic;
using static Core.GUI.MainMenuBar;



/*
* Abstract Menu Bar
*
*/
namespace Core
{
namespace GUI
{
public abstract class AbstractMenuBar<EnumOptionType> where EnumOptionType : Enum
{
/* ------------------------------------------------------------------*/
// public delegate

public delegate bool MenuCallback_Delegate();


/* ------------------------------------------------------------------*/
// static functions

public static MenuItem GetDefaultMenuItem(string name, MenuCallback_Delegate callback = null)
{
var menu_item = new MenuItem();
menu_item.Header = name;
menu_item.Name = "menu_item_" + UniqueID.GenerateString();
if (callback != null)
{
menu_item.Click += (object sender, RoutedEventArgs e) =>
{
var sender_content = sender as MenuItem;
if (sender_content == null)
{
return;
}
callback();
};
}
menu_item.Style = ColorTheme.MenuItemIconStyle();
return menu_item;
}


/* ------------------------------------------------------------------*/
// public functions

public virtual bool Initialize()
{
if (_initialized)
{
Terminate();
}
_initialized = false;

_content = new Menu();
_content.Style = ColorTheme.MainMenuBarStyle();

_main_menu_items = new Dictionary<EnumOptionType, MenuItem>();

_initialized = true;
return _initialized;
}

public Control Attach()
{
if (!_initialized)
{
Log.Default.Msg(Log.Level.Error, "Initialization required prior to execution");
return null;
}

_content.Items.Clear();
foreach (var main_menu_item in _main_menu_items)
{
_content.Items.Add(main_menu_item.Value);
}
return _content;
}

public void AddSeparator(EnumOptionType main_option)
{
_main_menu_items[main_option].Items.Add(new Separator());
}

public void AddMenu(EnumOptionType main_option, MenuItem menu_item)
{
_main_menu_items[main_option].Items.Add(menu_item);
_main_menu_items[main_option].IsEnabled = true;
}

public void Clear(EnumOptionType main_option)
{
_main_menu_items[main_option].Items.Clear();
}

public bool Terminate()
{
if (_initialized)
{
_main_menu_items.Clear();
_main_menu_items = null;

_content.Items.Clear();
_content = null;

_initialized = false;
}
return true;
}


/* ------------------------------------------------------------------*/
// protected functions

protected void add_main_menu(string name, EnumOptionType enum_option)
{
var main_menu_item = new MenuItem();
main_menu_item.Header = name;
main_menu_item.IsEnabled = false;
_main_menu_items.Add(enum_option, main_menu_item);
}


/* ------------------------------------------------------------------*/
// protected variables

protected bool _initialized = false;


/* ------------------------------------------------------------------*/
// private variables

private Menu _content = null;
private Dictionary<EnumOptionType, MenuItem> _main_menu_items = null;
}
}
}
4 changes: 2 additions & 2 deletions Core/Abstracts/AbstractService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class AbstractService


/* ------------------------------------------------------------------*/
// public functions
// protected functions

protected AbstractService()
{
Expand Down Expand Up @@ -75,7 +75,7 @@ public virtual bool Initialize()
}
*/

public virtual void AttachMenu(MenuBar menu_bar)
public virtual void AttachMenu(MainMenuBar menu_bar)
{
throw new InvalidOperationException("This function has been called for derived class of AbstractService that does not implement this function");
}
Expand Down
Loading

0 comments on commit 87a5b4c

Please sign in to comment.