From: <mar...@us...> - 2006-07-12 10:25:50
|
Revision: 591 Author: marisademeglio Date: 2006-07-12 03:25:31 -0700 (Wed, 12 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=591&view=rev Log Message: ----------- Added more events for heading node operations. Added more code to the TOC panel control. Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Obi.csproj trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs Added Paths: ----------- trunk/urakawa/application/Obi/Obi/Events/Node/AddChildSectionEventArgs.cs trunk/urakawa/application/Obi/Obi/Events/Node/BeginEditingSectionHeadingLabelEventArgs.cs trunk/urakawa/application/Obi/Obi/Events/Node/DecreaseSectionLevelEventArgs.cs trunk/urakawa/application/Obi/Obi/Events/Node/ExpandViewToAllDepthsEventArgs.cs trunk/urakawa/application/Obi/Obi/Events/Node/IncreaseSectionLevelEventArgs.cs trunk/urakawa/application/Obi/Obi/Events/Node/LimitViewToSectionDepthEventArgs.cs trunk/urakawa/application/Obi/Obi/Events/Node/MoveSectionDownEventArgs.cs trunk/urakawa/application/Obi/Obi/Events/Node/MoveSectionUpEventArgs.cs Added: trunk/urakawa/application/Obi/Obi/Events/Node/AddChildSectionEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/AddChildSectionEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Node/AddChildSectionEventArgs.cs 2006-07-12 10:25:31 UTC (rev 591) @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using urakawa.core; + +namespace Obi.Events.Node +{ + public delegate void AddChildSectionHandler(object sender, AddChildSectionEventArgs e); + + /// <summary> + /// This event is fired when a view wants to add a new child section node in the core tree. + /// </summary> + class AddChildSectionEventArgs : EventArgs + { + private CoreNode mContextNode; // the parent node of the new child + + public CoreNode ContextNode + { + get + { + return mContextNode; + } + } + + public AddChildSectionEventArgs(CoreNode contextNode) + { + mContextNode = contextNode; + } + } +} Added: trunk/urakawa/application/Obi/Obi/Events/Node/BeginEditingSectionHeadingLabelEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/BeginEditingSectionHeadingLabelEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Node/BeginEditingSectionHeadingLabelEventArgs.cs 2006-07-12 10:25:31 UTC (rev 591) @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using urakawa.core; + +namespace Obi.Events.Node +{ + public delegate void BeginEditingSectionHeadingLabelHandler(object sender, + BeginEditingSectionHeadingLabelEventArgs e); + + /// <summary> + /// This event is fired when a view wants to let the user begin editing the label + /// of a section heading. + /// </summary> + class BeginEditingSectionHeadingLabelEventArgs : EventArgs + { + private CoreNode mContextNode; // the node whose label is to be edited + + public CoreNode ContextNode + { + get + { + return mContextNode; + } + } + + public BeginEditingSectionHeadingLabelEventArgs(CoreNode contextNode) + { + mContextNode = contextNode; + } + } +} Added: trunk/urakawa/application/Obi/Obi/Events/Node/DecreaseSectionLevelEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/DecreaseSectionLevelEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Node/DecreaseSectionLevelEventArgs.cs 2006-07-12 10:25:31 UTC (rev 591) @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using urakawa.core; + +namespace Obi.Events.Node +{ + public delegate void DecreaseSectionLevelHandler(object sender, + DecreaseSectionLevelEventArgs e); + + /// <summary> + /// This event is fired to request to decrease a section by one level depth + /// </summary> + class DecreaseSectionLevelEventArgs : EventArgs + { + private CoreNode mContextNode; // the node to be moved + + public CoreNode ContextNode + { + get + { + return mContextNode; + } + } + + public DecreaseSectionLevelEventArgs(CoreNode contextNode) + { + mContextNode = contextNode; + } + } +} Added: trunk/urakawa/application/Obi/Obi/Events/Node/ExpandViewToAllDepthsEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/ExpandViewToAllDepthsEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Node/ExpandViewToAllDepthsEventArgs.cs 2006-07-12 10:25:31 UTC (rev 591) @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + + +namespace Obi.Events.Node +{ + public delegate void ExpandViewToAllDepthsHandler(object sender, + ExpandViewToAllDepthsEventArgs e); + + /// <summary> + /// This event is fired when the view should be limited to the depth of the given node + /// </summary> + class ExpandViewToAllDepthsEventArgs : EventArgs + { + public ExpandViewToAllDepthsEventArgs() + { + + } + } +} Added: trunk/urakawa/application/Obi/Obi/Events/Node/IncreaseSectionLevelEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/IncreaseSectionLevelEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Node/IncreaseSectionLevelEventArgs.cs 2006-07-12 10:25:31 UTC (rev 591) @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using urakawa.core; + +namespace Obi.Events.Node +{ + public delegate void IncreaseSectionLevelHandler(object sender, + IncreaseSectionLevelEventArgs e); + + /// <summary> + /// This event is fired to request to increase a section by one level depth + /// </summary> + class IncreaseSectionLevelEventArgs : EventArgs + { + private CoreNode mContextNode; // the node to be moved + + public CoreNode ContextNode + { + get + { + return mContextNode; + } + } + + public IncreaseSectionLevelEventArgs(CoreNode contextNode) + { + mContextNode = contextNode; + } + } +} Added: trunk/urakawa/application/Obi/Obi/Events/Node/LimitViewToSectionDepthEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/LimitViewToSectionDepthEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Node/LimitViewToSectionDepthEventArgs.cs 2006-07-12 10:25:31 UTC (rev 591) @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using urakawa.core; + +namespace Obi.Events.Node +{ + public delegate void LimitViewToSectionDepthHandler(object sender, + LimitViewToSectionDepthEventArgs e); + + /// <summary> + /// This event is fired when the view should be limited to the depth of the given node + /// </summary> + class LimitViewToSectionDepthEventArgs : EventArgs + { + private CoreNode mContextNode; // the node whose depth will determine the max depth shown in the views + + public CoreNode ContextNode + { + get + { + return mContextNode; + } + } + + public LimitViewToSectionDepthEventArgs(CoreNode contextNode) + { + mContextNode = contextNode; + } + } +} Added: trunk/urakawa/application/Obi/Obi/Events/Node/MoveSectionDownEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/MoveSectionDownEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Node/MoveSectionDownEventArgs.cs 2006-07-12 10:25:31 UTC (rev 591) @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Text; +using urakawa.core; + +namespace Obi.Events.Node +{ + public delegate void MoveSectionDownHandler(object sender, MoveSectionDownEventArgs e); + + /// <summary> + /// This event is fired when a view wants to move a node down (reorder) in the core tree. + /// </summary> + class MoveSectionDownEventArgs : EventArgs + { + private CoreNode mContextNode; // the node that will move down + + public CoreNode ContextNode + { + get + { + return mContextNode; + } + } + + public MoveSectionDownEventArgs(CoreNode contextNode) + { + mContextNode = contextNode; + } + } +} Added: trunk/urakawa/application/Obi/Obi/Events/Node/MoveSectionUpEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/MoveSectionUpEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Node/MoveSectionUpEventArgs.cs 2006-07-12 10:25:31 UTC (rev 591) @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using urakawa.core; + +namespace Obi.Events.Node +{ + public delegate void MoveSectionUpHandler(object sender, MoveSectionUpEventArgs e); + + /// <summary> + /// This event is fired when a view wants to move a node up (reorder) in the core tree. + /// </summary> + class MoveSectionUpEventArgs : EventArgs + { + private CoreNode mContextNode; // the node that will move up + + public CoreNode ContextNode + { + get + { + return mContextNode; + } + } + + public MoveSectionUpEventArgs(CoreNode contextNode) + { + mContextNode = contextNode; + } + } +} Modified: trunk/urakawa/application/Obi/Obi/Obi.csproj =================================================================== --- trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-12 09:00:16 UTC (rev 590) +++ trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-12 10:25:31 UTC (rev 591) @@ -92,8 +92,16 @@ <Compile Include="Dialogs\UserProfile.Designer.cs"> <DependentUpon>UserProfile.cs</DependentUpon> </Compile> + <Compile Include="Events\Node\ExpandViewToAllDepthsEventArgs.cs" /> + <Compile Include="Events\Node\AddChildSectionEventArgs.cs" /> <Compile Include="Events\Node\AddSiblingSectionEventArgs.cs" /> + <Compile Include="Events\Node\BeginEditingSectionHeadingLabelEventArgs.cs" /> <Compile Include="Events\Node\CreatedEventArgs.cs" /> + <Compile Include="Events\Node\DecreaseSectionLevelEventArgs.cs" /> + <Compile Include="Events\Node\IncreaseSectionLevelEventArgs.cs" /> + <Compile Include="Events\Node\LimitViewToSectionDepthEventArgs.cs" /> + <Compile Include="Events\Node\MoveSectionDownEventArgs.cs" /> + <Compile Include="Events\Node\MoveSectionUpEventArgs.cs" /> <Compile Include="Events\Project\StateChangedEventArgs.cs" /> <Compile Include="Localizer.cs" /> <Compile Include="messages.Designer.cs"> Modified: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-12 09:00:16 UTC (rev 590) +++ trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-12 10:25:31 UTC (rev 591) @@ -14,6 +14,13 @@ public partial class TOCPanel : UserControl { public event Events.Node.AddSiblingSectionHandler AddSiblingSection; + public event Events.Node.AddChildSectionHandler AddChildSection; + public event Events.Node.BeginEditingSectionHeadingLabelHandler BeginEditingLabel; + public event Events.Node.DecreaseSectionLevelHandler DecreaseSectionLevel; + public event Events.Node.IncreaseSectionLevelHandler IncreaseSectionLevel; + public event Events.Node.LimitViewToSectionDepthHandler LimitDepthOfView; + public event Events.Node.MoveSectionDownHandler MoveSectionDown; + public event Events.Node.MoveSectionUpHandler MoveSectionUp; private string ObiTextChannelName = "Obi.Text"; @@ -32,11 +39,6 @@ InitializeComponent(); } - /* - * ************************************ - * these functions are triggered from the outside - * ************************************* - */ /// <summary> /// Add a new heading as an immediate sibling of the relative node. /// The new heading has already been created as a <see cref="CoreNode"/>. Now we @@ -57,15 +59,14 @@ string label = getCoreNodeText(newNode); //add as a sibling - //@todo - //this adds it as the last child, so for us that's going to look like - //the youngest sibling. we need to add a middle sibling. System.Windows.Forms.TreeNode newTreeNode = - relTreeNode.Parent.Nodes.Add(newNode.GetHashCode().ToString(), label); - + relTreeNode.Parent.Nodes.Insert + (relTreeNode.Index+1, newNode.GetHashCode().ToString(), label); + newTreeNode.Tag = newNode; newTreeNode.ExpandAll(); + newTreeNode.EnsureVisible(); } /// <summary> @@ -92,11 +93,17 @@ newTreeNode.Tag = newNode; newTreeNode.ExpandAll(); + newTreeNode.EnsureVisible(); } + /// <summary> + /// Begin editing the label (activate the edit cursor) for the currently + /// selected section heading node. + /// </summary> public void BeginEditingLabelForCurrentSectionHeading() { System.Windows.Forms.TreeNode sel = this.tocTree.SelectedNode; + sel.EnsureVisible(); sel.BeginEdit(); } @@ -105,11 +112,11 @@ * you might move left if you go up and down * you won't move right */ - public void MoveCurrentSectionUp(urakawa.core.CoreNode node) + public void MoveCurrentSectionUp() { } - public void MoveCurrentSectionDown(urakawa.core.CoreNode node) + public void MoveCurrentSectionDown() { } @@ -127,11 +134,46 @@ { } + /// <summary> + /// Show all the sections in the tree view. + /// </summary> public void ExpandViewToShowAllSections() { tocTree.ExpandAll(); } + /// <summary> + /// Return the core node version of the selected tree node. + /// </summary> + /// <returns>The selected section.</returns> + public CoreNode GetSelectedSection() + { + urakawa.core.CoreNode selectedCoreNode; + System.Windows.Forms.TreeNode sel = this.tocTree.SelectedNode; + selectedCoreNode = (urakawa.core.CoreNode)sel.Tag; + return selectedCoreNode; + } + + /// <summary> + /// Selects a node in the tree view. + /// </summary> + /// <param name="node">The core node version of the node to select.</param> + /// <returns>true or false, depending on if the selection was successful</returns> + public bool SetSelectedSection(CoreNode node) + { + System.Windows.Forms.TreeNode sel = findTreeNodeFromCoreNode(node); + + if (sel != null) + { + tocTree.SelectedNode = sel; + return true; + } + else + { + return false; + } + } + /* * *************************************** * These functions "...ToolStripMenuItem_Click" are triggered @@ -140,11 +182,8 @@ private void addSectionAtSameLevelToolStripMenuItem_Click(object sender, EventArgs e) { urakawa.core.CoreNode selectedCoreNode; - System.Windows.Forms.TreeNode sel = this.tocTree.SelectedNode; - selectedCoreNode = (urakawa.core.CoreNode)sel.Tag; - AddSiblingSection(this, new Events.Node.AddSiblingSectionEventArgs(selectedCoreNode)); } @@ -156,27 +195,42 @@ private void moveUpToolStripMenuItem_Click(object sender, EventArgs e) { - + urakawa.core.CoreNode selectedCoreNode; + System.Windows.Forms.TreeNode sel = this.tocTree.SelectedNode; + selectedCoreNode = (urakawa.core.CoreNode)sel.Tag; + MoveSectionUp(this, new Events.Node.MoveSectionUpEventArgs(selectedCoreNode)); } private void moveDownToolStripMenuItem_Click(object sender, EventArgs e) { - + urakawa.core.CoreNode selectedCoreNode; + System.Windows.Forms.TreeNode sel = this.tocTree.SelectedNode; + selectedCoreNode = (urakawa.core.CoreNode)sel.Tag; + MoveSectionDown(this, new Events.Node.MoveSectionDownEventArgs(selectedCoreNode)); } private void increaseLevelToolStripMenuItem_Click(object sender, EventArgs e) { - + urakawa.core.CoreNode selectedCoreNode; + System.Windows.Forms.TreeNode sel = this.tocTree.SelectedNode; + selectedCoreNode = (urakawa.core.CoreNode)sel.Tag; + IncreaseSectionLevel(this, new Events.Node.IncreaseSectionLevelEventArgs(selectedCoreNode)); } private void decreaseLevelToolStripMenuItem_Click(object sender, EventArgs e) { - + urakawa.core.CoreNode selectedCoreNode; + System.Windows.Forms.TreeNode sel = this.tocTree.SelectedNode; + selectedCoreNode = (urakawa.core.CoreNode)sel.Tag; + DecreaseSectionLevel(this, new Events.Node.DecreaseSectionLevelEventArgs(selectedCoreNode)); } private void addSubSectionToolStripMenuItem_Click(object sender, EventArgs e) { - + urakawa.core.CoreNode selectedCoreNode; + System.Windows.Forms.TreeNode sel = this.tocTree.SelectedNode; + selectedCoreNode = (urakawa.core.CoreNode)sel.Tag; + AddChildSection(this, new Events.Node.AddChildSectionEventArgs(selectedCoreNode)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |