|
using System;
using System.Collections.Generic;
using System.Windows.Input;
namespace HappyNomad.Outlining {
public struct RelativePosition<T> {
/// <summary>The outlining insertion command to use</summary>
public RoutedUICommand command;
/// <summary>Name of the subitems property</summary>
public string subItemsPropName;
/// <summary>Parent to the new item</summary>
public T parent;
/// <summary>Children of the parent, relative to
/// which the new item will be positioned</summary>
public IList<T> insertRelativeTo;
/// <summary>Desired index when inserting a child</summary>
public int childIndex;
public RelativePosition( ICommand command, T parent, IList<T> insertRelativeTo ) {
this.command = (RoutedUICommand)command; this.subItemsPropName = null;
this.parent = parent; this.insertRelativeTo = insertRelativeTo; this.childIndex = -1;
}
public RelativePosition( ICommand command, string subItemsPropName, T parent, IList<T> insertRelativeTo ) {
this.command = (RoutedUICommand)command; this.subItemsPropName = subItemsPropName;
this.parent = parent; this.insertRelativeTo = insertRelativeTo; this.childIndex = -1;
}
public override string ToString() {
string result = GetType().Name + ": command=" + command.Name + ", parent={" + parent +
"}, insertRelativeTo=";
if ( insertRelativeTo != null )
foreach ( T i in insertRelativeTo )
result = result + "\n\t" + i;
return result;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Adrian loves facilitating suave user experiences via the latest and greatest GUI technologies such as Windows 8 Metro-style apps as well as WPF. More generally, he finds joy in architecting software that is easy to comprehend and maintain. He does so by applying design patterns at the top-level, and by incessantly refactoring code at lower levels. He's always interested in hearing about opportunities for full or part-time development work. He resides in Pennsylvania but can potentially travel anywhere in the country. (Writing about himself in the third-person is Adrian's new hobby.)