Re-Sorting treeview Nodes[0] only after being populated - c#

I have the following tree:
Animals
|
|___Zebra
| |__Head
| |__Arms
| |__Legs
|
|___Monkey
|__Head
|__Arms
|__Legs
Each animal has an ID number stored in the Tag field and their name is in Name field of node.I want to press a button that says "Sort by ID" and have the "Zebra" above turn into "14" etc, and then resort numerically. However, I want the children to stay with the head, arms, legs order. When I use the following code, it works, but it also re-sorts the head arms legs into arms, head, legs. I've tried a NodeSorter, but I just didn't get any different results. I'm also very new to C# so I might have implemented it incorrectly. :) I'm also using a custom node with a few extra fields to store data and boolean values. That's what the "JacksNode" refers to below.
Here's the code:
public static void sortByAnimalID(TreeView tv)
{
tv.BeginUpdate();
foreach (TreeNode treeNode in tv.Nodes[0].Nodes)
{
if (((JacksNode)treeNode).IsAnimal)
{
treeNode.Text = Convert.ToString(treeNode.Tag);
treeNode.Name = Convert.ToString(treeNode.Tag);
}
}
tv.Sort();
tv.EndUpdate();
}
Any ideas on what I'm doing wrong? I've searched the web for two weeks and have been overwhelmed with all the treeview articles. However, none have been this specific.
Thanks guys/gals for any suggestions.

Use the TreeNode.Level property to figure out how to compare node properties. Like this:
private void SortButton_Click(object sender, EventArgs e) {
if (treeView1.TreeViewNodeSorter == null) {
treeView1.TreeViewNodeSorter = new NodeSorter();
}
}
private class NodeSorter : System.Collections.IComparer {
public int Compare(object x, object y) {
TreeNode node1 = (TreeNode)x;
TreeNode node2 = (TreeNode)y;
if (node1.Level == 1) {
return Convert.ToInt32(node1.Tag).CompareTo(Convert.ToInt32(node2.Tag));
}
else {
return node1.Index.CompareTo(node2.Index);
}
}
}

//bubble sort
public void Sort_TV_ByTag(TreeNodeCollection treeNodeCollection)
{
int i, j;
int n = treeNodeCollection.Count;
for (i = 0; i < n; i++)
{
for (j = 1; j < (n - i); j++)
{
int firstValue = int.Parse(treeNodeCollection[j - 1].Tag.ToString());
int secondValue = int.Parse(treeNodeCollection[j].Tag.ToString());
//you can compare by Tag , Text , anything
if (firstValue > secondValue)
{
//swap the nodes
TreeNode n1 = treeNodeCollection[j - 1];
TreeNode n2 = treeNodeCollection[j];
treeNodeCollection.Remove(n1);
treeNodeCollection.Remove(n2);
treeNodeCollection.Insert(j, n1);
treeNodeCollection.Insert(j - 1, n2);
}
}
}
}
private void button1_Click(object sender, EventArgs e)
{
Sort_TV_ByTag(treeView1.Nodes[0].Nodes);
}

Related

Trying to select from a list the first previous eligible index

I have a List<List<Object>> in which one of these objects has the property isCurrentlySelected = true. This nested list represents a grid of these objects that might be constructed in any configuration (i.e. the grid may be any dimensions, and may even be jagged).
Now, some of these objects have the property isSelectable = false, so I'm trying to create a method which takes a single parameter for "direction" and returns the first eligible index in the specified direction from the one currently marked as selected.
So far I've only been able to do this using several nested for loops and if-else statements, and even then, it will only work for one direction. I'm wondering if there's a more elegant way to check for the first eligible element, preferably using a single method.
Thanks in advance for any help,
~KWiP
EDIT: with code sample
So I have the Menu class:
public class Menu
{
public int x;
public int y;
public int width;
public int height;
public int lineHeight;
public float menuTimer = 0.0f;
public bool menuKeysPressed = false;
public List<List<Selection>> selections = new List<List<Selection>>();
public int selectedList = 0;
public int selectedItem = 0;
in which is the child class Selection:
public class Selection
{
public int x;
public int y;
public bool isCurrentlySelected = false;
public bool isSelectable = true;
public Color selectedColor = Color.White;
public Color unselectedColor = Color.Gray;
public bool isNonText = false;
public string displayText = "";
public int textSize;
public Selection(int xPos, int yPos, string text, int size, bool selectable)
{
x = xPos;
y = yPos;
displayText = text;
textSize = size;
if (!selectable)
{
isCurrentlySelected = false;
}
}
}
Each Selection in a Menu object has X and Y coordinates in the form of its indices in the nested lists found in Menu.selections. In each Menu, there is typically exactly one Selection with its isCurrentlySelected property set to true.
public Menu(int xPos, int yPos, int wdth, int hght, int lists = 0, int items = 0, bool allSelectable = true)
{
x = xPos;
y = yPos;
width = wdth;
height = hght;
if (items > 0 && lists <= 0)
{
lists = 1;
}
for (int i = 0; i < lists; i++)
{
selections.Add(new List<Selection>());
for (int j = 0; j < items; j++)
{
selections.ElementAt(i).Add(new Selection(((wdth / items) * j) + xPos, ((hght / lists) * i) + yPos, "", 20, allSelectable));
}
}
if (items > 0)
{
selections.ElementAt(0).ElementAt(0).isCurrentlySelected = true;
}
}
Now, within the Menu class, I'm trying to make a method which will deselect the currently selected index, and then select the next closest eligible index in a particular direction, wrapping around to the other side if the end of the range of indices is reached. Unfortunately, all I've been able to come up with is this mess, which currently only works going North, and would need to be expanded to roughly 4x its size to accommodate all directions.
public void nav(Point currentSelected, int dir) // The 4 cardinal directions are represented by an int: 0 for North and continuing clockwise from there.
{
int newRow = currentSelected.Y;
int newIndex = currentSelected.X;
switch (dir)
{
case 0: // Operations to select next eligible N index.
if (this.selections.Count <= 1)
{
return;
}
else
{
int firstOpenRow = this.selections.Count;
for (int i = 0; i < this.selections.Count; i++)
{
int difference = i - currentSelected.Y;
if (difference > 0 && difference < firstOpenRow && this.selections.ElementAt(i).ElementAt(currentSelected.X).isSelectable == true)
{
firstOpenRow = i;
}
}
if (firstOpenRow == this.selections.Count)
{
for (int i = 0; i < this.selections.Count; i++)
{
int difference = i - currentSelected.Y;
if (difference < 0 && difference < firstOpenRow && this.selections.ElementAt(i).ElementAt(currentSelected.X).isSelectable == true)
{
firstOpenRow = i;
}
}
if (firstOpenRow == this.selections.Count)
{
firstOpenRow = currentSelected.Y;
}
}
this.selections.ElementAt(currentSelected.Y).ElementAt(currentSelected.X).isCurrentlySelected = false;
this.selections.ElementAt(firstOpenRow).ElementAt(currentSelected.X).isCurrentlySelected = true;
}
break;
case 1:
// Add operations for E here
break;
case 2:
// Add operations for S here
break;
case 3:
// Add operations for W here
break;
}
}
Your choice of data-structure isn't really well made for the kind of queries you need to make. Maybe you should consider investing a little more time into creating a linked grid. Something like:
class Item
{
Item North { get; private set; }
Item South { get; private set; }
Item West { get; private set; }
Item East { get; private set; }
}
Like that, if you look for the next 'left' item, you can just go West until you either reach null or you encounter an item that is selectable.
Otherwise, it makes sense to distinguish between the different kinds of directions. Just because you have less code doesn't mean your program runs faster. Think of your algorithm in terms of how many operations you have to make to reach your goal, instead of how long it is.
Sorry if that's not the answer your're looking for.

c# - ArgumentOutOfRangeException: Index was out of range - 2 Forms

Problem solved.
The original "private void buttonSave_Click" was changed to:
private void buttonSave_Click(object sender, EventArgs e)
{
if (MusicCollection.FormMain.PublicVars.AlbumList.Count != 100)
{
MusicCollection.FormMain.PublicVars.AlbumList.Add(new Album(NameTextBox.Text));
MessageBox.Show("New Album added: " + NameTextBox.Text);
formMain.ListAlbums(formMain.AlbumsListBox.Items);
this.Close();
}
else
{
MessageBox.Show("No room for new album.");
this.Close();
}
}
Original Post:
I'm new to using C#, so appologies for any seemly obvious mistakes or terrible coding.
I'm trying to create a new Album object (that gets its Name from NameTextBox.Text on Form FormAlbumAC) and add it to List AlbumList when the user clicks the save button on FormAlbumAC. Then I want to list all of AlbumList in a ListBox on Form FormMain.
When I run the program and click the save button, I'm getting the error "ArgumentOutOfRangeException was unhandled, Index was out of range" at the line:
if (MusicCollection.FormMain.PublicVars.AlbumList[i] == null)
// line 8 on my excerpt from Form FormAblumAC
I'm not sure what I'm doing wrong. Any help would be much appreciated, thank you.
Form FormMain:
public const int MAX_ALBUMS = 100;
public int totalAlbums = 0;
public FormMain()
{
InitializeComponent();
}
public static class PublicVars
{
public static List<Album> AlbumList { get; set; }
static PublicVars()
{
AlbumList = new List<Album>(MAX_ALBUMS);
}
}
public ListBox AlbumListBox
{
get
{
return AlbumListBox;
}
}
public void ListAlbums(IList list)
{
list.Clear();
foreach (var album in PublicVars.AlbumList)
{
if (album == null)
continue;
list.Add(album.Name);
}
}
Form FormAlbumAC:
private FormMain formMain;
private void buttonSave_Click(object sender, EventArgs e)
{
int index = -1;
for (int i = 0; i < MusicCollection.FormMain.MAX_ALBUMS; ++i)
{
if (MusicCollection.FormMain.PublicVars.AlbumList[i] == null)
{
index = i;
break;
}
}
if (index != -1)
{
MusicCollection.FormMain.PublicVars.AlbumList[index] = new Album(NameTextBox.Text);
++formMain.totalAlbums;
MessageBox.Show("New Album added: " + NameTextBox.Text);
formMain.ListAlbums(formMain.AlbumsListBox.Items);
this.Close();
}
else
{
MessageBox.Show("No room for new album.");
this.Close();
}
}
Your problem (from your comments) is that your for loop's condition is incorrect. Your for loop is this:
for (int i = 0; i < MusicCollection.FormMain.MAX_ALBUMS; ++i)
There is one problem and one potential problem here. First, when this code is actually run, it's really running:
for (int i = 0; i < 100; ++i)
because MusicCollection.FormMain.MAX_ALBUMS is declared as 100. This causes an error when the length of MusicCollection.FormMain.PublicVars.AlbumList is less than 100, because you're trying to grab an index that doesn't exist.
Instead, you need to iterate from i=0 to the length of ....PublicVars.AlbumList-1, or, preferably, for(int i = 0; i < ....PublicVars.AlbumList.Count; i++).
The second potential problem is that you are potentially skipping index 0. Arrays start at index zero and continue to index length-1. As such, you probably want i++, not ++i. Depends on your implementation, though.

Dijkstra's Algorithm implementation giving incorrect results

I need some help implementing Dijkstra's Algorithm and was hoping someone would be able to assist me. I have it so that it is printing some of routes but it isn't capturing the correct costs for the path.
Here is my node structure:
class Node
{
public enum Color {White, Gray, Black};
public string Name { get; set; } //city
public List<NeighborNode> Neighbors { get; set; } //Connected Edges
public Color nodeColor = Color.White;
public int timeDiscover { get; set; }//discover time
public int timeFinish { get; set; } // finish time
public Node()
{
Neighbors = new List<NeighborNode>();
}
public Node(string n, int discover)
{
Neighbors = new List<NeighborNode>();
this.Name = n;
timeDiscover = discover;
}
public Node(string n, NeighborNode e, decimal m)
{
Neighbors = new List<NeighborNode>();
this.Name = n;
this.Neighbors.Add(e);
}
}
class NeighborNode
{
public Node Name { get; set; }
public decimal Miles { get; set; } //Track the miles on the neighbor node
public NeighborNode() { }
public NeighborNode(Node n, decimal m)
{
Name = n;
Miles = m;
}
}
Here is my algorithm:
public void DijkstraAlgorithm(List<Node> graph)
{
List<DA> _algorithmList = new List<DA>(); //track the node cost/positioning
Stack<Node> _allCities = new Stack<Node>(); // add all cities into this for examination
Node _nodeToExamine = new Node(); //this is the node we're currently looking at.
decimal _cost = 0;
foreach (var city in graph) // putting these onto a stack for easy manipulation. Probably could have just made this a stack to start
{
_allCities.Push(city);
_algorithmList.Add(new DA(city));
}
_nodeToExamine = _allCities.Pop(); //pop off the first node
while (_allCities.Count != 0) // loop through each city
{
foreach (var neighbor in _nodeToExamine.Neighbors) //loop through each neighbor of the node
{
for (int i = 0; i < _algorithmList.Count; i++) //search the alorithm list for the current neighbor node
{
if (_algorithmList[i].Name.Name == neighbor.Name.Name) //found it
{
for (int j = 0; j < _algorithmList.Count; j++) //check for the cost of the parent node
{
if (_algorithmList[j].Name.Name == _nodeToExamine.Name) //looping through
{
if (_algorithmList[j].Cost != 100000000) //not infinity
_cost = _algorithmList[j].Cost; //set the cost to be the parent cost
break;
}
}
_cost = _cost + neighbor.Miles;
if (_algorithmList[i].Cost > _cost) // check to make sure the miles are less (better path)
{
_algorithmList[i].Parent = _nodeToExamine; //set the parent to be the top node
_algorithmList[i].Cost = _cost; // set the weight to be correct
break;
}
}
}
}
_cost = 0;
_nodeToExamine = _allCities.Pop();
}
}
This is what the graph looks like:
The graph list node is essentially
Node -- Neighbor Nodes
So for example:
Node = Olympia, Neighbor Nodes = Lacey and Tacoma
I think the problem is that
_cost = _algorithmList[j].Cost; //set the cost to be the parent cost
You do a direct assignment of cost, instead of an addition of old and new cost.
Also, the fact that you do
if (_algorithmList[j].Cost != 100000000) //not infinity
directly before it means that if the cost of the path is infinity, you do the very opposite - you add zero to the cost of the path, making it the least expensive instead of most expensive path.
If you want to check for infinity properly, you have to outright skip taking that path when you inspect its cost, not just skip calculating the cost.
I needed to rewrite the entire algorithm as it wasn't processing correctly:
public void DijkstraAlgorithm(List<Node> graph)
{
List<DA> _algorithmList = new List<DA>(); //track the node cost/positioning
DA _nodeToExamine = new DA(); //this is the node we're currently looking at.
bool flag = true; //for exting the while loop later
foreach (var node in graph)
{
_algorithmList.Add(new DA(node));
}
foreach (var children in _algorithmList[0].Name.Neighbors) //just starting at the first node
{
for (int i = 0; i < _algorithmList.Count; i++)
{
if (children.Name == _algorithmList[i].Name)
{
_algorithmList[i].Parent = _algorithmList[0].Name;
_algorithmList[i].Cost = children.Miles;
_algorithmList[0].Complete = true;
}
}
}
while (flag) //loop through the rest to organize
{
_algorithmList = _algorithmList.OrderBy(x => x.Cost).ToList(); //sort by shortest path
for (int i = 0; i < _algorithmList.Count; i++) //loop through each looking for a node that isn't complete
{
if (_algorithmList[i].Complete == false)
{
_nodeToExamine = _algorithmList[i];
break;
}
if (i == 13) //if the counter reaches 13 then we have completed all nodes and should bail out of the loop
flag = false;
}
if (_nodeToExamine.Name.Neighbors.Count == 0) //set any nodes that do not have children to be complete
{
_nodeToExamine.Complete = true;
}
foreach (var children in _nodeToExamine.Name.Neighbors) //loop through the children/neighbors to see if there's one with a shorter path
{
for (int i = 0; i < _algorithmList.Count; i++)
{
if (children.Name == _algorithmList[i].Name)
{
if (_nodeToExamine.Cost + children.Miles < _algorithmList[i].Cost) //found a better path
{
_algorithmList[i].Parent = _nodeToExamine.Name;
_algorithmList[i].Cost = _nodeToExamine.Cost + children.Miles;
}
}
}
_nodeToExamine.Complete = true;
}
}
PrintDijkstraAlgoirthm(_algorithmList);
}
public void PrintDijkstraAlgoirthm(List<DA> _finalList)
{
foreach (var item in _finalList)
{
if (item.Parent != null)
Console.WriteLine("{0} ---> {1}: {2}", item.Parent.Name, item.Name.Name, item.Cost);
}
}

Looping through Textboxes to retrieve data, c#

I have a class called "Player" with a constructor that takes 2 strings and an int.
These are declared in Textboxes on a form, with each team (Home H / Away A) having a different name, and each name type (Last L / First F) adding to the textbox's name. therefor giving a unique name such as txtFHome1.
In a foreach loop I want to create a new Player with the details of the textboxes on a page.
This is what I have got so far.
List <Player> HomeTeam = new List<Player>
private void btnAccept_Click(object sender, EventArgs e)
{
foreach (Control c in this.Controls)
{
for (int i = 0; i < 10; i++)
{
HomeTeam.Add (new Player(c.Name.EndsWith("FHome"+i),c.Name.EndsWith("LHome"+i),c.Name.EndsWith("upDownH"+i)));
}
}
}
any help?
From you post I understand that there are always 3 controls for 11 players, so there is no need to iterate trough all Controls in the form.
private void btnAccept_Click(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
var player = new Player(((TextBox)this.Controls.FindControl("FHome" + i)).Text, ((TextBox)this.Controls.FindControl("LHome" + i)).Text, ((NumericUpDown)this.Controls.FindControl("upDownH" + i)).Value);
HomeTeam.Add(player);
}
}
The first way is to use dictionaries with all controls. It is the fastest and easiest way.
Dictionary<int, TextBox> FHome;
Dictionary<int, TextBox> LHome;
Dictionary<int, TextBox> upDownH;
You should add the controls like this:
FHome.Add(0, textBoxLHome0);
FHome.Add(1, textBoxLHome1);
Then in your code you can use
for (int i = 0; i < 10; i++)
{
HomeTeam.Add (new Player(FHome[i].Text, LHome[i].Text, upDownH[i].Text));
}
try this:
Controls.OfType<TextBox>().ToList().ForEach((textbox) =>
{
for (int i = 0; i < 10; i++)
{
textbox.Text = "your text";
}
});
remember to include using System.Linq
I advice you to at lease try an encapsulate the three textboxes into a single UserControl like so:
public partial class ControlPlayerParams : UserControl {
public string Param1 { get { return this.textBox1.Text; } }
public string Param2 { get { return this.textBox2.Text; } }
public string Param3 { get { return this.textBox3.Text; } }
public ControlPlayerParams() {
this.InitializeComponent();
}
}
That way, you could at least do what you wanted to do more fluently and more safely (plus you get to modify just one UserControl in case you need something changed (Validation ??)):
foreach (ControlPlayerParams cpp in this.Controls.OfType<ControlPlayerParams>())
HomeTeam.Add(new Player(cpp.Param1, cpp.Param2, cpp.Param3));
BUT you should rethink the architecture of the app a bit if you ask me.

c# Plugin (reflection)

I'm having trouble with creating a plugin solution with reflection. When I click on a menuItem I would like to load and show another program in my window. I figured I would need 3 projects.
Client program that wants to load another program when clicked on menuItem
Program that I want to load
Plugin class
Code client program
private void nQueensToolStripMenuItem_Click(object sender, EventArgs e)
{
// Create an assembly object to load our classes
string path = Application.StartupPath + "\\NQueens.dll";
Assembly ass = Assembly.LoadFile(path);
Type objType = ass.GetType("NQueens.NQueen");
// Create an instace of NQueens.NQueen
var instance = Activator.CreateInstance(objType);
// public static bool berekenQueens()
objType.InvokeMember("berekenQueens",
BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Static,
null, instance, null);
// private static bool bordValidatie
objType.InvokeMember("bordValidatie",
BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Static,
null, instance, null);
}
Class
[AttributeUsage(AttributeTargets.Class)]
public class myPluginAttribute : Attribute
{
private bool _bIsPlugin;
public Boolean IsPlugin
{
get { return _bIsPlugin; }
set { _bIsPlugin = value; }
}
private string _sDescription;
public string Description
{
get { return _sDescription; }
set { _sDescription = value; }
}
public myPluginAttribute(Boolean b, String desc)
{
IsPlugin = b;
Description = desc;
}
}
NQueens (program i want to load when clicked on menuitem)
NQueens.cs
public class NQueen
{
public static bool berekenQueens(int Row, int N, bool[,] bord)
{
if (Row >= N) return true;
for (int Col = 0; Col < N; Col++)
{
//Q toevoegen
bord[Row, Col] = true;
//Q + Q volgende Row controleren
if (bordValidatie(Row, Col, bord, N) && berekenQueens(Row + 1, N, bord))
{
return true;
}
//Q verwijderen indien niet door controle
bord[Row, Col] = false;
}
return false;
}
private static bool bordValidatie(int currentRow, int currentCol, bool[,] currentBord, int N)
{
int colstep = 1;
for (int i = currentRow - 1; i >= 0; i--)
{
//rechte lijn
if (currentBord[i, currentCol])
return false;
//linker diagonaal
if (currentCol - colstep >= 0)
{
if (currentBord[i, currentCol - colstep])
return false;
}
//rechter diagonaal
if (currentCol + colstep < N)
{
if (currentBord[i, currentCol + colstep])
return false;
}
colstep += 1;
}
return true;
}
}
MainWindow (nqueens)
public partial class MainWindow : Window
{
public int iN { get { return Convert.ToInt32(txtN.Text); } set { txtN.Text = "" + value; } }
private bool[,] spelbord;
public MainWindow()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
spelbord = new bool[iN, iN];
NQueen.berekenQueens(0, iN, spelbord);
visualise(iN, spelbord);
}
private void visualise(int N, bool[,] bord)
{
gridTekenen();
for (int row = 0; row < N; row++)
{
for (int col = 0; col < N; col++)
{
Rectangle rect = new Rectangle();
rect.Stretch = Stretch.Fill;
TextBlock txtB = new TextBlock();
if (spelbord[row, col])
{
SolidColorBrush mySolidColorBrush = new SolidColorBrush();
mySolidColorBrush.Color = Colors.LightGreen;
rect.Fill = mySolidColorBrush;
txtB.Text = "Q";
}
rect.SetValue(Grid.ColumnProperty, col);
rect.SetValue(Grid.RowProperty, row);
txtB.SetValue(Grid.ColumnProperty, col);
txtB.SetValue(Grid.RowProperty, row);
gridPaneel.Children.Add(rect);
gridPaneel.Children.Add(txtB);
}
}
}
private void gridTekenen()
{
gridPaneel.ShowGridLines = true;
int grooteGrid = int.Parse(txtN.Text);
RowDefinition rowDef;
ColumnDefinition colDef;
for (int i = 0; i < grooteGrid; i++)
{
rowDef = new RowDefinition();
GridLengthConverter myGridLengthConverter = new GridLengthConverter();
GridLength gl1 = (GridLength)myGridLengthConverter.ConvertFromString(150 + "*");
rowDef.Height = gl1;
colDef = new ColumnDefinition();
colDef.Width = gl1;
gridPaneel.RowDefinitions.Add(rowDef);
gridPaneel.ColumnDefinitions.Add(colDef);
}
}
}
I'm stuck trying to get this thing working. How can I make my program to show the NQueens program? How does my client program know the methods from NQueen and use them?
EDIT: I made some changes in the nQueensToolStripMenuItem_Click method. Is this correct now? How can I show the NQueens method in my window now?
As far as I know, you will need a common Interface, which helps communicating with the "Extensions". You will then have three projects:
Your Core Application
A Library just containing the Interface (i.e. IPlugin)
Your Extensions.
Have a look at codeproject to get a better idea about the architecture of plugins.
A much simpler pattern is the classic "Factory Pattern" with interfaces. I've done this before to create plug-ins and it's really straightforward:
1) Create an interface containing all the properties and methods you would ever use to "talk" to the plug-in. Define this in a base class/assembly that will (hardly) ever change.
2) Create a frame UI application which perhaps has one stock implementation of the plug-in interface, perhaps the default menus, so you can easily debug and get your interface right.
3) Now to the dynamic loading... Create a configuration string listing a number of files which should be loaded. Good to allow this to be configurable rather than hard-coding paths, also for security never just load assemblies in a path, you don't know who could have put them there via a back door in file permissions.
4) On start-up use the assembly load from methods to go through each file and once loaded use reflection to query the interfaces, looking for your plugin interface. Store a collection of loaded interfaces/plug-ins and use them as you wish.
Obviously as you have a UI you will have a method to create the child menu items and windows and set their parent to your frame applications menu or client area appropriately. Then you will have some events defined on the interface to deal with events like items being clicked. Makes sense to also define a standard "tool" or command interface, so you can deal with menu items and toolbar items the same way.

Categories

Resources