From: <ju...@us...> - 2006-05-29 06:11:22
|
Revision: 390 Author: julienq Date: 2006-05-28 23:10:56 -0700 (Sun, 28 May 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=390&view=rev Log Message: ----------- Added events to Obi Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Obi.csproj trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs trunk/urakawa/application/Obi/Obi/ObiForm.cs trunk/urakawa/application/Obi/Obi/Project.cs trunk/urakawa/application/Obi/Obi/messages.Designer.cs trunk/urakawa/application/Obi/Obi/messages.resx Added Paths: ----------- trunk/urakawa/application/Obi/Obi/Events/ trunk/urakawa/application/Obi/Obi/Events/Project/ trunk/urakawa/application/Obi/Obi/Events/Project/StateChangedEventArgs.cs Removed Paths: ------------- trunk/urakawa/application/Obi/Obi/ProjectManager.cs Added: trunk/urakawa/application/Obi/Obi/Events/Project/StateChangedEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Project/StateChangedEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Project/StateChangedEventArgs.cs 2006-05-29 06:10:56 UTC (rev 390) @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Obi.Events.Project +{ + public enum StateChange { Closed, Created, Modified, Opened, Reverted, Saved }; + + public delegate void StateChangedHandler(object sender, StateChangedEventArgs e); + + public class StateChangedEventArgs: EventArgs + { + private Obi.Project mProject; + private StateChange mChange; + + public Obi.Project Project { get { return mProject; } } + public StateChange Change { get { return mChange; } } + + public StateChangedEventArgs(Obi.Project project, StateChange change) + { + mProject = project; + mChange = change; + } + } +} Property changes on: trunk/urakawa/application/Obi/Obi/Events/Project/StateChangedEventArgs.cs ___________________________________________________________________ Name: svn:executable + * Modified: trunk/urakawa/application/Obi/Obi/Obi.csproj =================================================================== --- trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-05-29 02:04:07 UTC (rev 389) +++ trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-05-29 06:10:56 UTC (rev 390) @@ -38,6 +38,7 @@ <ItemGroup> <Compile Include="Command.cs" /> <Compile Include="Commands.cs" /> + <Compile Include="Events\Project\StateChangedEventArgs.cs" /> <Compile Include="Localizer.cs" /> <Compile Include="messages.Designer.cs"> <AutoGen>True</AutoGen> @@ -52,7 +53,6 @@ </Compile> <Compile Include="Program.cs" /> <Compile Include="Project.cs" /> - <Compile Include="ProjectManager.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <EmbeddedResource Include="messages.resx"> <SubType>Designer</SubType> Modified: trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs 2006-05-29 02:04:07 UTC (rev 389) +++ trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs 2006-05-29 06:10:56 UTC (rev 390) @@ -32,13 +32,23 @@ this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.createNewProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.openProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.openrecentProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + this.clearListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.closeProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.saveProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveProjectasToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.revertToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mUndoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mRedoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.touchProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); - this.metadataPanel1 = new Obi.UserControls.MetadataPanel(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); @@ -59,6 +69,13 @@ this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.createNewProjectToolStripMenuItem, this.openProjectToolStripMenuItem, + this.openrecentProjectToolStripMenuItem, + this.toolStripSeparator2, + this.saveProjectToolStripMenuItem, + this.saveProjectasToolStripMenuItem, + this.revertToolStripMenuItem, + this.closeProjectToolStripMenuItem, + this.toolStripSeparator3, this.exitToolStripMenuItem}); this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Size = new System.Drawing.Size(36, 20); @@ -67,21 +84,76 @@ // createNewProjectToolStripMenuItem // this.createNewProjectToolStripMenuItem.Name = "createNewProjectToolStripMenuItem"; - this.createNewProjectToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.createNewProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.createNewProjectToolStripMenuItem.Text = "&New project"; this.createNewProjectToolStripMenuItem.Click += new System.EventHandler(this.createNewProjectToolStripMenuItem_Click); // // openProjectToolStripMenuItem // this.openProjectToolStripMenuItem.Name = "openProjectToolStripMenuItem"; - this.openProjectToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.openProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.openProjectToolStripMenuItem.Text = "&Open project"; this.openProjectToolStripMenuItem.Click += new System.EventHandler(this.openProjectToolStripMenuItem_Click); // + // openrecentProjectToolStripMenuItem + // + this.openrecentProjectToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripSeparator4, + this.clearListToolStripMenuItem}); + this.openrecentProjectToolStripMenuItem.Name = "openrecentProjectToolStripMenuItem"; + this.openrecentProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); + this.openrecentProjectToolStripMenuItem.Text = "Open &recent project"; + // + // toolStripSeparator4 + // + this.toolStripSeparator4.Name = "toolStripSeparator4"; + this.toolStripSeparator4.Size = new System.Drawing.Size(114, 6); + // + // clearListToolStripMenuItem + // + this.clearListToolStripMenuItem.Name = "clearListToolStripMenuItem"; + this.clearListToolStripMenuItem.Size = new System.Drawing.Size(117, 22); + this.clearListToolStripMenuItem.Text = "Clear list"; + // + // closeProjectToolStripMenuItem + // + this.closeProjectToolStripMenuItem.Name = "closeProjectToolStripMenuItem"; + this.closeProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); + this.closeProjectToolStripMenuItem.Text = "&Close project"; + this.closeProjectToolStripMenuItem.Click += new System.EventHandler(this.closeProjectToolStripMenuItem_Click); + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(168, 6); + // + // saveProjectToolStripMenuItem + // + this.saveProjectToolStripMenuItem.Name = "saveProjectToolStripMenuItem"; + this.saveProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); + this.saveProjectToolStripMenuItem.Text = "&Save project"; + // + // saveProjectasToolStripMenuItem + // + this.saveProjectasToolStripMenuItem.Name = "saveProjectasToolStripMenuItem"; + this.saveProjectasToolStripMenuItem.Size = new System.Drawing.Size(171, 22); + this.saveProjectasToolStripMenuItem.Text = "Save project &as"; + // + // revertToolStripMenuItem + // + this.revertToolStripMenuItem.Name = "revertToolStripMenuItem"; + this.revertToolStripMenuItem.Size = new System.Drawing.Size(171, 22); + this.revertToolStripMenuItem.Text = "&Discard changes"; + // + // toolStripSeparator3 + // + this.toolStripSeparator3.Name = "toolStripSeparator3"; + this.toolStripSeparator3.Size = new System.Drawing.Size(168, 6); + // // exitToolStripMenuItem // this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.exitToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.exitToolStripMenuItem.Text = "E&xit"; this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); // @@ -89,7 +161,9 @@ // this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.mUndoToolStripMenuItem, - this.mRedoToolStripMenuItem}); + this.mRedoToolStripMenuItem, + this.toolStripSeparator1, + this.touchProjectToolStripMenuItem}); this.editToolStripMenuItem.Name = "editToolStripMenuItem"; this.editToolStripMenuItem.Size = new System.Drawing.Size(37, 20); this.editToolStripMenuItem.Text = "&Edit"; @@ -99,7 +173,7 @@ this.mUndoToolStripMenuItem.Enabled = false; this.mUndoToolStripMenuItem.Name = "mUndoToolStripMenuItem"; this.mUndoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z))); - this.mUndoToolStripMenuItem.Size = new System.Drawing.Size(133, 22); + this.mUndoToolStripMenuItem.Size = new System.Drawing.Size(140, 22); this.mUndoToolStripMenuItem.Text = "&Undo"; this.mUndoToolStripMenuItem.Click += new System.EventHandler(this.mUndoToolStripMenuItem_Click); // @@ -108,10 +182,22 @@ this.mRedoToolStripMenuItem.Enabled = false; this.mRedoToolStripMenuItem.Name = "mRedoToolStripMenuItem"; this.mRedoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y))); - this.mRedoToolStripMenuItem.Size = new System.Drawing.Size(133, 22); + this.mRedoToolStripMenuItem.Size = new System.Drawing.Size(140, 22); this.mRedoToolStripMenuItem.Text = "&Redo"; this.mRedoToolStripMenuItem.Click += new System.EventHandler(this.mRedoToolStripMenuItem_Click); // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(137, 6); + // + // touchProjectToolStripMenuItem + // + this.touchProjectToolStripMenuItem.Name = "touchProjectToolStripMenuItem"; + this.touchProjectToolStripMenuItem.Size = new System.Drawing.Size(140, 22); + this.touchProjectToolStripMenuItem.Text = "&Touch project"; + this.touchProjectToolStripMenuItem.Click += new System.EventHandler(this.touchProjectToolStripMenuItem_Click); + // // statusStrip1 // this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -126,27 +212,13 @@ // toolStripStatusLabel1 // this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; - this.toolStripStatusLabel1.Size = new System.Drawing.Size(37, 17); - this.toolStripStatusLabel1.Text = "Ready"; + this.toolStripStatusLabel1.Size = new System.Drawing.Size(0, 17); // - // metadataPanel1 - // - this.metadataPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.metadataPanel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); - this.metadataPanel1.Location = new System.Drawing.Point(0, 24); - this.metadataPanel1.Margin = new System.Windows.Forms.Padding(0); - this.metadataPanel1.Name = "metadataPanel1"; - this.metadataPanel1.Padding = new System.Windows.Forms.Padding(3); - this.metadataPanel1.Size = new System.Drawing.Size(775, 60); - this.metadataPanel1.TabIndex = 4; - // // ObiForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(775, 502); - this.Controls.Add(this.metadataPanel1); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.menuStrip1); this.MainMenuStrip = this.menuStrip1; @@ -171,9 +243,19 @@ private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; - private Obi.UserControls.MetadataPanel metadataPanel1; private System.Windows.Forms.ToolStripMenuItem createNewProjectToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem openProjectToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveProjectToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveProjectasToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem closeProjectToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripMenuItem touchProjectToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem openrecentProjectToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; + private System.Windows.Forms.ToolStripMenuItem revertToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; + private System.Windows.Forms.ToolStripMenuItem clearListToolStripMenuItem; } Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-05-29 02:04:07 UTC (rev 389) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-05-29 06:10:56 UTC (rev 390) @@ -12,7 +12,29 @@ { public partial class ObiForm : Form { + private Project mProject; // the project currently being authored + private UndoRedoStack mUndoStack; // the undo stack for this project [should belong to the project; saved together] + + private event Events.Project.StateChangedHandler ProjectStateChanged; + /// <summary> + /// Initialize a new form. No project is opened at creation time. + /// </summary> + public ObiForm() + { + InitializeComponent(); + + mProject = null; + ProjectStateChanged += new Events.Project.StateChangedHandler(mProject_StateChanged); + GUIUpdateNoProject(); + + mUndoStack = new UndoRedoStack(); + undo_label = mUndoToolStripMenuItem.Text; + redo_label = mRedoToolStripMenuItem.Text; + UndoStackChanged += new UndoStackChangedHandler(mUndoStack_UndoStackChanged); + } + + /// <summary> /// Create a new project if the correct one was closed properly. /// </summary> /// <param name="sender"></param> @@ -21,11 +43,12 @@ { if (ClosedProject()) { - ProjectManager.Instance.CreateProject(); + mProject = new Project(); + OnProjectCreated(); } else { - Console.WriteLine(Localizer.Message("cancelled") + "."); + Ready(); } } @@ -43,14 +66,28 @@ DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { - ProjectManager.Instance.OpenXUK(dialog.FileName); + mProject = new Project(dialog.FileName); + OnProjectOpened(); return; } } - Console.WriteLine(Localizer.Message("cancelled") + "."); + Ready(); } /// <summary> + /// Close the current project. + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void closeProjectToolStripMenuItem_Click(object sender, EventArgs e) + { + if (ClosedProject()) + { + mProject = null; + } + } + + /// <summary> /// Exit if and only if the currently open project was saved correctly. /// </summary> /// <param name="sender"></param> @@ -63,7 +100,7 @@ } else { - Console.WriteLine(Localizer.Message("cancelled") + "."); + Ready(); } } @@ -73,44 +110,162 @@ /// <returns>True if there is no open project or the currently open project could be closed.</returns> private bool ClosedProject() { - if (ProjectManager.Instance.Unsaved) + if (mProject != null && mProject.Unsaved) { DialogResult result = MessageBox.Show(Localizer.Message("closed_project_text"), Localizer.Message("close_project_caption"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { - // save the project + mProject.Save(); + OnProjectSaved(); } - return result != DialogResult.Cancel; + if (result == DialogResult.Cancel) + { + Ready(); + return false; + } + else + { + OnProjectClosed(); + return true; + } } else { + Ready(); return true; } } + /// <summary> + /// Touch the project so that it seems that it was modified (used for debugging.) + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void touchProjectToolStripMenuItem_Click(object sender, EventArgs e) + { + mProject.Touch(); + OnProjectModified(); + } + private void OnProjectClosed() + { + ProjectStateChanged(this, new Events.Project.StateChangedEventArgs(mProject, Obi.Events.Project.StateChange.Closed)); + } + + private void OnProjectCreated() + { + ProjectStateChanged(this, new Events.Project.StateChangedEventArgs(mProject, Obi.Events.Project.StateChange.Created)); + } + + private void OnProjectModified() + { + ProjectStateChanged(this, new Events.Project.StateChangedEventArgs(mProject, Obi.Events.Project.StateChange.Modified)); + } + + private void OnProjectOpened() + { + ProjectStateChanged(this, new Events.Project.StateChangedEventArgs(mProject, Obi.Events.Project.StateChange.Opened)); + } + + private void OnProjectSaved() + { + ProjectStateChanged(this, new Events.Project.StateChangedEventArgs(mProject, Obi.Events.Project.StateChange.Saved)); + } + + private void mProject_StateChanged(object sender, Events.Project.StateChangedEventArgs e) + { + switch (e.Change) + { + case Obi.Events.Project.StateChange.Closed: + GUIUpdateNoProject(); + break; + case Obi.Events.Project.StateChange.Created: + GUIUpdateSavedProject(); + Debug(Localizer.Message("debug_created_project")); + break; + case Obi.Events.Project.StateChange.Modified: + GUIUpdateUnsavedProject(); + Debug(Localizer.Message("debug_touched_project")); + break; + case Obi.Events.Project.StateChange.Opened: + GUIUpdateSavedProject(); + Debug(String.Format(Localizer.Message("debug_opened_project"), e.Project.XUKPath)); + break; + case Obi.Events.Project.StateChange.Saved: + GUIUpdateSavedProject(); + Debug(String.Format(Localizer.Message("debug_saved_project"), e.Project.XUKPath)); + break; + default: + Debug("******"); + break; + } + } + + /// <summary> + /// Utility method that prints to the console and outputs to the status bar. + /// </summary> + /// <param name="message">The message to print.</param> + private void Debug(string message) + { + Console.WriteLine(message); + toolStripStatusLabel1.Text = message; + } + + /// <summary> + /// Update the GUI to reflect enabled/disabled actions when no project is opened. + /// </summary> + private void GUIUpdateNoProject() + { + closeProjectToolStripMenuItem.Enabled = false; + saveProjectToolStripMenuItem.Enabled = false; + saveProjectasToolStripMenuItem.Enabled = false; + touchProjectToolStripMenuItem.Enabled = false; + revertToolStripMenuItem.Enabled = false; + Ready(); + } + + /// <summary> + /// Update the GUI to reflect enabled/disabled actions when the project is saved. + /// </summary> + private void GUIUpdateSavedProject() + { + closeProjectToolStripMenuItem.Enabled = true; + saveProjectToolStripMenuItem.Enabled = false; + saveProjectasToolStripMenuItem.Enabled = true; + touchProjectToolStripMenuItem.Enabled = true; + revertToolStripMenuItem.Enabled = false; + } + + /// <summary> + /// Update the GUI to reflect enabled/disabled actions when the project is unsaved. + /// </summary> + private void GUIUpdateUnsavedProject() + { + closeProjectToolStripMenuItem.Enabled = true; + saveProjectToolStripMenuItem.Enabled = true; + saveProjectasToolStripMenuItem.Enabled = true; + touchProjectToolStripMenuItem.Enabled = true; + revertToolStripMenuItem.Enabled = true; + Ready(); + } + + private void Ready() + { + toolStripStatusLabel1.Text = Localizer.Message("ready"); + } + + - - - private UndoRedoStack mUndoStack; + + private string undo_label; private string redo_label; private delegate void UndoStackChangedHandler(object sender, EventArgs e); private event UndoStackChangedHandler UndoStackChanged; - public ObiForm() - { - InitializeComponent(); - //mStrip.Resized += new EmptyStrip.ResizedHandler(mStrip_Resized); - UndoStackChanged += new UndoStackChangedHandler(mUndoStack_UndoStackChanged); - mUndoStack = new UndoRedoStack(); - undo_label = mUndoToolStripMenuItem.Text; - redo_label = mRedoToolStripMenuItem.Text; - } - private void mStrip_Resized(object sender, ResizedEventArgs e) { PushUndo(new ResizeStripCommand((EmptyStrip)sender, e.Before, e.After)); Modified: trunk/urakawa/application/Obi/Obi/Project.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Project.cs 2006-05-29 02:04:07 UTC (rev 389) +++ trunk/urakawa/application/Obi/Obi/Project.cs 2006-05-29 06:10:56 UTC (rev 390) @@ -30,7 +30,7 @@ /// </summary> public Project() { - mUnsaved = true; + mUnsaved = false; } /// <summary> @@ -47,5 +47,10 @@ { mUnsaved = false; } + + public void Touch() + { + mUnsaved = true; + } } } Deleted: trunk/urakawa/application/Obi/Obi/ProjectManager.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ProjectManager.cs 2006-05-29 02:04:07 UTC (rev 389) +++ trunk/urakawa/application/Obi/Obi/ProjectManager.cs 2006-05-29 06:10:56 UTC (rev 390) @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Obi -{ - public class ProjectManager - { - private static readonly ProjectManager mInstance = new ProjectManager(); - private Project mProject; - - public static ProjectManager Instance - { - get - { - return mInstance; - } - } - - public Project Project - { - get - { - return mProject; - } - } - - /// <summary> - /// True if there are unsaved changes in the project. - /// </summary> - public bool Unsaved - { - get - { - return mProject != null && mProject.Unsaved; - } - } - - private ProjectManager() - { - mProject = null; - } - - /// <summary> - /// Create a new project and replace the old one with the new one. - /// </summary> - public void CreateProject() - { - mProject = new Project(); - } - - /// <summary> - /// Open a XUK file and create a new project object from it. - /// Throw an exception if there is an error reading the file. - /// </summary> - /// <param name="path">Complete path of the XUK file.</param> - public void OpenXUK(string path) - { - mProject = new Project(path); - Console.WriteLine("Open XUK file {0}.", path); - } - } -} \ No newline at end of file Modified: trunk/urakawa/application/Obi/Obi/messages.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/messages.Designer.cs 2006-05-29 02:04:07 UTC (rev 389) +++ trunk/urakawa/application/Obi/Obi/messages.Designer.cs 2006-05-29 06:10:56 UTC (rev 390) @@ -79,7 +79,9 @@ } /// <summary> - /// Looks up a localized string similar to You are about to close a project with unsaved modifications. Do you want to save these modifications before closing the project? You may also press Cancel to not close the project.. + /// Looks up a localized string similar to You are about to close a project with unsaved modifications. + ///Do you want to save these modifications before closing the project? + ///You may also press Cancel to not close the project.. /// </summary> internal static string closed_project_text { get { @@ -88,6 +90,42 @@ } /// <summary> + /// Looks up a localized string similar to [DEBUG] Created project. + /// </summary> + internal static string debug_created_project { + get { + return ResourceManager.GetString("debug_created_project", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to [DEBUG] Opened project from XUK file {0}. + /// </summary> + internal static string debug_opened_project { + get { + return ResourceManager.GetString("debug_opened_project", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to [DEBUG] Saved project. + /// </summary> + internal static string debug_saved_project { + get { + return ResourceManager.GetString("debug_saved_project", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to [DEBUG] Touched project. + /// </summary> + internal static string debug_touched_project { + get { + return ResourceManager.GetString("debug_touched_project", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to New strip. /// </summary> internal static string new_strip_label { @@ -97,6 +135,24 @@ } /// <summary> + /// Looks up a localized string similar to No project is currently open.. + /// </summary> + internal static string no_open_project { + get { + return ResourceManager.GetString("no_open_project", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Ready.. + /// </summary> + internal static string ready { + get { + return ResourceManager.GetString("ready", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to {0} {1}. /// </summary> internal static string redo_label { Modified: trunk/urakawa/application/Obi/Obi/messages.resx =================================================================== --- trunk/urakawa/application/Obi/Obi/messages.resx 2006-05-29 02:04:07 UTC (rev 389) +++ trunk/urakawa/application/Obi/Obi/messages.resx 2006-05-29 06:10:56 UTC (rev 390) @@ -124,11 +124,31 @@ <value>Closing a modified project</value> </data> <data name="closed_project_text" xml:space="preserve"> - <value>You are about to close a project with unsaved modifications. Do you want to save these modifications before closing the project? You may also press Cancel to not close the project.</value> + <value>You are about to close a project with unsaved modifications. +Do you want to save these modifications before closing the project? +You may also press Cancel to not close the project.</value> </data> + <data name="debug_created_project" xml:space="preserve"> + <value>[DEBUG] Created project</value> + </data> + <data name="debug_opened_project" xml:space="preserve"> + <value>[DEBUG] Opened project from XUK file {0}</value> + </data> + <data name="debug_saved_project" xml:space="preserve"> + <value>[DEBUG] Saved project</value> + </data> + <data name="debug_touched_project" xml:space="preserve"> + <value>[DEBUG] Touched project</value> + </data> <data name="new_strip_label" xml:space="preserve"> <value>New strip</value> </data> + <data name="no_open_project" xml:space="preserve"> + <value>No project is currently open.</value> + </data> + <data name="ready" xml:space="preserve"> + <value>Ready.</value> + </data> <data name="redo_label" xml:space="preserve"> <value>{0} {1}</value> </data> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-05-30 11:32:22
|
Revision: 393 Author: julienq Date: 2006-05-30 04:32:12 -0700 (Tue, 30 May 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=393&view=rev Log Message: ----------- Project infrastructure is working, except persistence Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Obi.csproj trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs trunk/urakawa/application/Obi/Obi/ObiForm.cs trunk/urakawa/application/Obi/Obi/Project.cs trunk/urakawa/application/Obi/Obi/UserProfile.cs trunk/urakawa/application/Obi/Obi/messages.Designer.cs trunk/urakawa/application/Obi/Obi/messages.resx Modified: trunk/urakawa/application/Obi/Obi/Obi.csproj =================================================================== --- trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-05-30 01:09:14 UTC (rev 392) +++ trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-05-30 11:32:12 UTC (rev 393) @@ -32,6 +32,7 @@ <Reference Include="System.Data" /> <Reference Include="System.Deployment" /> <Reference Include="System.Drawing" /> + <Reference Include="System.Runtime.Serialization.Formatters.Soap" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml" /> </ItemGroup> Modified: trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs 2006-05-30 01:09:14 UTC (rev 392) +++ trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs 2006-05-30 11:32:12 UTC (rev 393) @@ -33,13 +33,13 @@ this.createNewProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.openProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.openrecentProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + this.openrecentSeparator = new System.Windows.Forms.ToolStripSeparator(); this.clearListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.closeProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.saveProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveProjectasToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.revertToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.closeProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -98,30 +98,24 @@ // openrecentProjectToolStripMenuItem // this.openrecentProjectToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripSeparator4, + this.openrecentSeparator, this.clearListToolStripMenuItem}); this.openrecentProjectToolStripMenuItem.Name = "openrecentProjectToolStripMenuItem"; this.openrecentProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.openrecentProjectToolStripMenuItem.Text = "Open &recent project"; // - // toolStripSeparator4 + // openrecentSeparator // - this.toolStripSeparator4.Name = "toolStripSeparator4"; - this.toolStripSeparator4.Size = new System.Drawing.Size(114, 6); + this.openrecentSeparator.Name = "openrecentSeparator"; + this.openrecentSeparator.Size = new System.Drawing.Size(114, 6); // // clearListToolStripMenuItem // this.clearListToolStripMenuItem.Name = "clearListToolStripMenuItem"; this.clearListToolStripMenuItem.Size = new System.Drawing.Size(117, 22); this.clearListToolStripMenuItem.Text = "Clear list"; + this.clearListToolStripMenuItem.Click += new System.EventHandler(this.clearListToolStripMenuItem_Click); // - // closeProjectToolStripMenuItem - // - this.closeProjectToolStripMenuItem.Name = "closeProjectToolStripMenuItem"; - this.closeProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); - this.closeProjectToolStripMenuItem.Text = "&Close project"; - this.closeProjectToolStripMenuItem.Click += new System.EventHandler(this.closeProjectToolStripMenuItem_Click); - // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; @@ -132,19 +126,29 @@ this.saveProjectToolStripMenuItem.Name = "saveProjectToolStripMenuItem"; this.saveProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.saveProjectToolStripMenuItem.Text = "&Save project"; + this.saveProjectToolStripMenuItem.Click += new System.EventHandler(this.saveProjectToolStripMenuItem_Click); // // saveProjectasToolStripMenuItem // this.saveProjectasToolStripMenuItem.Name = "saveProjectasToolStripMenuItem"; this.saveProjectasToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.saveProjectasToolStripMenuItem.Text = "Save project &as"; + this.saveProjectasToolStripMenuItem.Click += new System.EventHandler(this.saveProjectasToolStripMenuItem_Click); // // revertToolStripMenuItem // this.revertToolStripMenuItem.Name = "revertToolStripMenuItem"; this.revertToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.revertToolStripMenuItem.Text = "&Discard changes"; + this.revertToolStripMenuItem.Click += new System.EventHandler(this.revertToolStripMenuItem_Click); // + // closeProjectToolStripMenuItem + // + this.closeProjectToolStripMenuItem.Name = "closeProjectToolStripMenuItem"; + this.closeProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); + this.closeProjectToolStripMenuItem.Text = "&Close project"; + this.closeProjectToolStripMenuItem.Click += new System.EventHandler(this.closeProjectToolStripMenuItem_Click); + // // toolStripSeparator3 // this.toolStripSeparator3.Name = "toolStripSeparator3"; @@ -224,6 +228,7 @@ this.MainMenuStrip = this.menuStrip1; this.Name = "ObiForm"; this.Text = "Obi"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ObiForm_FormClosing); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.statusStrip1.ResumeLayout(false); @@ -254,7 +259,7 @@ private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; private System.Windows.Forms.ToolStripMenuItem revertToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; + private System.Windows.Forms.ToolStripSeparator openrecentSeparator; private System.Windows.Forms.ToolStripMenuItem clearListToolStripMenuItem; Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-05-30 01:09:14 UTC (rev 392) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-05-30 11:32:12 UTC (rev 393) @@ -1,8 +1,13 @@ using System; +using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; +using System.IO; +using System.IO.IsolatedStorage; +using System.Runtime.Serialization; +using System.Runtime.Serialization.Formatters.Soap; using System.Text; using System.Windows.Forms; @@ -13,10 +18,11 @@ public partial class ObiForm : Form { private Project mProject; // the project currently being authored + private Settings mSettings; // application settings private UndoRedoStack mUndoStack; // the undo stack for this project [should belong to the project; saved together] + + private event Events.Project.StateChangedHandler ProjectStateChanged; // track changes on the project - private event Events.Project.StateChangedHandler ProjectStateChanged; - /// <summary> /// Initialize a new form. No project is opened at creation time. /// </summary> @@ -27,7 +33,7 @@ mProject = null; ProjectStateChanged += new Events.Project.StateChangedHandler(mProject_StateChanged); GUIUpdateNoProject(); - + GetSettings(); mUndoStack = new UndoRedoStack(); undo_label = mUndoToolStripMenuItem.Text; redo_label = mRedoToolStripMenuItem.Text; @@ -43,7 +49,7 @@ { if (ClosedProject()) { - mProject = new Project(); + mProject = new Project(null); OnProjectCreated(); } else @@ -52,8 +58,10 @@ } } + private const string XukFilter = "Obi project file (*.xuk)|*.xuk"; + /// <summary> - /// Open a project from a XUK file. + /// Open a project from a XUK file by prompting the user for a file location. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> @@ -62,19 +70,200 @@ if (ClosedProject()) { OpenFileDialog dialog = new OpenFileDialog(); - dialog.Filter = "Obi project file (*.xuk)|*.xuk"; + dialog.Filter = XukFilter; DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { mProject = new Project(dialog.FileName); + AddRecentProject(dialog.FileName); OnProjectOpened(); - return; } + else + { + Ready(); + } } + else + { + Ready(); + } + } + + /// <summary> + /// Add a project to the list of recent projects. + /// If the project was already in the list, promote it to the top of the list. + /// Update the recent menu if necessary. + /// </summary> + /// <param name="path">The path of the project to add.</param> + private void AddRecentProject(string path) + { + if (mSettings.RecentProjects.Count == 0) + { + openrecentProjectToolStripMenuItem.Enabled = true; + } + else + { + if (mSettings.RecentProjects.Contains(path)) + { + int i = mSettings.RecentProjects.IndexOf(path); + mSettings.RecentProjects.RemoveAt(i); + openrecentProjectToolStripMenuItem.DropDownItems.RemoveAt(i); + } + } + mSettings.RecentProjects.Insert(0, path); + ToolStripMenuItem item = new ToolStripMenuItem(); + item.Text = Path.GetFileName(path); + item.Click += new System.EventHandler(delegate(object sender, EventArgs e) { OpenProject(path); }); + openrecentProjectToolStripMenuItem.DropDownItems.Insert(0, item); + } + + /// <summary> + /// Open a project from a XUK file. + /// </summary> + /// <param name="path">The path of the XUK file to open.</param> + private void OpenProject(string path) + { + if (ClosedProject()) + { + mProject = new Project(path); + AddRecentProject(path); + OnProjectOpened(); + } + else + { + Ready(); + } + } + + /// <summary> + /// Clear the list of recently opened files (prompt the user first.) + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void clearListToolStripMenuItem_Click(object sender, EventArgs e) + { + DialogResult result = MessageBox.Show(Localizer.Message("clear_recent_text"), + Localizer.Message("clear_recent_caption"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (result == DialogResult.Yes) + { + ClearRecentList(); + } Ready(); } /// <summary> + /// Clear the list of recent projects. + /// </summary> + private void ClearRecentList() + { + for (int i = mSettings.RecentProjects.Count - 1; i >= 0; --i) + { + openrecentProjectToolStripMenuItem.DropDownItems.RemoveAt(i); + } + mSettings.RecentProjects.Clear(); + openrecentProjectToolStripMenuItem.Enabled = false; + } + + /// <summary> + /// Save the current project under its current name, or ask for one if none is defined yet. + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void saveProjectToolStripMenuItem_Click(object sender, EventArgs e) + { + if (mProject.Unsaved) + { + if (mProject.XUKPath == null) + { + SaveProjectAs(); + } + else + { + mProject.Save(); + OnProjectSaved(); + } + } + else + { + Ready(); + } + } + + /// <summary> + /// Save the project under a (presumably) different name. + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void saveProjectasToolStripMenuItem_Click(object sender, EventArgs e) + { + SaveProjectAs(); + } + + /// <summary> + /// Save the project under a file name supplied by the user through a file chooser. + /// The currently open project is still the old project. + /// </summary> + private void SaveProjectAs() + { + SaveFileDialog dialog = new SaveFileDialog(); + dialog.Filter = XukFilter; + DialogResult result = dialog.ShowDialog(); + if (result == DialogResult.OK) + { + if (mProject.SetXukPath(dialog.FileName)) + { + mProject.Save(); + OnProjectSaved(); + } + else + { + mProject.SaveAs(dialog.FileName); + Debug(String.Format(Localizer.Message("debug_saved_project"), dialog.FileName)); + } + AddRecentProject(dialog.FileName); + } + else + { + Ready(); + } + } + + /// <summary> + /// Revert the project to its last saved state, or if it was never saved, just reset it to a blank project. + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void revertToolStripMenuItem_Click(object sender, EventArgs e) + { + if (mProject.Unsaved) + { + DialogResult discard = MessageBox.Show(Localizer.Message("discard_changes_text"), + Localizer.Message("discard_changes_caption"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (discard == DialogResult.Yes) + { + if (mProject.XUKPath == null) + { + mProject = new Project(null); + OnProjectCreated(); + } + else + { + mProject = new Project(mProject.XUKPath); + OnProjectOpened(); + } + } + else + { + Ready(); + } + } + else + { + Ready(); + } + } + + /// <summary> /// Close the current project. /// </summary> /// <param name="sender"></param> @@ -113,7 +302,7 @@ if (mProject != null && mProject.Unsaved) { DialogResult result = MessageBox.Show(Localizer.Message("closed_project_text"), - Localizer.Message("close_project_caption"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); + Localizer.Message("closed_project_caption"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { mProject.Save(); @@ -132,6 +321,7 @@ } else { + OnProjectClosed(); Ready(); return true; } @@ -217,6 +407,7 @@ /// </summary> private void GUIUpdateNoProject() { + this.Text = "Obi"; closeProjectToolStripMenuItem.Enabled = false; saveProjectToolStripMenuItem.Enabled = false; saveProjectasToolStripMenuItem.Enabled = false; @@ -230,6 +421,7 @@ /// </summary> private void GUIUpdateSavedProject() { + this.Text = mProject.Title + " - Obi"; closeProjectToolStripMenuItem.Enabled = true; saveProjectToolStripMenuItem.Enabled = false; saveProjectasToolStripMenuItem.Enabled = true; @@ -242,6 +434,7 @@ /// </summary> private void GUIUpdateUnsavedProject() { + this.Text = mProject.Title + "* - Obi"; closeProjectToolStripMenuItem.Enabled = true; saveProjectToolStripMenuItem.Enabled = true; saveProjectasToolStripMenuItem.Enabled = true; @@ -250,16 +443,81 @@ Ready(); } + /// <summary> + /// Update the status bar to say "Ready." + /// </summary> private void Ready() { toolStripStatusLabel1.Text = Localizer.Message("ready"); } + private const string SettingsFileName = "obi_settings.xml"; - + /// <summary> + /// Read the settings, or create an empty settings object. + /// </summary> + private void GetSettings() + { + mSettings = new Settings(); + mSettings.RecentProjects = new ArrayList(); + ClearRecentList(); + } + /*private void GetSettings() + { + mSettings = new Settings(); + try + { + IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForDomain(); + IsolatedStorageFileStream stream = + new IsolatedStorageFileStream(SettingsFileName, FileMode.Open, FileAccess.Read, file); + MessageBox.Show("OK (stream)", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); + SoapFormatter soap = new SoapFormatter(); + mSettings.RecentProjects = (ArrayList)soap.Deserialize(stream); + ClearRecentList(); + for (int i = mSettings.RecentProjects.Count - 1; i >= 0; --i) + { + //AddRecentProject((string) mSettings.RecentProjects[i]); + Console.WriteLine("Add {0} ({1})", (string)mSettings.RecentProjects[i], i); + } + MessageBox.Show("OK (deserialize)", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); + stream.Close(); + } + catch (Exception e) + { + mSettings.RecentProjects = new ArrayList(); + ClearRecentList(); + } + }*/ + /// <summary> + /// Save the settings when closing. + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void ObiForm_FormClosing(object sender, FormClosingEventArgs e) + { + /*try + { + IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForDomain(); + IsolatedStorageFileStream stream = + new IsolatedStorageFileStream(SettingsFileName, FileMode.Create, FileAccess.Write, file); + SoapFormatter soap = new SoapFormatter(); + soap.Serialize(stream, mSettings.RecentProjects); + stream.Close(); + string[] dirs = file.GetFileNames("*.*"); + MessageBox.Show("OK: " + String.Join(" :: ", dirs), "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception x) + { + MessageBox.Show(String.Format(Localizer.Message("save_settings_error_text"), x.Message), + Localizer.Message("save_settings_error_caption"), MessageBoxButtons.OK, MessageBoxIcon.Error); + }*/ + } + + + private string undo_label; private string redo_label; @@ -319,4 +577,13 @@ } } } + + /// <summary> + /// Various persistent application settings. + /// </summary> + [Serializable()] + public class Settings + { + public ArrayList RecentProjects; // paths to projects recently opened + } } \ No newline at end of file Modified: trunk/urakawa/application/Obi/Obi/Project.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Project.cs 2006-05-30 01:09:14 UTC (rev 392) +++ trunk/urakawa/application/Obi/Obi/Project.cs 2006-05-30 11:32:12 UTC (rev 393) @@ -8,6 +8,7 @@ { private bool mUnsaved; // true if the project was modified and not saved private string mXUKPath; // path to the XUK file + private string mTitle; // temporary title (from file name) public bool Unsaved { @@ -25,12 +26,12 @@ } } - /// <summary> - /// Create a blank project. - /// </summary> - public Project() + public string Title { - mUnsaved = false; + get + { + return mTitle; + } } /// <summary> @@ -41,16 +42,50 @@ { mUnsaved = false; mXUKPath = xukPath; + mTitle = xukPath == null ? "(Untitled project)" : System.IO.Path.GetFileNameWithoutExtension(xukPath); } + /// <summary> + /// Save the project. + /// </summary> public void Save() { mUnsaved = false; } + /// <summary> + /// Make a copy of this project and save it under a new name. + /// </summary> + /// <param name="path">The path of the new project.</param> + public void SaveAs(string path) + { + } + + /// <summary> + /// Pretend that the project was modified. + /// </summary> public void Touch() { mUnsaved = true; } + + /// <summary> + /// Set the XUK path if and only if it was not set before. + /// </summary> + /// <param name="path">The new XUK path.</param> + /// <returns>True if the path was actually set.</returns> + public bool SetXukPath(string path) + { + if (mXUKPath == null) + { + mXUKPath = path; + mTitle = System.IO.Path.GetFileNameWithoutExtension(path); + return true; + } + else + { + return false; + } + } } } Modified: trunk/urakawa/application/Obi/Obi/UserProfile.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserProfile.cs 2006-05-30 01:09:14 UTC (rev 392) +++ trunk/urakawa/application/Obi/Obi/UserProfile.cs 2006-05-30 11:32:12 UTC (rev 393) @@ -11,5 +11,13 @@ private string mOrganization; private CultureInfo mLanguage; private string mIdTemplate; + + public UserProfile() + { + mName = null; + mOrganization = null; + mLanguage = null; + mIdTemplate = null; + } } } \ No newline at end of file Modified: trunk/urakawa/application/Obi/Obi/messages.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/messages.Designer.cs 2006-05-30 01:09:14 UTC (rev 392) +++ trunk/urakawa/application/Obi/Obi/messages.Designer.cs 2006-05-30 11:32:12 UTC (rev 393) @@ -70,6 +70,25 @@ } /// <summary> + /// Looks up a localized string similar to Clear the list of recent projects?. + /// </summary> + internal static string clear_recent_caption { + get { + return ResourceManager.GetString("clear_recent_caption", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Are you sure you want to clear the list of recent projects? + ///You cannot undo this operation.. + /// </summary> + internal static string clear_recent_text { + get { + return ResourceManager.GetString("clear_recent_text", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to Closing a modified project. /// </summary> internal static string closed_project_caption { @@ -80,8 +99,7 @@ /// <summary> /// Looks up a localized string similar to You are about to close a project with unsaved modifications. - ///Do you want to save these modifications before closing the project? - ///You may also press Cancel to not close the project.. + ///Do you want to save these modifications before closing the project?. /// </summary> internal static string closed_project_text { get { @@ -108,7 +126,7 @@ } /// <summary> - /// Looks up a localized string similar to [DEBUG] Saved project. + /// Looks up a localized string similar to [DEBUG] Saved project to XUK file {0}. /// </summary> internal static string debug_saved_project { get { @@ -126,6 +144,26 @@ } /// <summary> + /// Looks up a localized string similar to Discarding changes to a modified project. + /// </summary> + internal static string discard_changes_caption { + get { + return ResourceManager.GetString("discard_changes_caption", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Do you really want to discard all modifications made to this + ///project and revert it to its last saved state? + ///You cannot undo this operation.. + /// </summary> + internal static string discard_changes_text { + get { + return ResourceManager.GetString("discard_changes_text", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to New strip. /// </summary> internal static string new_strip_label { @@ -171,6 +209,27 @@ } /// <summary> + /// Looks up a localized string similar to Could not save settings. + /// </summary> + internal static string save_settings_error_caption { + get { + return ResourceManager.GetString("save_settings_error_caption", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to The following error occurred while trying to save the settings: + ///"{0}" + ///As a result, changes to the settings made during this session have not been saved. + ///Oh well.. + /// </summary> + internal static string save_settings_error_text { + get { + return ResourceManager.GetString("save_settings_error_text", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to {0} {1}. /// </summary> internal static string undo_label { Modified: trunk/urakawa/application/Obi/Obi/messages.resx =================================================================== --- trunk/urakawa/application/Obi/Obi/messages.resx 2006-05-30 01:09:14 UTC (rev 392) +++ trunk/urakawa/application/Obi/Obi/messages.resx 2006-05-30 11:32:12 UTC (rev 393) @@ -120,13 +120,19 @@ <data name="cancelled" xml:space="preserve"> <value>Cancelled</value> </data> + <data name="clear_recent_caption" xml:space="preserve"> + <value>Clear the list of recent projects?</value> + </data> + <data name="clear_recent_text" xml:space="preserve"> + <value>Are you sure you want to clear the list of recent projects? +You cannot undo this operation.</value> + </data> <data name="closed_project_caption" xml:space="preserve"> <value>Closing a modified project</value> </data> <data name="closed_project_text" xml:space="preserve"> <value>You are about to close a project with unsaved modifications. -Do you want to save these modifications before closing the project? -You may also press Cancel to not close the project.</value> +Do you want to save these modifications before closing the project?</value> </data> <data name="debug_created_project" xml:space="preserve"> <value>[DEBUG] Created project</value> @@ -135,11 +141,19 @@ <value>[DEBUG] Opened project from XUK file {0}</value> </data> <data name="debug_saved_project" xml:space="preserve"> - <value>[DEBUG] Saved project</value> + <value>[DEBUG] Saved project to XUK file {0}</value> </data> <data name="debug_touched_project" xml:space="preserve"> <value>[DEBUG] Touched project</value> </data> + <data name="discard_changes_caption" xml:space="preserve"> + <value>Discarding changes to a modified project</value> + </data> + <data name="discard_changes_text" xml:space="preserve"> + <value>Do you really want to discard all modifications made to this +project and revert it to its last saved state? +You cannot undo this operation.</value> + </data> <data name="new_strip_label" xml:space="preserve"> <value>New strip</value> </data> @@ -155,6 +169,15 @@ <data name="resize_strip" xml:space="preserve"> <value>resize strip</value> </data> + <data name="save_settings_error_caption" xml:space="preserve"> + <value>Could not save settings</value> + </data> + <data name="save_settings_error_text" xml:space="preserve"> + <value>The following error occurred while trying to save the settings: +"{0}" +As a result, changes to the settings made during this session have not been saved. +Oh well.</value> + </data> <data name="undo_label" xml:space="preserve"> <value>{0} {1}</value> </data> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-06-27 14:59:53
|
Revision: 454 Author: julienq Date: 2006-06-27 07:59:42 -0700 (Tue, 27 Jun 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=454&view=rev Log Message: ----------- Integrating the toolkit in the application... Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Obi.csproj trunk/urakawa/application/Obi/Obi/ObiForm.cs trunk/urakawa/application/Obi/Obi/Project.cs trunk/urakawa/application/Obi/Obi/Strips/Manager.cs trunk/urakawa/application/Obi/Obi/Strips/ParStrip.cs Modified: trunk/urakawa/application/Obi/Obi/Obi.csproj =================================================================== --- trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-06-27 05:34:11 UTC (rev 453) +++ trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-06-27 14:59:42 UTC (rev 454) @@ -57,6 +57,10 @@ <Reference Include="System.Runtime.Serialization.Formatters.Soap" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml" /> + <Reference Include="urakawa, Version=1.0.2363.26816, Culture=neutral"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\..\implementation\UrakawaToolkit\obj\Debug\urakawa.dll</HintPath> + </Reference> </ItemGroup> <ItemGroup> <Compile Include="Commands.cs" /> Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-06-27 05:34:11 UTC (rev 453) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-06-27 14:59:42 UTC (rev 454) @@ -14,6 +14,8 @@ using Commands; using Obi.UserControls; +using urakawa.core; + namespace Obi { public partial class ObiForm : Form @@ -687,7 +689,8 @@ private void appendStripToolStripMenuItem_Click(object sender, EventArgs e) { - Strips.ParStrip par = mProject.Strips.AddNewParStrip(); + CoreNode new_node = mProject.AppendStrip(); + Strips.ParStrip par = mProject.Strips.AddNewParStrip(new_node); mProjectPanel.StripManager.Add(par); OnProjectModified(); Debug(String.Format(Localizer.Message("debug_appended_strip"), par)); Modified: trunk/urakawa/application/Obi/Obi/Project.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Project.cs 2006-06-27 05:34:11 UTC (rev 453) +++ trunk/urakawa/application/Obi/Obi/Project.cs 2006-06-27 14:59:42 UTC (rev 454) @@ -2,6 +2,9 @@ using System.Collections.Generic; using System.Text; +using urakawa.core; +using urakawa.media; + namespace Obi { public class Project @@ -12,6 +15,11 @@ private NCX.NCX mNCX; // TOC of the project private Strips.Manager mStrips; // strip manager for the project + public static readonly string AUDIO_CHANNEL = "audio channel"; + + private Presentation mPresentation; // the presentation itself + //private ChannelsProperty mAudioProperty; // audio property for core nodes + public bool Unsaved { get { return mUnsaved; } } public string XUKPath { get { return mXUKPath; } } public SimpleMetadata Metadata { get { return mMetadata; } } @@ -31,6 +39,13 @@ mMetadata = new SimpleMetadata(title, id, userProfile); mNCX = new NCX.NCX(this); mStrips = new Strips.Manager(); + + mPresentation = new Presentation(); + Channel audio_channel = mPresentation.getChannelFactory().createChannel(AUDIO_CHANNEL); + mPresentation.getChannelsManager().addChannel(audio_channel); + AudioMedia audio_media = (AudioMedia)mPresentation.getMediaFactory().createMedia(MediaType.AUDIO); + //mAudioProperty = mPresentation.getPropertyFactory().createChannelsProperty(); + //mAudioProperty.setMedia(audio_channel, audio_media); } /// <summary> @@ -96,8 +111,29 @@ return System.Text.RegularExpressions.Regex.Replace(title, @"[^a-zA-Z0-9_]", "_"); } - public void AppendItem() + /// <summary> + /// A new strip is appended: need to create a new node + /// </summary> + public CoreNode AppendStrip() { + CoreNode new_node = mPresentation.getCoreNodeFactory().createNode(); + // new_node.setProperty(mAudioProperty); + // Find the last node after which to insert + CoreNode last = mPresentation.getRootNode(); + while (last.getChildCount() > 0) + { + last = (CoreNode)last.getChild(last.getChildCount() - 1); + } + // Add the node as a sibling; or if this is the root node, as a child + if (last.getParent() == null) + { + last.appendChild(new_node); + } + else + { + ((CoreNode)(last.getParent())).appendChild(new_node); + } + return new_node; } } -} +} \ No newline at end of file Modified: trunk/urakawa/application/Obi/Obi/Strips/Manager.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Strips/Manager.cs 2006-06-27 05:34:11 UTC (rev 453) +++ trunk/urakawa/application/Obi/Obi/Strips/Manager.cs 2006-06-27 14:59:42 UTC (rev 454) @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Text; +using urakawa.core; + namespace Obi.Strips { public class Manager @@ -29,9 +31,9 @@ mSelected = null; } - public ParStrip AddNewParStrip() + public ParStrip AddNewParStrip(CoreNode node) { - ParStrip par = new ParStrip(Localizer.Message("new_strip_label")); + ParStrip par = new ParStrip(Localizer.Message("new_strip_label"), node); mPars.Add(par); return par; } Modified: trunk/urakawa/application/Obi/Obi/Strips/ParStrip.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Strips/ParStrip.cs 2006-06-27 05:34:11 UTC (rev 453) +++ trunk/urakawa/application/Obi/Obi/Strips/ParStrip.cs 2006-06-27 14:59:42 UTC (rev 454) @@ -2,11 +2,16 @@ using System.Collections.Generic; using System.Text; +using urakawa.core; +using urakawa.media; + namespace Obi.Strips { public class ParStrip: Strip { - private string mLabel; + private string mLabel; // the strip label + private CoreNode mNode; // the core node corresponding to this strip + private SequenceMedia mAudio; // heading audio object public delegate void LabelChangedHandler(object sender, LabelChangedEventArgs e); public event LabelChangedHandler LabelChanged; @@ -25,14 +30,38 @@ } } + /// <summary> + /// Audio to the heading + /// </summary> + public SequenceMedia Audio + { + get + { + return mAudio; + } + set + { + Presentation presentation = (Presentation)mNode.getPresentation(); + ChannelsProperty audioprop = (ChannelsProperty)presentation.getPropertyFactory().createChannelsProperty(); + ChannelsManager manager = (ChannelsManager)presentation.getChannelsManager(); + Channel audiochan = (Channel)((manager.getChannelByName(Project.AUDIO_CHANNEL)[0])); + audioprop.setMedia(audiochan, value); + mNode.setProperty(audioprop); + } + } + public ParStrip() { mLabel = null; + mNode = null; + mAudio = null; } - public ParStrip(string label) + public ParStrip(string label, CoreNode node) { mLabel = label; + mNode = node; + mAudio = null; } public override string ToString() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-07-11 08:17:15
|
Revision: 569 Author: julienq Date: 2006-07-11 01:17:07 -0700 (Tue, 11 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=569&view=rev Log Message: ----------- Preferences are saved Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Dialogs/UserProfile.Designer.cs trunk/urakawa/application/Obi/Obi/ObiForm.cs trunk/urakawa/application/Obi/Obi/UserProfile.cs Modified: trunk/urakawa/application/Obi/Obi/Dialogs/UserProfile.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Dialogs/UserProfile.Designer.cs 2006-07-11 06:08:39 UTC (rev 568) +++ trunk/urakawa/application/Obi/Obi/Dialogs/UserProfile.Designer.cs 2006-07-11 08:17:07 UTC (rev 569) @@ -34,8 +34,8 @@ this.organizationBox = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.cultureBox = new System.Windows.Forms.ComboBox(); - this.button1 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); + this.okButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); this.SuspendLayout(); // // label1 @@ -96,37 +96,38 @@ this.cultureBox.Sorted = true; this.cultureBox.TabIndex = 5; // - // button1 + // okButton // - this.button1.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.button1.DialogResult = System.Windows.Forms.DialogResult.OK; - this.button1.Location = new System.Drawing.Point(118, 117); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); - this.button1.TabIndex = 6; - this.button1.Text = "&OK"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); + this.okButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Location = new System.Drawing.Point(118, 117); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(75, 23); + this.okButton.TabIndex = 6; + this.okButton.Text = "&OK"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.button1_Click); // - // button2 + // cancelButton // - this.button2.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.button2.Location = new System.Drawing.Point(199, 117); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(75, 23); - this.button2.TabIndex = 7; - this.button2.Text = "&Cancel"; - this.button2.UseVisualStyleBackColor = true; + this.cancelButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(199, 117); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 23); + this.cancelButton.TabIndex = 7; + this.cancelButton.Text = "&Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; // // UserProfile // - this.AcceptButton = this.button1; + this.AcceptButton = this.okButton; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.cancelButton; this.ClientSize = new System.Drawing.Size(392, 152); - this.Controls.Add(this.button2); - this.Controls.Add(this.button1); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.okButton); this.Controls.Add(this.cultureBox); this.Controls.Add(this.label3); this.Controls.Add(this.organizationBox); @@ -149,7 +150,7 @@ private System.Windows.Forms.TextBox organizationBox; private System.Windows.Forms.Label label3; private System.Windows.Forms.ComboBox cultureBox; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.Button cancelButton; } } \ No newline at end of file Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-11 06:08:39 UTC (rev 568) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-11 08:17:07 UTC (rev 569) @@ -562,7 +562,7 @@ /// <summary> /// Read the settings, or create an empty settings object. /// </summary> - private void GetSettings() + /*private void GetSettings() { mSettings = new Settings(); mSettings.RecentProjects = new ArrayList(); @@ -571,9 +571,9 @@ Console.WriteLine(mSettings.UserProfile); mSettings.IdTemplate = "obi_####"; mSettings.DefaultPath = Environment.CurrentDirectory; - } + }*/ - /*private void GetSettings() + private void GetSettings() { mSettings = new Settings(); try @@ -583,7 +583,7 @@ new IsolatedStorageFileStream(SettingsFileName, FileMode.Open, FileAccess.Read, file); MessageBox.Show("OK (stream)", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); SoapFormatter soap = new SoapFormatter(); - mSettings.RecentProjects = (ArrayList)soap.Deserialize(stream); + mSettings = (Settings)soap.Deserialize(stream); ClearRecentList(); for (int i = mSettings.RecentProjects.Count - 1; i >= 0; --i) { @@ -598,22 +598,20 @@ mSettings.RecentProjects = new ArrayList(); ClearRecentList(); } - }*/ + } /// <summary> /// Save the settings when closing. /// </summary> - /// <param name="sender"></param> - /// <param name="e"></param> private void ObiForm_FormClosing(object sender, FormClosingEventArgs e) { - /*try + try { IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForDomain(); IsolatedStorageFileStream stream = new IsolatedStorageFileStream(SettingsFileName, FileMode.Create, FileAccess.Write, file); SoapFormatter soap = new SoapFormatter(); - soap.Serialize(stream, mSettings.RecentProjects); + soap.Serialize(stream, mSettings); stream.Close(); string[] dirs = file.GetFileNames("*.*"); MessageBox.Show("OK: " + String.Join(" :: ", dirs), "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); @@ -622,7 +620,7 @@ { MessageBox.Show(String.Format(Localizer.Message("save_settings_error_text"), x.Message), Localizer.Message("save_settings_error_caption"), MessageBoxButtons.OK, MessageBoxIcon.Error); - }*/ + } } Modified: trunk/urakawa/application/Obi/Obi/UserProfile.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserProfile.cs 2006-07-11 06:08:39 UTC (rev 568) +++ trunk/urakawa/application/Obi/Obi/UserProfile.cs 2006-07-11 08:17:07 UTC (rev 569) @@ -5,6 +5,11 @@ namespace Obi { + /// <summary> + /// The user profile stores basic information about the user. + /// This information is used to provide default values for book metadata. + /// </summary> + [Serializable] public class UserProfile { private string mName; // user name This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-07-11 12:22:05
|
Revision: 577 Author: julienq Date: 2006-07-11 05:21:38 -0700 (Tue, 11 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=577&view=rev Log Message: ----------- Added toc panel (that will replace NCX panel) Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Dialogs/NewProject.Designer.cs trunk/urakawa/application/Obi/Obi/Dialogs/NewProject.cs trunk/urakawa/application/Obi/Obi/Events/Project/StateChangedEventArgs.cs trunk/urakawa/application/Obi/Obi/ObiForm.cs trunk/urakawa/application/prototype/UrakawaPrototype/StructureView.Designer.cs Added Paths: ----------- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.resx Modified: trunk/urakawa/application/Obi/Obi/Dialogs/NewProject.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Dialogs/NewProject.Designer.cs 2006-07-11 12:20:26 UTC (rev 576) +++ trunk/urakawa/application/Obi/Obi/Dialogs/NewProject.Designer.cs 2006-07-11 12:21:38 UTC (rev 577) @@ -29,12 +29,12 @@ private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); - this.mTitleBox = new System.Windows.Forms.TextBox(); + this.titleBox = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); - this.mFileBox = new System.Windows.Forms.TextBox(); - this.button1 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); - this.button3 = new System.Windows.Forms.Button(); + this.fileBox = new System.Windows.Forms.TextBox(); + this.selectButton = new System.Windows.Forms.Button(); + this.okButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); this.SuspendLayout(); // // label1 @@ -46,15 +46,15 @@ this.label1.TabIndex = 0; this.label1.Text = "&Title:"; // - // mTitleBox + // titleBox // - this.mTitleBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.titleBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.mTitleBox.Location = new System.Drawing.Point(48, 12); - this.mTitleBox.Name = "mTitleBox"; - this.mTitleBox.Size = new System.Drawing.Size(444, 19); - this.mTitleBox.TabIndex = 1; - this.mTitleBox.Leave += new System.EventHandler(this.titleBox_Leave); + this.titleBox.Location = new System.Drawing.Point(48, 12); + this.titleBox.Name = "titleBox"; + this.titleBox.Size = new System.Drawing.Size(444, 19); + this.titleBox.TabIndex = 1; + this.titleBox.Leave += new System.EventHandler(this.titleBox_Leave); // // label2 // @@ -65,61 +65,61 @@ this.label2.TabIndex = 2; this.label2.Text = "&File:"; // - // mFileBox + // fileBox // - this.mFileBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.fileBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.mFileBox.Location = new System.Drawing.Point(48, 37); - this.mFileBox.Name = "mFileBox"; - this.mFileBox.Size = new System.Drawing.Size(363, 19); - this.mFileBox.TabIndex = 3; + this.fileBox.Location = new System.Drawing.Point(48, 37); + this.fileBox.Name = "fileBox"; + this.fileBox.Size = new System.Drawing.Size(363, 19); + this.fileBox.TabIndex = 3; // - // button1 + // selectButton // - this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.button1.Location = new System.Drawing.Point(417, 35); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); - this.button1.TabIndex = 4; - this.button1.Text = "&Select"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); + this.selectButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.selectButton.Location = new System.Drawing.Point(417, 35); + this.selectButton.Name = "selectButton"; + this.selectButton.Size = new System.Drawing.Size(75, 23); + this.selectButton.TabIndex = 4; + this.selectButton.Text = "&Select"; + this.selectButton.UseVisualStyleBackColor = true; + this.selectButton.Click += new System.EventHandler(this.selectButton_Click); // - // button2 + // okButton // - this.button2.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.button2.DialogResult = System.Windows.Forms.DialogResult.OK; - this.button2.Location = new System.Drawing.Point(174, 93); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(75, 23); - this.button2.TabIndex = 5; - this.button2.Text = "&OK"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); + this.okButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Location = new System.Drawing.Point(174, 93); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(75, 23); + this.okButton.TabIndex = 5; + this.okButton.Text = "&OK"; + this.okButton.UseVisualStyleBackColor = true; // - // button3 + // cancelButton // - this.button3.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.button3.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.button3.Location = new System.Drawing.Point(255, 93); - this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(75, 23); - this.button3.TabIndex = 6; - this.button3.Text = "&Cancel"; - this.button3.UseVisualStyleBackColor = true; + this.cancelButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(255, 93); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 23); + this.cancelButton.TabIndex = 6; + this.cancelButton.Text = "&Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; // // NewProject // - this.AcceptButton = this.button2; + this.AcceptButton = this.okButton; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.cancelButton; this.ClientSize = new System.Drawing.Size(504, 128); - this.Controls.Add(this.button3); - this.Controls.Add(this.button2); - this.Controls.Add(this.button1); - this.Controls.Add(this.mFileBox); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.okButton); + this.Controls.Add(this.selectButton); + this.Controls.Add(this.fileBox); this.Controls.Add(this.label2); - this.Controls.Add(this.mTitleBox); + this.Controls.Add(this.titleBox); this.Controls.Add(this.label1); this.MinimumSize = new System.Drawing.Size(8, 162); this.Name = "NewProject"; @@ -132,11 +132,11 @@ #endregion private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox mTitleBox; + private System.Windows.Forms.TextBox titleBox; private System.Windows.Forms.Label label2; - private System.Windows.Forms.TextBox mFileBox; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Button button2; - private System.Windows.Forms.Button button3; + private System.Windows.Forms.TextBox fileBox; + private System.Windows.Forms.Button selectButton; + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.Button cancelButton; } } \ No newline at end of file Modified: trunk/urakawa/application/Obi/Obi/Dialogs/NewProject.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Dialogs/NewProject.cs 2006-07-11 12:20:26 UTC (rev 576) +++ trunk/urakawa/application/Obi/Obi/Dialogs/NewProject.cs 2006-07-11 12:21:38 UTC (rev 577) @@ -9,50 +9,75 @@ namespace Obi.Dialogs { + /// <summary> + /// Dialog for creating a new project. + /// The user can choos a title for the project and a file to save it to. + /// </summary> public partial class NewProject : Form { - private string mTitle; - private string mPath; + /// <summary> + /// The chosen title for the project. + /// </summary> + public string Title + { + get + { + return titleBox.Text; + } + } - public string Title { get { return mTitle; } } - public string Path { get { return mPath; } } + /// <summary> + /// The chosen path for the XUK project file. + /// </summary> + public string Path + { + get + { + return fileBox.Text; + } + } + /// <summary> + /// Create a new dialog with default information (dummy name and default path.) + /// </summary> + /// <param name="path">The initial directory where to create the project.</param> public NewProject(string path) { InitializeComponent(); - mPath = path; - mTitle = Localizer.Message("new_project"); - mTitleBox.Text = mTitle; - mFileBox.Text = mPath; + titleBox.Text = Localizer.Message("new_project"); + fileBox.Text = path; GenerateFileName(); } - private void button2_Click(object sender, EventArgs e) + /// <summary> + /// Update the path text box with the selected path from the file chooser. + /// </summary> + private void selectButton_Click(object sender, EventArgs e) { - mTitle = mTitleBox.Text; - mPath = mFileBox.Text; - } - - private void button1_Click(object sender, EventArgs e) - { SaveFileDialog dialog = new SaveFileDialog(); - dialog.InitialDirectory = System.IO.Path.GetDirectoryName(mFileBox.Text); + dialog.InitialDirectory = System.IO.Path.GetDirectoryName(fileBox.Text); dialog.Filter = "XUK project file (*.xuk)|*.xuk"; if (dialog.ShowDialog() == DialogResult.OK) { - mFileBox.Text = dialog.FileName; + fileBox.Text = dialog.FileName; } } + /// <summary> + /// Generate a new XUK file name when a new title is chosen. + /// </summary> private void titleBox_Leave(object sender, EventArgs e) { GenerateFileName(); } + /// <summary> + /// Generate a full path from the initial directory and the title of the project. + /// </summary> private void GenerateFileName() { - mFileBox.Text = String.Format(@"{0}\{1}.xuk", System.IO.Path.GetDirectoryName(mFileBox.Text), - Project.ShortName(mTitleBox.Text)); + fileBox.Text = String.Format(@"{0}\{1}.xuk", System.IO.Path.GetDirectoryName(fileBox.Text), + Project.ShortName(titleBox.Text)); } } } \ No newline at end of file Modified: trunk/urakawa/application/Obi/Obi/Events/Project/StateChangedEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Project/StateChangedEventArgs.cs 2006-07-11 12:20:26 UTC (rev 576) +++ trunk/urakawa/application/Obi/Obi/Events/Project/StateChangedEventArgs.cs 2006-07-11 12:21:38 UTC (rev 577) @@ -4,17 +4,33 @@ namespace Obi.Events.Project { - public enum StateChange { Closed, Created, Modified, Opened, Reverted, Saved }; + public enum StateChange { Closed, Created, Modified, Opened, Reverted, Saved }; public delegate void StateChangedHandler(object sender, StateChangedEventArgs e); + /// <summary> + /// This event indicates that the state of the project has changed. The project may have been opened, saved, modified, etc. + /// </summary> public class StateChangedEventArgs: EventArgs { private Obi.Project mProject; private StateChange mChange; - public Obi.Project Project { get { return mProject; } } - public StateChange Change { get { return mChange; } } + public Obi.Project Project + { + get + { + return mProject; + } + } + + public StateChange Change + { + get + { + return mChange; + } + } public StateChangedEventArgs(Obi.Project project, StateChange change) { Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-11 12:20:26 UTC (rev 576) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-11 12:21:38 UTC (rev 577) @@ -22,10 +22,12 @@ { private Project mProject; // the project currently being authored private Settings mSettings; // application settings - private UndoRedoStack mUndoStack; // the undo stack for this project [should belong to the project; saved together] + private UndoRedoStack mUndoStack; // the undo stack for this project (should it belong to the project?) private event Events.Project.StateChangedHandler ProjectStateChanged; // track changes on the project + private static readonly string XukFilter = "Obi project file (*.xuk)|*.xuk"; // filter for opening/saving XUK files + /// <summary> /// Initialize a new form. No project is opened at creation time. /// </summary> @@ -43,11 +45,11 @@ UndoStackChanged += new UndoStackChangedHandler(mUndoStack_UndoStackChanged); } + #region Menu items + /// <summary> - /// Create a new project if the correct one was closed properly. + /// Create a new project if the current one was closed properly, or if none was open. /// </summary> - /// <param name="sender"></param> - /// <param name="e"></param> private void createNewProjectToolStripMenuItem_Click(object sender, EventArgs e) { Dialogs.NewProject dialog = new Dialogs.NewProject(mSettings.DefaultPath); @@ -69,13 +71,15 @@ } } - private const string XukFilter = "Obi project file (*.xuk)|*.xuk"; + #endregion + + + + /// <summary> /// Open a project from a XUK file by prompting the user for a file location. /// </summary> - /// <param name="sender"></param> - /// <param name="e"></param> private void openProjectToolStripMenuItem_Click(object sender, EventArgs e) { if (ClosedProject()) Added: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs 2006-07-11 12:21:38 UTC (rev 577) @@ -0,0 +1,37 @@ +namespace Obi.UserControls +{ + partial class TOCPanel + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} Property changes on: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs ___________________________________________________________________ Name: svn:executable + * Added: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-11 12:21:38 UTC (rev 577) @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; + +namespace Obi.UserControls +{ + public partial class TOCPanel : UserControl + { + public TOCPanel() + { + InitializeComponent(); + } + } +} Property changes on: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs ___________________________________________________________________ Name: svn:executable + * Added: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.resx =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.resx (rev 0) +++ trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.resx 2006-07-11 12:21:38 UTC (rev 577) @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file Property changes on: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.resx ___________________________________________________________________ Name: svn:executable + * Modified: trunk/urakawa/application/prototype/UrakawaPrototype/StructureView.Designer.cs =================================================================== --- trunk/urakawa/application/prototype/UrakawaPrototype/StructureView.Designer.cs 2006-07-11 12:20:26 UTC (rev 576) +++ trunk/urakawa/application/prototype/UrakawaPrototype/StructureView.Designer.cs 2006-07-11 12:21:38 UTC (rev 577) @@ -86,7 +86,7 @@ treeNode3, treeNode5}); this.treeView1.SelectedImageIndex = 0; - this.treeView1.Size = new System.Drawing.Size(301, 347); + this.treeView1.Size = new System.Drawing.Size(301, 320); this.treeView1.TabIndex = 1; // // contextMenuStrip1 @@ -106,7 +106,7 @@ this.toolStripSeparator2, this.deleteToolStripMenuItem}); this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(135, 242); + this.contextMenuStrip1.Size = new System.Drawing.Size(134, 242); this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); // // addHeadingToolStripMenuItem @@ -115,27 +115,27 @@ this.asSiblingToolStripMenuItem, this.asChildToolStripMenuItem}); this.addHeadingToolStripMenuItem.Name = "addHeadingToolStripMenuItem"; - this.addHeadingToolStripMenuItem.Size = new System.Drawing.Size(134, 22); + this.addHeadingToolStripMenuItem.Size = new System.Drawing.Size(133, 22); this.addHeadingToolStripMenuItem.Text = "Add heading"; // // asSiblingToolStripMenuItem // this.asSiblingToolStripMenuItem.Name = "asSiblingToolStripMenuItem"; - this.asSiblingToolStripMenuItem.Size = new System.Drawing.Size(118, 22); + this.asSiblingToolStripMenuItem.Size = new System.Drawing.Size(121, 22); this.asSiblingToolStripMenuItem.Text = "As sibling"; this.asSiblingToolStripMenuItem.Click += new System.EventHandler(this.asSiblingToolStripMenuItem_Click); // // asChildToolStripMenuItem // this.asChildToolStripMenuItem.Name = "asChildToolStripMenuItem"; - this.asChildToolStripMenuItem.Size = new System.Drawing.Size(118, 22); + this.asChildToolStripMenuItem.Size = new System.Drawing.Size(121, 22); this.asChildToolStripMenuItem.Text = "As child"; this.asChildToolStripMenuItem.Click += new System.EventHandler(this.asChildToolStripMenuItem_Click); // // addListToolStripMenuItem // this.addListToolStripMenuItem.Name = "addListToolStripMenuItem"; - this.addListToolStripMenuItem.Size = new System.Drawing.Size(134, 22); + this.addListToolStripMenuItem.Size = new System.Drawing.Size(133, 22); this.addListToolStripMenuItem.Text = "Add list"; // // addPageToolStripMenuItem @@ -144,82 +144,82 @@ this.aSinglePageToolStripMenuItem, this.aRangeOfPagesToolStripMenuItem}); this.addPageToolStripMenuItem.Name = "addPageToolStripMenuItem"; - this.addPageToolStripMenuItem.Size = new System.Drawing.Size(134, 22); + this.addPageToolStripMenuItem.Size = new System.Drawing.Size(133, 22); this.addPageToolStripMenuItem.Text = "Add page"; // // aSinglePageToolStripMenuItem // this.aSinglePageToolStripMenuItem.Name = "aSinglePageToolStripMenuItem"; - this.aSinglePageToolStripMenuItem.Size = new System.Drawing.Size(105, 22); + this.aSinglePageToolStripMenuItem.Size = new System.Drawing.Size(102, 22); this.aSinglePageToolStripMenuItem.Text = "Single"; // // aRangeOfPagesToolStripMenuItem // this.aRangeOfPagesToolStripMenuItem.Name = "aRangeOfPagesToolStripMenuItem"; - this.aRangeOfPagesToolStripMenuItem.Size = new System.Drawing.Size(105, 22); + this.aRangeOfPagesToolStripMenuItem.Size = new System.Drawing.Size(102, 22); this.aRangeOfPagesToolStripMenuItem.Text = "Range"; // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(131, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(130, 6); // // indentToolStripMenuItem // this.indentToolStripMenuItem.Name = "indentToolStripMenuItem"; - this.indentToolStripMenuItem.Size = new System.Drawing.Size(134, 22); + this.indentToolStripMenuItem.Size = new System.Drawing.Size(133, 22); this.indentToolStripMenuItem.Text = "Indent"; this.indentToolStripMenuItem.Click += new System.EventHandler(this.indentToolStripMenuItem_Click); // // outdentToolStripMenuItem // this.outdentToolStripMenuItem.Name = "outdentToolStripMenuItem"; - this.outdentToolStripMenuItem.Size = new System.Drawing.Size(134, 22); + this.outdentToolStripMenuItem.Size = new System.Drawing.Size(133, 22); this.outdentToolStripMenuItem.Text = "Outdent"; this.outdentToolStripMenuItem.Click += new System.EventHandler(this.outdentToolStripMenuItem_Click); // // moveUpToolStripMenuItem // this.moveUpToolStripMenuItem.Name = "moveUpToolStripMenuItem"; - this.moveUpToolStripMenuItem.Size = new System.Drawing.Size(134, 22); + this.moveUpToolStripMenuItem.Size = new System.Drawing.Size(133, 22); this.moveUpToolStripMenuItem.Text = "Move up"; this.moveUpToolStripMenuItem.Click += new System.EventHandler(this.moveUpToolStripMenuItem_Click); // // moveDownToolStripMenuItem // this.moveDownToolStripMenuItem.Name = "moveDownToolStripMenuItem"; - this.moveDownToolStripMenuItem.Size = new System.Drawing.Size(134, 22); + this.moveDownToolStripMenuItem.Size = new System.Drawing.Size(133, 22); this.moveDownToolStripMenuItem.Text = "Move down"; this.moveDownToolStripMenuItem.Click += new System.EventHandler(this.moveDownToolStripMenuItem_Click); // // toolStripSeparator3 // this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(131, 6); + this.toolStripSeparator3.Size = new System.Drawing.Size(130, 6); // // renameLabelToolStripMenuItem // this.renameLabelToolStripMenuItem.Name = "renameLabelToolStripMenuItem"; - this.renameLabelToolStripMenuItem.Size = new System.Drawing.Size(134, 22); + this.renameLabelToolStripMenuItem.Size = new System.Drawing.Size(133, 22); this.renameLabelToolStripMenuItem.Text = "Rename"; this.renameLabelToolStripMenuItem.Click += new System.EventHandler(this.renameLabelToolStripMenuItem_Click_1); // // renameToolStripMenuItem // this.renameToolStripMenuItem.Name = "renameToolStripMenuItem"; - this.renameToolStripMenuItem.Size = new System.Drawing.Size(134, 22); + this.renameToolStripMenuItem.Size = new System.Drawing.Size(133, 22); this.renameToolStripMenuItem.Text = "Edit label..."; this.renameToolStripMenuItem.Click += new System.EventHandler(this.renameToolStripMenuItem_Click); // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(131, 6); + this.toolStripSeparator2.Size = new System.Drawing.Size(130, 6); // // deleteToolStripMenuItem // this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; - this.deleteToolStripMenuItem.Size = new System.Drawing.Size(134, 22); + this.deleteToolStripMenuItem.Size = new System.Drawing.Size(133, 22); this.deleteToolStripMenuItem.Text = "Delete item"; this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click); // @@ -231,11 +231,11 @@ // // StructureView // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.treeView1); this.Name = "StructureView"; - this.Size = new System.Drawing.Size(301, 347); + this.Size = new System.Drawing.Size(301, 320); this.Load += new System.EventHandler(this.load); this.contextMenuStrip1.ResumeLayout(false); this.ResumeLayout(false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-07-11 12:25:33
|
Revision: 578 Author: julienq Date: 2006-07-11 05:25:23 -0700 (Tue, 11 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=578&view=rev Log Message: ----------- Added toc panel again Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Obi.csproj trunk/urakawa/application/Obi/Obi/ObiForm.cs trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs Modified: trunk/urakawa/application/Obi/Obi/Obi.csproj =================================================================== --- trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-11 12:21:38 UTC (rev 577) +++ trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-11 12:25:23 UTC (rev 578) @@ -178,6 +178,10 @@ <SubType>Designer</SubType> <DependentUpon>StripPanel.cs</DependentUpon> </EmbeddedResource> + <EmbeddedResource Include="UserControls\TOCPanel.resx"> + <SubType>Designer</SubType> + <DependentUpon>TOCPanel.cs</DependentUpon> + </EmbeddedResource> <Compile Include="Properties\Resources.Designer.cs"> <AutoGen>True</AutoGen> <DependentUpon>Resources.resx</DependentUpon> @@ -255,6 +259,12 @@ <Compile Include="UserControls\MetadataPanel.Designer.cs"> <DependentUpon>MetadataPanel.cs</DependentUpon> </Compile> + <Compile Include="UserControls\TOCPanel.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="UserControls\TOCPanel.Designer.cs"> + <DependentUpon>TOCPanel.cs</DependentUpon> + </Compile> <Compile Include="UserProfile.cs" /> </ItemGroup> <ItemGroup> Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-11 12:21:38 UTC (rev 577) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-11 12:25:23 UTC (rev 578) @@ -27,6 +27,7 @@ private event Events.Project.StateChangedHandler ProjectStateChanged; // track changes on the project private static readonly string XukFilter = "Obi project file (*.xuk)|*.xuk"; // filter for opening/saving XUK files + private static readonly string SettingsFileName = "obi_settings.xml"; // settings file name /// <summary> /// Initialize a new form. No project is opened at creation time. @@ -561,8 +562,6 @@ toolStripStatusLabel1.Text = Localizer.Message("ready"); } - private const string SettingsFileName = "obi_settings.xml"; - /// <summary> /// Read the settings, or create an empty settings object. /// </summary> Modified: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs 2006-07-11 12:21:38 UTC (rev 577) +++ trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs 2006-07-11 12:25:23 UTC (rev 578) @@ -28,10 +28,29 @@ /// </summary> private void InitializeComponent() { - components = new System.ComponentModel.Container(); + this.treeView1 = new System.Windows.Forms.TreeView(); + this.SuspendLayout(); + // + // treeView1 + // + this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill; + this.treeView1.Location = new System.Drawing.Point(0, 0); + this.treeView1.Name = "treeView1"; + this.treeView1.Size = new System.Drawing.Size(150, 150); + this.treeView1.TabIndex = 0; + // + // TOCPanel + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.treeView1); + this.Name = "TOCPanel"; + this.ResumeLayout(false); + } #endregion + + private System.Windows.Forms.TreeView treeView1; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-07-11 13:37:05
|
Revision: 580 Author: julienq Date: 2006-07-11 06:36:57 -0700 (Tue, 11 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=580&view=rev Log Message: ----------- Settings should work Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Obi.csproj trunk/urakawa/application/Obi/Obi/ObiForm.cs trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.Designer.cs Modified: trunk/urakawa/application/Obi/Obi/Obi.csproj =================================================================== --- trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-11 12:58:28 UTC (rev 579) +++ trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-11 13:36:57 UTC (rev 580) @@ -92,6 +92,7 @@ <Compile Include="Dialogs\UserProfile.Designer.cs"> <DependentUpon>UserProfile.cs</DependentUpon> </Compile> + <Compile Include="Events\Node\CreatedEventArgs.cs" /> <Compile Include="Events\Project\StateChangedEventArgs.cs" /> <Compile Include="Localizer.cs" /> <Compile Include="messages.Designer.cs"> @@ -197,6 +198,7 @@ <DependentUpon>Settings.settings</DependentUpon> <DesignTimeSharedInput>True</DesignTimeSharedInput> </Compile> + <Compile Include="Settings.cs" /> <Compile Include="SimpleMetadata.cs" /> <Compile Include="Strips\AudioStrip.cs" /> <Compile Include="Strips\Manager.cs" /> Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-11 12:58:28 UTC (rev 579) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-11 13:36:57 UTC (rev 580) @@ -39,7 +39,7 @@ ProjectStateChanged += new Events.Project.StateChangedHandler(mProject_StateChanged); GUIUpdateNoProject(); UpdateShowHideTOC(); - GetSettings(); + mSettings = GetSettings(); mUndoStack = new UndoRedoStack(); undo_label = mUndoToolStripMenuItem.Text; redo_label = mRedoToolStripMenuItem.Text; @@ -563,44 +563,33 @@ } /// <summary> - /// Read the settings, or create an empty settings object. + /// Read the settings; missing values are replaced with defaults. /// </summary> - /*private void GetSettings() + private Settings GetSettings() { - mSettings = new Settings(); - mSettings.RecentProjects = new ArrayList(); - ClearRecentList(); - mSettings.UserProfile = new UserProfile(); - Console.WriteLine(mSettings.UserProfile); - mSettings.IdTemplate = "obi_####"; - mSettings.DefaultPath = Environment.CurrentDirectory; - }*/ - - private void GetSettings() - { - mSettings = new Settings(); + IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForDomain(); try { - IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForDomain(); IsolatedStorageFileStream stream = new IsolatedStorageFileStream(SettingsFileName, FileMode.Open, FileAccess.Read, file); - MessageBox.Show("OK (stream)", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); SoapFormatter soap = new SoapFormatter(); mSettings = (Settings)soap.Deserialize(stream); - ClearRecentList(); - for (int i = mSettings.RecentProjects.Count - 1; i >= 0; --i) - { - //AddRecentProject((string) mSettings.RecentProjects[i]); - Console.WriteLine("Add {0} ({1})", (string)mSettings.RecentProjects[i], i); - } - MessageBox.Show("OK (deserialize)", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); stream.Close(); } - catch (Exception e) + catch (Exception) { - mSettings.RecentProjects = new ArrayList(); - ClearRecentList(); + mSettings = new Settings(); } + if (mSettings.RecentProjects == null) mSettings.RecentProjects = new ArrayList(); + ClearRecentList(); + for (int i = mSettings.RecentProjects.Count - 1; i >= 0; --i) + { + AddRecentProject((string)mSettings.RecentProjects[i]); + } + if (mSettings.UserProfile == null) mSettings.UserProfile = new UserProfile(); + if (mSettings.IdTemplate == null) mSettings.IdTemplate = "obi_####"; + if (mSettings.DefaultPath == null) mSettings.DefaultPath = Environment.CurrentDirectory; + return mSettings; } /// <summary> @@ -616,8 +605,6 @@ SoapFormatter soap = new SoapFormatter(); soap.Serialize(stream, mSettings); stream.Close(); - string[] dirs = file.GetFileNames("*.*"); - MessageBox.Show("OK: " + String.Join(" :: ", dirs), "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception x) { @@ -697,16 +684,4 @@ Debug(String.Format(Localizer.Message("debug_appended_strip"), par)); } } - - /// <summary> - /// Various persistent application settings. - /// </summary> - [Serializable()] - public class Settings - { - public ArrayList RecentProjects; // paths to projects recently opened - public UserProfile UserProfile; // the user profile - public string IdTemplate; // identifier template - public string DefaultPath; // default location - } } \ No newline at end of file Modified: trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.Designer.cs 2006-07-11 12:58:28 UTC (rev 579) +++ trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.Designer.cs 2006-07-11 13:36:57 UTC (rev 580) @@ -30,8 +30,8 @@ { this.label1 = new System.Windows.Forms.Label(); this.mSplitContainer = new System.Windows.Forms.SplitContainer(); - this.ncxPanel1 = new Obi.UserControls.NCXPanel(); this.stripManagerPanel1 = new Obi.UserControls.StripManagerPanel(); + this.tocPanel1 = new Obi.UserControls.TOCPanel(); this.mSplitContainer.Panel1.SuspendLayout(); this.mSplitContainer.Panel2.SuspendLayout(); this.mSplitContainer.SuspendLayout(); @@ -59,7 +59,7 @@ // mSplitContainer.Panel1 // this.mSplitContainer.Panel1.BackColor = System.Drawing.Color.Transparent; - this.mSplitContainer.Panel1.Controls.Add(this.ncxPanel1); + this.mSplitContainer.Panel1.Controls.Add(this.tocPanel1); // // mSplitContainer.Panel2 // @@ -69,15 +69,6 @@ this.mSplitContainer.SplitterDistance = 210; this.mSplitContainer.TabIndex = 1; // - // ncxPanel1 - // - this.ncxPanel1.BackColor = System.Drawing.SystemColors.Control; - this.ncxPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.ncxPanel1.Location = new System.Drawing.Point(0, 0); - this.ncxPanel1.Name = "ncxPanel1"; - this.ncxPanel1.Size = new System.Drawing.Size(210, 330); - this.ncxPanel1.TabIndex = 2; - // // stripManagerPanel1 // this.stripManagerPanel1.BackColor = System.Drawing.Color.Transparent; @@ -87,6 +78,14 @@ this.stripManagerPanel1.Size = new System.Drawing.Size(417, 330); this.stripManagerPanel1.TabIndex = 0; // + // tocPanel1 + // + this.tocPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tocPanel1.Location = new System.Drawing.Point(0, 0); + this.tocPanel1.Name = "tocPanel1"; + this.tocPanel1.Size = new System.Drawing.Size(210, 330); + this.tocPanel1.TabIndex = 0; + // // ProjectPanel // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -108,8 +107,8 @@ private System.Windows.Forms.Label label1; private System.Windows.Forms.SplitContainer mSplitContainer; - private NCXPanel ncxPanel1; private StripManagerPanel stripManagerPanel1; + private TOCPanel tocPanel1; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-07-11 13:46:04
|
Revision: 581 Author: julienq Date: 2006-07-11 06:45:46 -0700 (Tue, 11 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=581&view=rev Log Message: ----------- Added missing event files Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/ObiForm.cs trunk/urakawa/application/Obi/Obi/messages.Designer.cs trunk/urakawa/application/Obi/Obi/messages.resx Added Paths: ----------- trunk/urakawa/application/Obi/Obi/Events/Node/ trunk/urakawa/application/Obi/Obi/Events/Node/CreatedEventArgs.cs Added: trunk/urakawa/application/Obi/Obi/Events/Node/CreatedEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/CreatedEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Node/CreatedEventArgs.cs 2006-07-11 13:45:46 UTC (rev 581) @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using urakawa.core; + +namespace Obi.Events.Node +{ + public delegate void CreatedHandler(object sender, CreatedEventArgs e); + + /// <summary> + /// This event indicates that a new core node was created. + /// </summary> + public class CreatedEventArgs : EventArgs + { + private Obi.Project mProject; + private CoreNode mNode; + + public Obi.Project Project + { + get + { + return mProject; + } + } + + public CoreNode Node + { + get + { + return mNode; + } + } + + public CreatedEventArgs(Obi.Project project, CoreNode node) + { + mProject = project; + mNode = node; + } + } +} Property changes on: trunk/urakawa/application/Obi/Obi/Events/Node/CreatedEventArgs.cs ___________________________________________________________________ Name: svn:executable + * Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-11 13:36:57 UTC (rev 580) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-11 13:45:46 UTC (rev 581) @@ -510,7 +510,7 @@ /// </summary> private void GUIUpdateNoProject() { - this.Text = "Obi"; + this.Text = Localizer.Message("obi"); closeProjectToolStripMenuItem.Enabled = false; saveProjectToolStripMenuItem.Enabled = false; saveProjectasToolStripMenuItem.Enabled = false; @@ -528,7 +528,7 @@ /// </summary> private void GUIUpdateSavedProject() { - this.Text = mProject.Metadata.Title + " - Obi"; + this.Text = String.Format("{0} - {1}", mProject.Metadata.Title, Localizer.Message("obi")); closeProjectToolStripMenuItem.Enabled = true; saveProjectToolStripMenuItem.Enabled = false; saveProjectasToolStripMenuItem.Enabled = true; @@ -543,7 +543,7 @@ /// </summary> private void GUIUpdateUnsavedProject() { - this.Text = mProject.Metadata.Title + "* - Obi"; + this.Text = String.Format("{0}* - {1}", mProject.Metadata.Title, Localizer.Message("obi")); closeProjectToolStripMenuItem.Enabled = true; saveProjectToolStripMenuItem.Enabled = true; saveProjectasToolStripMenuItem.Enabled = true; Modified: trunk/urakawa/application/Obi/Obi/messages.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/messages.Designer.cs 2006-07-11 13:36:57 UTC (rev 580) +++ trunk/urakawa/application/Obi/Obi/messages.Designer.cs 2006-07-11 13:45:46 UTC (rev 581) @@ -218,6 +218,15 @@ } /// <summary> + /// Looks up a localized string similar to Obi. + /// </summary> + internal static string obi { + get { + return ResourceManager.GetString("obi", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to Ready.. /// </summary> internal static string ready { Modified: trunk/urakawa/application/Obi/Obi/messages.resx =================================================================== --- trunk/urakawa/application/Obi/Obi/messages.resx 2006-07-11 13:36:57 UTC (rev 580) +++ trunk/urakawa/application/Obi/Obi/messages.resx 2006-07-11 13:45:46 UTC (rev 581) @@ -172,6 +172,9 @@ <data name="no_open_project" xml:space="preserve"> <value>No project is currently open.</value> </data> + <data name="obi" xml:space="preserve"> + <value>Obi</value> + </data> <data name="ready" xml:space="preserve"> <value>Ready.</value> </data> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-07-11 14:07:30
|
Revision: 582 Author: julienq Date: 2006-07-11 07:07:20 -0700 (Tue, 11 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=582&view=rev Log Message: ----------- AddSiblingSectionEvent added Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Obi.csproj Added Paths: ----------- trunk/urakawa/application/Obi/Obi/Events/Node/AddSiblingSectionEventArgs.cs Added: trunk/urakawa/application/Obi/Obi/Events/Node/AddSiblingSectionEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/AddSiblingSectionEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Node/AddSiblingSectionEventArgs.cs 2006-07-11 14:07:20 UTC (rev 582) @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using urakawa.core; + +namespace Obi.Events.Node +{ + public delegate void AddSiblingSectionHandler(object sender, AddSiblingSectionEventArgs e); + + /// <summary> + /// This event is fired when a view wants to add a new sibling section node in the core tree. + /// </summary> + class AddSiblingSectionEventArgs : EventArgs + { + private CoreNode mContextNode; // the node after which to add the new sibling + + public CoreNode ContextNode + { + get + { + return mContextNode; + } + } + + public AddSiblingSectionEventArgs(CoreNode contextNode) + { + mContextNode = contextNode; + } + } +} Property changes on: trunk/urakawa/application/Obi/Obi/Events/Node/AddSiblingSectionEventArgs.cs ___________________________________________________________________ Name: svn:executable + * Modified: trunk/urakawa/application/Obi/Obi/Obi.csproj =================================================================== --- trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-11 13:45:46 UTC (rev 581) +++ trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-11 14:07:20 UTC (rev 582) @@ -92,6 +92,7 @@ <Compile Include="Dialogs\UserProfile.Designer.cs"> <DependentUpon>UserProfile.cs</DependentUpon> </Compile> + <Compile Include="Events\Node\AddSiblingSectionEventArgs.cs" /> <Compile Include="Events\Node\CreatedEventArgs.cs" /> <Compile Include="Events\Project\StateChangedEventArgs.cs" /> <Compile Include="Localizer.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <ju...@us...> - 2006-07-20 00:33:34
|
Revision: 618 Author: julienq Date: 2006-07-19 17:33:09 -0700 (Wed, 19 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=618&view=rev Log Message: ----------- Renaming section is now an event Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Obi.csproj trunk/urakawa/application/Obi/Obi/Project.cs trunk/urakawa/application/Obi/Obi/UserControls/ICoreTreeView.cs trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs Added Paths: ----------- trunk/urakawa/application/Obi/Obi/Events/Node/RenameSectionEventArgs.cs trunk/urakawa/application/Obi/Obi/Events/Sync/RenamedNodeEventArgs.cs Removed Paths: ------------- trunk/urakawa/application/Obi/Obi/Events/Sync/RenamedNode.cs Added: trunk/urakawa/application/Obi/Obi/Events/Node/RenameSectionEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/RenameSectionEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Node/RenameSectionEventArgs.cs 2006-07-20 00:33:09 UTC (rev 618) @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using urakawa.core; + +namespace Obi.Events.Node +{ + public delegate void RenameSectionHandler(object sender, RenameSectionEventArgs e); + + /// <summary> + /// This event is fired when a view wants to rename a section. + /// </summary> + public class RenameSectionEventArgs : EventArgs + { + private CoreNode mNode; // the node to rename + private string mLabel; // the new text label of the node + + public CoreNode Node + { + get + { + return mNode; + } + } + + public string Label + { + get + { + return mLabel; + } + } + + public RenameSectionEventArgs(CoreNode node, string label) + { + mNode = node; + mLabel = label; + } + } +} Property changes on: trunk/urakawa/application/Obi/Obi/Events/Node/RenameSectionEventArgs.cs ___________________________________________________________________ Name: svn:executable + * Deleted: trunk/urakawa/application/Obi/Obi/Events/Sync/RenamedNode.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Sync/RenamedNode.cs 2006-07-20 00:20:16 UTC (rev 617) +++ trunk/urakawa/application/Obi/Obi/Events/Sync/RenamedNode.cs 2006-07-20 00:33:09 UTC (rev 618) @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using urakawa.core; - -namespace Obi.Events.Sync -{ - public delegate void RenamedNodeHandler(object sender, RenamedNodeEventArgs e); - - /// <summary> - /// This event is fired when a node has been renamed. - /// </summary> - public class RenamedNodeEventArgs : EventArgs - { - private CoreNode mNode; // the renamed node - private string mLabel; // its new label (easier to find this way :)) - - public CoreNode Node - { - get - { - return mNode; - } - } - - public string Label - { - get - { - return mLabel; - } - } - - public RenamedNodeEventArgs(CoreNode node, string label) - { - mNode = node; - mLabel = label; - } - } -} Copied: trunk/urakawa/application/Obi/Obi/Events/Sync/RenamedNodeEventArgs.cs (from rev 617, trunk/urakawa/application/Obi/Obi/Events/Sync/RenamedNode.cs) =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Sync/RenamedNodeEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Sync/RenamedNodeEventArgs.cs 2006-07-20 00:33:09 UTC (rev 618) @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using urakawa.core; + +namespace Obi.Events.Sync +{ + public delegate void RenamedNodeHandler(object sender, RenamedNodeEventArgs e); + + /// <summary> + /// This event is fired when a node has been renamed. + /// </summary> + public class RenamedNodeEventArgs : EventArgs + { + private object mOrigin; // the originator of the request + private CoreNode mNode; // the renamed node + private string mLabel; // its new label (easier to find this way :)) + + public object Origin + { + get + { + return mOrigin; + } + } + + public CoreNode Node + { + get + { + return mNode; + } + } + + public string Label + { + get + { + return mLabel; + } + } + + public RenamedNodeEventArgs(object origin, CoreNode node, string label) + { + mOrigin = origin; + mNode = node; + mLabel = label; + } + } +} Modified: trunk/urakawa/application/Obi/Obi/Obi.csproj =================================================================== --- trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-20 00:20:16 UTC (rev 617) +++ trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-20 00:33:09 UTC (rev 618) @@ -103,10 +103,12 @@ <Compile Include="Events\Node\LimitViewToSectionDepthEventArgs.cs" /> <Compile Include="Events\Node\MoveSectionDownEventArgs.cs" /> <Compile Include="Events\Node\MoveSectionUpEventArgs.cs" /> + <Compile Include="Events\Node\RenameSectionEventArgs.cs" /> <Compile Include="Events\Project\StateChangedEventArgs.cs" /> <Compile Include="Events\Sync\AddedChildNodeEventArgs.cs" /> <Compile Include="Events\Sync\AddedSiblingNodeEventArgs.cs" /> <Compile Include="Events\Sync\DeletedNodeEventArgs.cs" /> + <Compile Include="Events\Sync\RenamedNodeEventArgs.cs" /> <Compile Include="Localizer.cs" /> <Compile Include="messages.Designer.cs"> <AutoGen>True</AutoGen> Modified: trunk/urakawa/application/Obi/Obi/Project.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-20 00:20:16 UTC (rev 617) +++ trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-20 00:33:09 UTC (rev 618) @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Text; @@ -31,6 +32,7 @@ public event Events.Sync.AddedChildNodeHandler AddedChildNode; public event Events.Sync.AddedSiblingNodeHandler AddedSiblingNode; public event Events.Sync.DeletedNodeHandler DeletedNode; + public event Events.Sync.RenamedNodeHandler RenamedNode; /// <summary> /// This flag is set to true if the project contains modifications that have not been saved. @@ -328,6 +330,46 @@ //mUnsaved = true; } + /// <summary> + /// Change the text label of a node. + /// </summary> + public void RenameNode(object sender, Events.Node.RenameSectionEventArgs e) + { + GetTextMedia(e.Node).setText(e.Label); + RenamedNode(this, new Events.Sync.RenamedNodeEventArgs(sender, e.Node, e.Label)); + mUnsaved = true; + } + #endregion + + /// <summary> + /// Get the text media of a core node. The result can then be used to get or set the text of a node. + /// Original comments: A helper function to get the text from the given <see cref="CoreNode"/>. + /// The text channel which contains the desired text will be named so that we know + /// what its purpose is (ie, "DefaultText" or "PrimaryText") + /// @todo + /// Otherwise we should use the default, only, or randomly first text channel found. + /// </summary> + /// <remarks>This replaces get/setCoreNodeText. E.g. getCoreNodeText(node) = GetTextMedia(node).getText()</remarks> + /// <remarks>This is taken from TOCPanel, and should probably be a node method; + /// we would subclass CoreNode fort his.</remarks> + /// <param name="node">The node which text media we are interested in.</param> + /// <returns>The text media found, or null if none.</returns> + public static TextMedia GetTextMedia(CoreNode node) + { + ChannelsProperty channelsProp = (ChannelsProperty)node.getProperty(typeof(ChannelsProperty)); + Channel textChannel; + IList channelsList = channelsProp.getListOfUsedChannels(); + for (int i = 0; i < channelsList.Count; i++) + { + string channelName = ((IChannel)channelsList[i]).getName(); + if (channelName == Project.TEXT_CHANNEL) + { + textChannel = (Channel)channelsList[i]; + return (TextMedia)channelsProp.getMedia(textChannel); + } + } + return null; + } } } \ No newline at end of file Modified: trunk/urakawa/application/Obi/Obi/UserControls/ICoreTreeView.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/ICoreTreeView.cs 2006-07-20 00:20:16 UTC (rev 617) +++ trunk/urakawa/application/Obi/Obi/UserControls/ICoreTreeView.cs 2006-07-20 00:33:09 UTC (rev 618) @@ -27,14 +27,14 @@ /// </summary> /// <param name="newNode">The newly created node.</param> /// <param name="relNode">Its preceding sibling node.</param> - void AddNewSiblingSection(CoreNode newNode, CoreNode relNode); + //void AddNewSiblingSection(CoreNode newNode, CoreNode relNode); /// <summary> /// Add a new heading as a child of the relative node. /// </summary> /// <param name="newNode">The new heading to add to the tree</param> /// <param name="relNode">The parent node for the new heading</param> - void AddNewChildSection(CoreNode newNode, CoreNode relNode); + //void AddNewChildSection(CoreNode newNode, CoreNode relNode); void MoveCurrentSectionUp(); @@ -47,6 +47,6 @@ /// <summary> /// Edit the label of the currently selected heading. /// </summary> - void BeginEditingNodeLabel(CoreNode node); + //void BeginEditingNodeLabel(CoreNode node); } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-20 00:20:16 UTC (rev 617) +++ trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-20 00:33:09 UTC (rev 618) @@ -36,6 +36,8 @@ mProject.AddedSiblingNode += new Events.Sync.AddedSiblingNodeHandler(mTOCPanel.SyncAddedSiblingNode); mTOCPanel.MoveSectionUp += new Events.Node.MoveSectionUpHandler(mProject.MoveNodeUp); mTOCPanel.DeleteSection += new Events.Node.DeleteSectionHandler(mProject.RemoveNode); + mTOCPanel.RenameSection += new Events.Node.RenameSectionHandler(mProject.RenameNode); + mProject.RenamedNode += new Events.Sync.RenamedNodeHandler(mTOCPanel.SyncRenamedNode); } } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-20 00:20:16 UTC (rev 617) +++ trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-20 00:33:09 UTC (rev 618) @@ -28,6 +28,7 @@ public event Events.Node.LimitViewToSectionDepthHandler LimitDepthOfView; public event Events.Node.MoveSectionDownHandler MoveSectionDown; public event Events.Node.MoveSectionUpHandler MoveSectionUp; + public event Events.Node.RenameSectionHandler RenameSection; /// <summary> /// Test whether a node is currently selected or not. @@ -79,7 +80,7 @@ { if (node.getParent() != null) { - string label = GetTextMedia((CoreNode)node).getText(); + string label = Project.GetTextMedia((CoreNode)node).getText(); System.Windows.Forms.TreeNode newTreeNode; if (node.getParent().getParent() != null) { @@ -128,7 +129,7 @@ /// </summary> /// <param name="newNode">The new heading to add to the tree</param> /// <param name="relNode">The relative sibling node</param> - public void AddNewSiblingSection(CoreNode newNode, CoreNode relNode) + /*public void AddNewSiblingSection(CoreNode newNode, CoreNode relNode) { System.Windows.Forms.TreeNode relTreeNode = findTreeNodeFromCoreNode(relNode); string label = GetTextMedia(newNode).getText(); @@ -149,7 +150,7 @@ newTreeNode.ExpandAll(); newTreeNode.EnsureVisible(); tocTree.SelectedNode = newTreeNode; - } + }*/ /// <summary> /// Add a new heading as a child of the relative node. @@ -164,7 +165,7 @@ /// </summary> /// <param name="newNode">The new heading to add to the tree</param> /// <param name="relNode">The parent node for the new heading</param> - public void AddNewChildSection(CoreNode newNode, CoreNode relNode) + /*public void AddNewChildSection(CoreNode newNode, CoreNode relNode) { System.Windows.Forms.TreeNode newTreeNode; string label = GetTextMedia(newNode).getText(); @@ -181,7 +182,7 @@ newTreeNode.ExpandAll(); newTreeNode.EnsureVisible(); tocTree.SelectedNode = newTreeNode; - } + }*/ /// <summary> /// Delete a section from the table contents. The core node was removed from the core tree. @@ -200,12 +201,12 @@ /// Begin editing the label (activate the edit cursor) for the currently /// selected section heading node. /// </summary> - public void BeginEditingNodeLabel(CoreNode node) + /*public void BeginEditingNodeLabel(CoreNode node) { System.Windows.Forms.TreeNode treeNode = findTreeNodeFromCoreNode(node); treeNode.EnsureVisible(); treeNode.BeginEdit(); - } + }*/ /* * you might move left if you go up and down @@ -438,29 +439,32 @@ new Events.Node.DecreaseSectionLevelEventArgs(GetSelectedSection())); } + /// <summary> + /// The user has edited a label in the tree, so an event is raised to rename the node. + /// </summary> private void tocTree_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { - // this will likely be replaced with the raising of an event - // to signal that the label has changed - // if a change has actually occurred, the label is not null. if (e.Label != null) { - CoreNode node = (CoreNode)e.Node.Tag; if (e.Label == "") { + // Normally, the toolkit would cause an exception for an empty string; + // but it's easier to catch it here and cancel the event. + // In any case I am not sure that the behavior of the toolkit is good + // in this situation. e.CancelEdit = true; MessageBox.Show(Localizer.Message("empty_label_warning_text"), Localizer.Message("empty_label_warning_caption"), - MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } - else + else if (e.Label != Project.GetTextMedia((CoreNode)e.Node.Tag).getText()) { - GetTextMedia(node).setText(e.Label); + RenameSection(this, new Events.Node.RenameSectionEventArgs((CoreNode)e.Node.Tag, e.Label)); } } } - /// <summary> + /// <summary> /// helper function to get a channel based on its name /// </summary> /// <param name="node">the node (points to its own presentation)</param> @@ -508,7 +512,7 @@ for (int i = 0; i < treeNodes.GetLength(0); i++) { //check the tag field and the text label - if (treeNodes[i].Tag == node && treeNodes[i].Text == GetTextMedia(node).getText()) + if (treeNodes[i].Tag == node && treeNodes[i].Text == Project.GetTextMedia(node).getText()) { foundNode = treeNodes[i]; break; @@ -518,7 +522,7 @@ if (foundNode == null) { throw new Exception(String.Format("Could not find tree node matching core node #{0} with label \"{1}\".", - node.GetHashCode(), GetTextMedia(node).getText())); + node.GetHashCode(), Project.GetTextMedia(node).getText())); } return foundNode; } @@ -538,34 +542,6 @@ } - /// <summary> - /// Get the text media of a core node. The result can then be used to get or set the text of a node. - /// Original comments: A helper function to get the text from the given <see cref="CoreNode"/>. - /// The text channel which contains the desired text will be named so that we know - /// what its purpose is (ie, "DefaultText" or "PrimaryText") - /// @todo - /// Otherwise we should use the default, only, or randomly first text channel found. - /// </summary> - /// <remarks>This replaces get/setCoreNodeText. E.g. getCoreNodeText(node) = GetTextMedia(node).getText()</remarks> - /// <param name="node">The node which text media we are interested in.</param> - /// <returns>The text media found, or null if none.</returns> - private static TextMedia GetTextMedia(CoreNode node) - { - ChannelsProperty channelsProp = (ChannelsProperty)node.getProperty(typeof(ChannelsProperty)); - Channel textChannel; - IList channelsList = channelsProp.getListOfUsedChannels(); - for (int i = 0; i < channelsList.Count; i++) - { - string channelName = ((IChannel)channelsList[i]).getName(); - if (channelName == Project.TEXT_CHANNEL) - { - textChannel = (Channel)channelsList[i]; - return (TextMedia)channelsProp.getMedia(textChannel); - } - } - return null; - } - #region Sync event handlers /// <summary> @@ -575,7 +551,7 @@ internal void SyncAddedChildNode(object sender, Events.Sync.AddedChildNodeEventArgs e) { System.Windows.Forms.TreeNode newTreeNode; - string label = GetTextMedia(e.Node).getText(); + string label = Project.GetTextMedia(e.Node).getText(); if (e.Node.getParent().getParent() != null) { System.Windows.Forms.TreeNode relTreeNode = findTreeNodeFromCoreNode((CoreNode)e.Node.getParent()); @@ -595,7 +571,7 @@ internal void SyncAddedSiblingNode(object sender, Events.Sync.AddedSiblingNodeEventArgs e) { System.Windows.Forms.TreeNode relTreeNode = findTreeNodeFromCoreNode(e.ContextNode); - string label = GetTextMedia(e.Node).getText(); + string label = Project.GetTextMedia(e.Node).getText(); //add as a sibling System.Windows.Forms.TreeNodeCollection siblingCollection = null; if (relTreeNode.Parent != null) @@ -616,6 +592,15 @@ newTreeNode.BeginEdit(); } + internal void SyncRenamedNode(object sender, Events.Sync.RenamedNodeEventArgs e) + { + if (e.Origin != this) + { + System.Windows.Forms.TreeNode treeNode = findTreeNodeFromCoreNode(e.Node); + treeNode.Text = e.Label; + } + } + #endregion } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-07-21 10:59:39
|
Revision: 628 Author: julienq Date: 2006-07-21 03:59:22 -0700 (Fri, 21 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=628&view=rev Log Message: ----------- Added strip manager view; needs the new Node class to maintain more easily. Changed back to the main toolkit. Got rid of the ICoreTreeView interface. Save the "CreateTitleSection" preference from New Project dialog. Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Dialogs/NewProject.cs trunk/urakawa/application/Obi/Obi/Obi.csproj trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs trunk/urakawa/application/Obi/Obi/ObiForm.cs trunk/urakawa/application/Obi/Obi/Project.cs trunk/urakawa/application/Obi/Obi/Settings.cs trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs Removed Paths: ------------- trunk/urakawa/application/Obi/Obi/UserControls/ICoreTreeView.cs Modified: trunk/urakawa/application/Obi/Obi/Dialogs/NewProject.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Dialogs/NewProject.cs 2006-07-21 09:11:20 UTC (rev 627) +++ trunk/urakawa/application/Obi/Obi/Dialogs/NewProject.cs 2006-07-21 10:59:22 UTC (rev 628) @@ -40,6 +40,10 @@ { return mAutoTitleCheckBox.Checked; } + set + { + mAutoTitleCheckBox.Checked = value; + } } /// <summary> Modified: trunk/urakawa/application/Obi/Obi/Obi.csproj =================================================================== --- trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-21 09:11:20 UTC (rev 627) +++ trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-21 10:59:22 UTC (rev 628) @@ -57,9 +57,9 @@ <Reference Include="System.Runtime.Serialization.Formatters.Soap" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml" /> - <Reference Include="urakawa, Version=1.0.2392.27158, Culture=neutral, processorArchitecture=MSIL"> + <Reference Include="urakawa, Version=1.0.2393.35010, Culture=neutral, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> - <HintPath>..\..\..\..\..\branches\port-implementation-to-VS2005\implementation\UrakawaToolkit\bin\Debug\urakawa.dll</HintPath> + <HintPath>..\..\..\implementation\UrakawaToolkit\bin\Debug\urakawa.dll</HintPath> </Reference> <Reference Include="UrakawaApplicationBackend, Version=1.0.2368.31351, Culture=neutral"> <SpecificVersion>False</SpecificVersion> @@ -93,7 +93,6 @@ <Compile Include="Dialogs\UserProfile.Designer.cs"> <DependentUpon>UserProfile.cs</DependentUpon> </Compile> - <Compile Include="Events\Node\CreateEventArgs.cs" /> <Compile Include="Events\Node\DeleteSectionEventArgs.cs" /> <Compile Include="Events\Node\ExpandViewToAllDepthsEventArgs.cs" /> <Compile Include="Events\Node\AddChildSectionEventArgs.cs" /> @@ -159,6 +158,10 @@ <SubType>Designer</SubType> <DependentUpon>ProjectPanel.cs</DependentUpon> </EmbeddedResource> + <EmbeddedResource Include="UserControls\SectionStrip.resx"> + <SubType>Designer</SubType> + <DependentUpon>SectionStrip.cs</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="UserControls\StripManagerPanel.resx"> <SubType>Designer</SubType> <DependentUpon>StripManagerPanel.cs</DependentUpon> @@ -184,13 +187,20 @@ </Compile> <Compile Include="Settings.cs" /> <Compile Include="SimpleMetadata.cs" /> - <Compile Include="UserControls\ICoreTreeView.cs" /> + <Compile Include="Strips\SectionStrip.cs" /> + <Compile Include="Strips\Strip.cs" /> <Compile Include="UserControls\ProjectPanel.cs"> <SubType>UserControl</SubType> </Compile> <Compile Include="UserControls\ProjectPanel.Designer.cs"> <DependentUpon>ProjectPanel.cs</DependentUpon> </Compile> + <Compile Include="UserControls\SectionStrip.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="UserControls\SectionStrip.Designer.cs"> + <DependentUpon>SectionStrip.cs</DependentUpon> + </Compile> <Compile Include="UserControls\StripManagerPanel.cs"> <SubType>UserControl</SubType> </Compile> Modified: trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs 2006-07-21 09:11:20 UTC (rev 627) +++ trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs 2006-07-21 10:59:22 UTC (rev 628) @@ -46,9 +46,6 @@ this.metadataToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.touchProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.tocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.addSectionAtSameLevelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.addSubsectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.deleteSectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.tableOfContentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -57,6 +54,7 @@ this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.mProjectPanel = new Obi.UserControls.ProjectPanel(); + this.mAddSectionAtSameLevelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); @@ -185,45 +183,25 @@ // metadataToolStripMenuItem // this.metadataToolStripMenuItem.Name = "metadataToolStripMenuItem"; - this.metadataToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.metadataToolStripMenuItem.Size = new System.Drawing.Size(140, 22); this.metadataToolStripMenuItem.Text = "&Metadata"; this.metadataToolStripMenuItem.Click += new System.EventHandler(this.metadataToolStripMenuItem_Click); // // touchProjectToolStripMenuItem // this.touchProjectToolStripMenuItem.Name = "touchProjectToolStripMenuItem"; - this.touchProjectToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.touchProjectToolStripMenuItem.Size = new System.Drawing.Size(140, 22); this.touchProjectToolStripMenuItem.Text = "&Touch project"; this.touchProjectToolStripMenuItem.Click += new System.EventHandler(this.touchProjectToolStripMenuItem_Click); // // tocToolStripMenuItem // this.tocToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.addSectionAtSameLevelToolStripMenuItem, - this.addSubsectionToolStripMenuItem, - this.deleteSectionToolStripMenuItem}); + this.mAddSectionAtSameLevelToolStripMenuItem}); this.tocToolStripMenuItem.Name = "tocToolStripMenuItem"; this.tocToolStripMenuItem.Size = new System.Drawing.Size(40, 20); this.tocToolStripMenuItem.Text = "TO&C"; // - // addSectionAtSameLevelToolStripMenuItem - // - this.addSectionAtSameLevelToolStripMenuItem.Name = "addSectionAtSameLevelToolStripMenuItem"; - this.addSectionAtSameLevelToolStripMenuItem.Size = new System.Drawing.Size(204, 22); - this.addSectionAtSameLevelToolStripMenuItem.Text = "Add §ion at same level"; - // - // addSubsectionToolStripMenuItem - // - this.addSubsectionToolStripMenuItem.Name = "addSubsectionToolStripMenuItem"; - this.addSubsectionToolStripMenuItem.Size = new System.Drawing.Size(204, 22); - this.addSubsectionToolStripMenuItem.Text = "&Add sub-section"; - // - // deleteSectionToolStripMenuItem - // - this.deleteSectionToolStripMenuItem.Name = "deleteSectionToolStripMenuItem"; - this.deleteSectionToolStripMenuItem.Size = new System.Drawing.Size(204, 22); - this.deleteSectionToolStripMenuItem.Text = "&Delete section"; - // // viewToolStripMenuItem // this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -291,6 +269,12 @@ this.mProjectPanel.Size = new System.Drawing.Size(767, 450); this.mProjectPanel.TabIndex = 4; // + // mAddSectionAtSameLevelToolStripMenuItem + // + this.mAddSectionAtSameLevelToolStripMenuItem.Name = "mAddSectionAtSameLevelToolStripMenuItem"; + this.mAddSectionAtSameLevelToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.mAddSectionAtSameLevelToolStripMenuItem.Text = "&Add section at same level"; + // // ObiForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -341,9 +325,7 @@ private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem tableOfContentsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem tocToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem addSubsectionToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem addSectionAtSameLevelToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem deleteSectionToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem mAddSectionAtSameLevelToolStripMenuItem; } Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-21 09:11:20 UTC (rev 627) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-21 10:59:22 UTC (rev 628) @@ -47,6 +47,7 @@ private void mNewProjectToolStripMenuItem_Click(object sender, EventArgs e) { Dialogs.NewProject dialog = new Dialogs.NewProject(mSettings.DefaultPath); + dialog.CreateTitleSection = mSettings.CreateTitleSection; if (dialog.ShowDialog() == DialogResult.OK) { if (ClosedProject()) @@ -55,6 +56,7 @@ mProject.StateChanged += new Obi.Events.Project.StateChangedHandler(mProject_StateChanged); mProject.Create(dialog.Path, dialog.Title, mSettings.IdTemplate, mSettings.UserProfile, dialog.CreateTitleSection); + mSettings.CreateTitleSection = dialog.CreateTitleSection; } else { @@ -285,20 +287,12 @@ FormUpdateModifiedProject(); break; case Obi.Events.Project.StateChange.Opened: - FormUpdateOpenedProject(); mProjectPanel.Project = mProject; mProjectPanel.Clear(); mProjectPanel.SynchronizeWithCoreTree(mProject.getPresentation().getRootNode()); - /*tableOfContentsToolStripMenuItem.Enabled = true; - addSubsectionToolStripMenuItem.Click += - new System.EventHandler(mProjectPanel.TOCPanel.addSubSectionToolStripMenuItem_Click); - addSectionAtSameLevelToolStripMenuItem.Click += + mAddSectionAtSameLevelToolStripMenuItem.Click += new System.EventHandler(mProjectPanel.TOCPanel.addSectionAtSameLevelToolStripMenuItem_Click); - moveSectionupToolStripMenuItem.Click += - new System.EventHandler(mProjectPanel.TOCPanel.moveUpToolStripMenuItem_Click); - deleteSectionToolStripMenuItem.Click += - new System.EventHandler(mProjectPanel.TOCPanel.deleteSectionToolStripMenuItem_Click); - FormUpdateShowHideTOC();*/ + FormUpdateOpenedProject(); break; case Obi.Events.Project.StateChange.Saved: FormUpdateSavedProject(); @@ -405,10 +399,10 @@ private void FormUpdateClosedProject() { this.Text = Localizer.Message("obi"); - mSaveProjectToolStripMenuItem.Enabled = false; // cannot save - mSaveProjectasToolStripMenuItem.Enabled = false; // cannot save as - mDiscardChangesToolStripMenuItem.Enabled = false; // cannot discard changes - mCloseProjectToolStripMenuItem.Enabled = false; // cannot close + mSaveProjectToolStripMenuItem.Enabled = false; // cannot save + mSaveProjectasToolStripMenuItem.Enabled = false; // cannot save as + mDiscardChangesToolStripMenuItem.Enabled = false; // cannot discard changes + mCloseProjectToolStripMenuItem.Enabled = false; // cannot close foreach (ToolStripItem item in editToolStripMenuItem.DropDownItems) // cannot do any edit { item.Enabled = false; @@ -433,23 +427,29 @@ } /// <summary> - /// Update the form to reflect enabled/disabled actions when no project is opened. + /// Update the form to reflect enabled/disabled actions when a project is opened. /// </summary> private void FormUpdateOpenedProject() { - FormUpdateSavedProject(); + this.Text = String.Format("{0} - {1}", mProject.Metadata.Title, Localizer.Message("obi")); + mSaveProjectToolStripMenuItem.Enabled = false; mSaveProjectasToolStripMenuItem.Enabled = true; + mDiscardChangesToolStripMenuItem.Enabled = false; mCloseProjectToolStripMenuItem.Enabled = true; - FormUpdateShowHideTOC(); - foreach (ToolStripItem item in editToolStripMenuItem.DropDownItems) // cannot do any edit + foreach (ToolStripItem item in editToolStripMenuItem.DropDownItems) // can do edits { item.Enabled = true; } - foreach (ToolStripItem item in viewToolStripMenuItem.DropDownItems) // cannot change view + foreach (ToolStripItem item in tocToolStripMenuItem.DropDownItems) // can modify the TOC { item.Enabled = true; } - mProjectPanel.Project = null; + foreach (ToolStripItem item in viewToolStripMenuItem.DropDownItems) // can change view + { + item.Enabled = true; + } + FormUpdateShowHideTOC(); + toolStripStatusLabel1.Text = String.Format(Localizer.Message("opened_project"), mProject.XUKPath); } /// <summary> @@ -464,7 +464,7 @@ } /// <summary> - /// Update the form to reflect enabled/disabled actions when the project is unsaved. + /// Update the form to reflect enabled/disabled actions when the project is modified. /// </summary> private void FormUpdateModifiedProject() { Modified: trunk/urakawa/application/Obi/Obi/Project.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-21 09:11:20 UTC (rev 627) +++ trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-21 10:59:22 UTC (rev 628) @@ -30,9 +30,9 @@ private string mLastPath; // last path to which the project was saved (see save as) private SimpleMetadata mMetadata; // metadata for this project - public static readonly string AUDIO_CHANNEL = "obi.audio"; // canonical name of the audio channel - public static readonly string TEXT_CHANNEL = "obi.text"; // canonical name of the text channel - public static readonly string ANNOTATION_CHANNEL = "obi.annotation"; // canonical name of the annotation channel + public static readonly string AudioChannel = "obi.audio"; // canonical name of the audio channel + public static readonly string TextChannel = "obi.text"; // canonical name of the text channel + public static readonly string AnnotationChannel = "obi.annotation"; // canonical name of the annotation channel public event Events.Project.StateChangedHandler StateChanged; // the state of the project changed (modified, saved...) public event Events.Sync.AddedChildNodeHandler AddedChildNode; // a new child node was added to the presentation @@ -111,11 +111,11 @@ { mXUKPath = xukPath; mMetadata = CreateMetadata(title, id, userProfile); - mAudioChannel = getPresentation().getChannelFactory().createChannel(AUDIO_CHANNEL); + mAudioChannel = getPresentation().getChannelFactory().createChannel(AudioChannel); getPresentation().getChannelsManager().addChannel(mAudioChannel); - mTextChannel = getPresentation().getChannelFactory().createChannel(TEXT_CHANNEL); + mTextChannel = getPresentation().getChannelFactory().createChannel(TextChannel); getPresentation().getChannelsManager().addChannel(mTextChannel); - mAnnotationChannel = getPresentation().getChannelFactory().createChannel(ANNOTATION_CHANNEL); + mAnnotationChannel = getPresentation().getChannelFactory().createChannel(AnnotationChannel); getPresentation().getChannelsManager().addChannel(mAnnotationChannel); if (createTitle) { @@ -138,9 +138,9 @@ { mUnsaved = false; mXUKPath = xukPath; - mAudioChannel = FindChannel(AUDIO_CHANNEL); - mTextChannel = FindChannel(TEXT_CHANNEL); - mAnnotationChannel = FindChannel(ANNOTATION_CHANNEL); + mAudioChannel = FindChannel(AudioChannel); + mTextChannel = FindChannel(TextChannel); + mAnnotationChannel = FindChannel(AnnotationChannel); mMetadata = new SimpleMetadata(); foreach (object o in getMetadataList()) { @@ -368,21 +368,6 @@ } /// <summary> - /// Create a new section node with a default text label. The node is not attached to anything. - /// TODO: this should be a constructor/factory method for our derived node class. - /// </summary> - /// <returns>The created node.</returns> - private CoreNode CreateSectionNode() - { - CoreNode node = getPresentation().getCoreNodeFactory().createNode(); - ChannelsProperty prop = (ChannelsProperty)node.getProperty(typeof(ChannelsProperty)); - TextMedia text = (TextMedia)getPresentation().getMediaFactory().createMedia(MediaType.TEXT); - text.setText(Localizer.Message("default_section_label")); - prop.setMedia(mTextChannel, text); - return node; - } - - /// <summary> /// Remove a node from the core tree (simply detach it, and synchronize the views.) /// </summary> public void RemoveNode(object origin, CoreNode node) @@ -432,6 +417,21 @@ #endregion /// <summary> + /// Create a new section node with a default text label. The node is not attached to anything. + /// TODO: this should be a constructor/factory method for our derived node class. + /// </summary> + /// <returns>The created node.</returns> + private CoreNode CreateSectionNode() + { + CoreNode node = getPresentation().getCoreNodeFactory().createNode(); + ChannelsProperty prop = (ChannelsProperty)node.getProperty(typeof(ChannelsProperty)); + TextMedia text = (TextMedia)getPresentation().getMediaFactory().createMedia(MediaType.TEXT); + text.setText(Localizer.Message("default_section_label")); + prop.setMedia(mTextChannel, text); + return node; + } + + /// <summary> /// Get the text media of a core node. The result can then be used to get or set the text of a node. /// Original comments: A helper function to get the text from the given <see cref="CoreNode"/>. /// The text channel which contains the desired text will be named so that we know @@ -452,7 +452,7 @@ for (int i = 0; i < channelsList.Count; i++) { string channelName = ((IChannel)channelsList[i]).getName(); - if (channelName == Project.TEXT_CHANNEL) + if (channelName == Project.TextChannel) { textChannel = (Channel)channelsList[i]; return (TextMedia)channelsProp.getMedia(textChannel); Modified: trunk/urakawa/application/Obi/Obi/Settings.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Settings.cs 2006-07-21 09:11:20 UTC (rev 627) +++ trunk/urakawa/application/Obi/Obi/Settings.cs 2006-07-21 10:59:22 UTC (rev 628) @@ -15,6 +15,7 @@ /// (this is probably overkill, but it's available.) /// </summary> /// <remarks>It seems that the recent list is not saved, have to investigate...</remarks> + /// <remarks>It also seems that making a change in the class resets the existing settings?</remarks> [Serializable()] public class Settings { @@ -22,6 +23,7 @@ public UserProfile UserProfile; // the user profile public string IdTemplate; // identifier template public string DefaultPath; // default location + public bool CreateTitleSection; // defaulf for "create title section" in new project public static readonly string SettingsFileName = "obi_settings.xml"; // settings file name Deleted: trunk/urakawa/application/Obi/Obi/UserControls/ICoreTreeView.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/ICoreTreeView.cs 2006-07-21 09:11:20 UTC (rev 627) +++ trunk/urakawa/application/Obi/Obi/UserControls/ICoreTreeView.cs 2006-07-21 10:59:22 UTC (rev 628) @@ -1,52 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using urakawa.core; - -namespace Obi.UserControls -{ - /// <summary> - /// Views of the core tree (table of contents tree view and strip view) - /// implement this interface which keeps them in sync with the core tree. - /// </summary> - public interface ICoreTreeView - { - /// <summary> - /// Clear the view: remove all nodes, strips, etc. - /// </summary> - void Clear(); - - /// <summary> - /// Synchronize the view with the core tree. - /// </summary> - void SynchronizeWithCoreTree(CoreNode root); - - /// <summary> - /// A new section node has been added in the core tree. - /// </summary> - /// <param name="newNode">The newly created node.</param> - /// <param name="relNode">Its preceding sibling node.</param> - //void AddNewSiblingSection(CoreNode newNode, CoreNode relNode); - - /// <summary> - /// Add a new heading as a child of the relative node. - /// </summary> - /// <param name="newNode">The new heading to add to the tree</param> - /// <param name="relNode">The parent node for the new heading</param> - //void AddNewChildSection(CoreNode newNode, CoreNode relNode); - - void MoveCurrentSectionUp(); - - /// <summary> - /// Delete a section node. - /// </summary> - /// <param name="node">The node that was removed from the core tree.</param> - void DeleteSectionNode(CoreNode node); - - /// <summary> - /// Edit the label of the currently selected heading. - /// </summary> - //void BeginEditingNodeLabel(CoreNode node); - } -} Modified: trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.Designer.cs 2006-07-21 09:11:20 UTC (rev 627) +++ trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.Designer.cs 2006-07-21 10:59:22 UTC (rev 628) @@ -31,7 +31,7 @@ this.label1 = new System.Windows.Forms.Label(); this.mSplitContainer = new System.Windows.Forms.SplitContainer(); this.mTOCPanel = new Obi.UserControls.TOCPanel(); - this.stripManagerPanel1 = new Obi.UserControls.StripManagerPanel(); + this.mStripManagerPanel = new Obi.UserControls.StripManagerPanel(); this.mSplitContainer.Panel1.SuspendLayout(); this.mSplitContainer.Panel2.SuspendLayout(); this.mSplitContainer.SuspendLayout(); @@ -64,7 +64,7 @@ // mSplitContainer.Panel2 // this.mSplitContainer.Panel2.BackColor = System.Drawing.Color.Transparent; - this.mSplitContainer.Panel2.Controls.Add(this.stripManagerPanel1); + this.mSplitContainer.Panel2.Controls.Add(this.mStripManagerPanel); this.mSplitContainer.Size = new System.Drawing.Size(631, 330); this.mSplitContainer.SplitterDistance = 210; this.mSplitContainer.TabIndex = 1; @@ -77,14 +77,14 @@ this.mTOCPanel.Size = new System.Drawing.Size(210, 330); this.mTOCPanel.TabIndex = 0; // - // stripManagerPanel1 + // mStripManagerPanel // - this.stripManagerPanel1.BackColor = System.Drawing.Color.Transparent; - this.stripManagerPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.stripManagerPanel1.Location = new System.Drawing.Point(0, 0); - this.stripManagerPanel1.Name = "stripManagerPanel1"; - this.stripManagerPanel1.Size = new System.Drawing.Size(417, 330); - this.stripManagerPanel1.TabIndex = 0; + this.mStripManagerPanel.BackColor = System.Drawing.Color.Transparent; + this.mStripManagerPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.mStripManagerPanel.Location = new System.Drawing.Point(0, 0); + this.mStripManagerPanel.Name = "mStripManagerPanel"; + this.mStripManagerPanel.Size = new System.Drawing.Size(417, 330); + this.mStripManagerPanel.TabIndex = 0; // // ProjectPanel // @@ -107,7 +107,7 @@ private System.Windows.Forms.Label label1; private System.Windows.Forms.SplitContainer mSplitContainer; - private StripManagerPanel stripManagerPanel1; + private StripManagerPanel mStripManagerPanel; private TOCPanel mTOCPanel; } Modified: trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-21 09:11:20 UTC (rev 627) +++ trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-21 10:59:22 UTC (rev 628) @@ -30,14 +30,19 @@ mSplitContainer.Panel1Collapsed = false; if (mProject != null) { + mTOCPanel.AddSiblingSection += new Events.Node.AddSiblingSectionHandler(mProject.CreateSiblingSectionRequested); + mProject.AddedSiblingNode += new Events.Sync.AddedSiblingNodeHandler(mTOCPanel.SyncAddedSiblingNode); + mProject.AddedSiblingNode += new Events.Sync.AddedSiblingNodeHandler(mStripManagerPanel.SyncAddedSiblingNode); mTOCPanel.AddChildSection += new Events.Node.AddChildSectionHandler(mProject.CreateChildSectionRequested); mProject.AddedChildNode += new Events.Sync.AddedChildNodeHandler(mTOCPanel.SyncAddedChildNode); - mTOCPanel.AddSiblingSection += new Events.Node.AddSiblingSectionHandler(mProject.CreateSiblingSectionRequested); - mProject.AddedSiblingNode += new Events.Sync.AddedSiblingNodeHandler(mTOCPanel.SyncAddedSiblingNode); + mProject.AddedChildNode += new Events.Sync.AddedChildNodeHandler(mStripManagerPanel.SyncAddedChildNode); + mTOCPanel.MoveSectionUp += new Events.Node.MoveSectionUpHandler(mProject.MoveNodeUpRequested); mTOCPanel.DeleteSection += new Events.Node.DeleteSectionHandler(mProject.RemoveNodeRequested); + mTOCPanel.RenameSection += new Events.Node.RenameSectionHandler(mProject.RenameNodeRequested); mProject.RenamedNode += new Events.Sync.RenamedNodeHandler(mTOCPanel.SyncRenamedNode); + mProject.RenamedNode += new Events.Sync.RenamedNodeHandler(mStripManagerPanel.SyncRenamedNode); } } } @@ -54,7 +59,7 @@ { get { - return stripManagerPanel1; + return mStripManagerPanel; } } @@ -97,6 +102,7 @@ public void SynchronizeWithCoreTree(CoreNode root) { mTOCPanel.SynchronizeWithCoreTree(root); + mStripManagerPanel.SynchronizeWithCoreTree(root); } } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs 2006-07-21 09:11:20 UTC (rev 627) +++ trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs 2006-07-21 10:59:22 UTC (rev 628) @@ -44,6 +44,7 @@ // // mFlowLayoutPanel // + this.mFlowLayoutPanel.BackColor = System.Drawing.Color.Transparent; this.mFlowLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.mFlowLayoutPanel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; this.mFlowLayoutPanel.Location = new System.Drawing.Point(0, 0); Modified: trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-07-21 09:11:20 UTC (rev 627) +++ trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-07-21 10:59:22 UTC (rev 628) @@ -6,13 +6,88 @@ using System.Text; using System.Windows.Forms; +using urakawa.core; + namespace Obi.UserControls { - public partial class StripManagerPanel : UserControl //, ICoreTreeView + /// <summary> + /// This control is a view of all the contents of a project + /// </summary> + public partial class StripManagerPanel : UserControl, ICoreNodeVisitor { + private Dictionary<CoreNode, SectionStrip> mNodeMap; + public StripManagerPanel() { InitializeComponent(); + mNodeMap = new Dictionary<CoreNode, SectionStrip>(); } + + /// <summary> + /// Synchronize the strips view with the core tree. + /// Since we need priviledged access to the class for synchronization, + /// we make it implement ICoreNodeVisitor directly. + /// </summary> + public void SynchronizeWithCoreTree(CoreNode root) + { + mNodeMap.Clear(); + mFlowLayoutPanel.Controls.Clear(); + root.acceptDepthFirst(this); + } + + #region Synchronization visitor + + /// <summary> + /// Do nothing. + /// </summary> + /// <param name="node">The node to do nothing with.</param> + public void postVisit(ICoreNode node) + { + } + + /// <summary> + /// Create a new strip for every core node. Skip the root node. + /// </summary> + /// <param name="node">The node to add to the tree.</param> + /// <returns>True.</returns> + public bool preVisit(ICoreNode node) + { + if (node.getParent() != null) + { + SectionStrip strip = new SectionStrip(); + strip.Label = Project.GetTextMedia((CoreNode)node).getText(); + mNodeMap[(CoreNode)node] = strip; + mFlowLayoutPanel.Controls.Add(strip); + } + return true; + } + + #endregion + + #region Sync event handlers + + internal void SyncAddedSiblingNode(object sender, Events.Sync.AddedSiblingNodeEventArgs e) + { + SectionStrip strip = new SectionStrip(); + strip.Label = Project.GetTextMedia(e.Node).getText(); + mNodeMap[e.Node] = strip; + mFlowLayoutPanel.Controls.Add(strip); + } + + internal void SyncAddedChildNode(object sender, Events.Sync.AddedChildNodeEventArgs e) + { + SectionStrip strip = new SectionStrip(); + strip.Label = Project.GetTextMedia(e.Node).getText(); + mNodeMap[e.Node] = strip; + mFlowLayoutPanel.Controls.Add(strip); + } + + internal void SyncRenamedNode(object sender, Events.Sync.RenamedNodeEventArgs e) + { + SectionStrip strip = mNodeMap[e.Node]; + strip.Label = e.Label; + } + + #endregion } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs 2006-07-21 09:11:20 UTC (rev 627) +++ trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs 2006-07-21 10:59:22 UTC (rev 628) @@ -38,7 +38,6 @@ this.increaseLevelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.editLabelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.decreaseLevelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.deleteSectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.contextMenuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -65,10 +64,9 @@ this.increaseLevelToolStripMenuItem, this.editLabelToolStripMenuItem, this.decreaseLevelToolStripMenuItem, - this.toolStripSeparator1, this.deleteSectionToolStripMenuItem}); this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(205, 208); + this.contextMenuStrip1.Size = new System.Drawing.Size(205, 202); this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); // // addSectionAtSameLevelToolStripMenuItem @@ -120,11 +118,6 @@ this.decreaseLevelToolStripMenuItem.Text = "Decrease level"; this.decreaseLevelToolStripMenuItem.Click += new System.EventHandler(this.decreaseLevelToolStripMenuItem_Click); // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(201, 6); - // // deleteSectionToolStripMenuItem // this.deleteSectionToolStripMenuItem.Name = "deleteSectionToolStripMenuItem"; @@ -155,7 +148,6 @@ private System.Windows.Forms.ToolStripMenuItem increaseLevelToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem decreaseLevelToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem editLabelToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripMenuItem deleteSectionToolStripMenuItem; } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-21 09:11:20 UTC (rev 627) +++ trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-21 10:59:22 UTC (rev 628) @@ -17,11 +17,10 @@ /// change the label, etc. of headings.) /// This control implements the CoreTreeView interface so that it can be synchronized with the core tree. /// </summary> - public partial class TOCPanel : UserControl, ICoreTreeView, ICoreNodeVisitor + public partial class TOCPanel : UserControl, ICoreNodeVisitor { public event Events.Node.AddSiblingSectionHandler AddSiblingSection; public event Events.Node.AddChildSectionHandler AddChildSection; - public event Events.Node.DeleteSectionHandler DeleteSection; public event Events.Node.BeginEditingSectionHeadingLabelHandler BeginEditingLabel; public event Events.Node.DecreaseSectionLevelHandler DecreaseSectionLevel; public event Events.Node.IncreaseSectionLevelHandler IncreaseSectionLevel; @@ -29,6 +28,7 @@ public event Events.Node.MoveSectionDownHandler MoveSectionDown; public event Events.Node.MoveSectionUpHandler MoveSectionUp; public event Events.Node.RenameSectionHandler RenameSection; + public event Events.Node.DeleteSectionHandler DeleteSection; /// <summary> /// Test whether a node is currently selected or not. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-07-21 22:44:20
|
Revision: 632 Author: marisademeglio Date: 2006-07-21 15:44:10 -0700 (Fri, 21 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=632&view=rev Log Message: ----------- Added some vaguely useful debug.print statements Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Project.cs trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs Modified: trunk/urakawa/application/Obi/Obi/Project.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-21 15:43:31 UTC (rev 631) +++ trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-21 22:44:10 UTC (rev 632) @@ -350,6 +350,7 @@ public void CreateSiblingSectionRequested(object sender, Events.Node.AddSiblingSectionEventArgs e) { + System.Diagnostics.Debug.WriteLine("create sibling request from " + sender.ToString() + " with hash: " + sender.GetHashCode()); CreateSiblingSection(sender, e.ContextNode); } Modified: trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-21 15:43:31 UTC (rev 631) +++ trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-21 22:44:10 UTC (rev 632) @@ -33,6 +33,7 @@ mTOCPanel.AddSiblingSection += new Events.Node.AddSiblingSectionHandler(mProject.CreateSiblingSectionRequested); mProject.AddedSiblingNode += new Events.Sync.AddedSiblingNodeHandler(mTOCPanel.SyncAddedSiblingNode); mProject.AddedSiblingNode += new Events.Sync.AddedSiblingNodeHandler(mStripManagerPanel.SyncAddedSiblingNode); + mTOCPanel.AddChildSection += new Events.Node.AddChildSectionHandler(mProject.CreateChildSectionRequested); mProject.AddedChildNode += new Events.Sync.AddedChildNodeHandler(mTOCPanel.SyncAddedChildNode); mProject.AddedChildNode += new Events.Sync.AddedChildNodeHandler(mStripManagerPanel.SyncAddedChildNode); Modified: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-21 15:43:31 UTC (rev 631) +++ trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-21 22:44:10 UTC (rev 632) @@ -381,6 +381,8 @@ /// </summary> internal void addSectionAtSameLevelToolStripMenuItem_Click(object sender, EventArgs e) { + System.Diagnostics.Debug.WriteLine("TOC panel click!\n"); + AddSiblingSection(this, new Events.Node.AddSiblingSectionEventArgs(GetSelectedSection())); } @@ -555,6 +557,9 @@ { System.Windows.Forms.TreeNode newTreeNode; string label = Project.GetTextMedia(e.Node).getText(); + + System.Diagnostics.Debug.WriteLine("TocPanel: SyncAddedChildNode -- " + label); + if (e.Node.getParent().getParent() != null) { System.Windows.Forms.TreeNode relTreeNode = findTreeNodeFromCoreNode((CoreNode)e.Node.getParent()); @@ -573,8 +578,12 @@ internal void SyncAddedSiblingNode(object sender, Events.Sync.AddedSiblingNodeEventArgs e) { + System.Windows.Forms.TreeNode relTreeNode = findTreeNodeFromCoreNode(e.ContextNode); string label = Project.GetTextMedia(e.Node).getText(); + + System.Diagnostics.Debug.WriteLine("TocPanel: SyncAddedSiblingNode -- " + label); + //add as a sibling System.Windows.Forms.TreeNodeCollection siblingCollection = null; if (relTreeNode.Parent != null) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-07-22 04:22:56
|
Revision: 634 Author: julienq Date: 2006-07-21 21:22:47 -0700 (Fri, 21 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=634&view=rev Log Message: ----------- Recent project list is working. (If there is a problem, try deleting your preference file first.) TOC menu is back! On to strip view... Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs trunk/urakawa/application/Obi/Obi/ObiForm.cs trunk/urakawa/application/Obi/Obi/Project.cs trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs Modified: trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs 2006-07-22 02:15:39 UTC (rev 633) +++ trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs 2006-07-22 04:22:47 UTC (rev 634) @@ -45,16 +45,19 @@ this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.metadataToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.touchProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.tocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.tableOfContentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mTocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mShowhideTableOfCOntentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.mStripsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.userSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.preferencesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.mAddSectionAtSameLevelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mAddsubsectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mDeleteSectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mProjectPanel = new Obi.UserControls.ProjectPanel(); - this.mAddSectionAtSameLevelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); @@ -64,8 +67,8 @@ this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem, this.editToolStripMenuItem, - this.tocToolStripMenuItem, - this.viewToolStripMenuItem, + this.mTocToolStripMenuItem, + this.mStripsToolStripMenuItem, this.toolsToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; @@ -122,7 +125,7 @@ // this.mClearListToolStripMenuItem.Name = "mClearListToolStripMenuItem"; this.mClearListToolStripMenuItem.Size = new System.Drawing.Size(117, 22); - this.mClearListToolStripMenuItem.Text = "Clear list"; + this.mClearListToolStripMenuItem.Text = "&Clear list"; this.mClearListToolStripMenuItem.Click += new System.EventHandler(this.mClearListToolStripMenuItem_Click); // // toolStripSeparator2 @@ -194,29 +197,36 @@ this.touchProjectToolStripMenuItem.Text = "&Touch project"; this.touchProjectToolStripMenuItem.Click += new System.EventHandler(this.touchProjectToolStripMenuItem_Click); // - // tocToolStripMenuItem + // mTocToolStripMenuItem // - this.tocToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.mAddSectionAtSameLevelToolStripMenuItem}); - this.tocToolStripMenuItem.Name = "tocToolStripMenuItem"; - this.tocToolStripMenuItem.Size = new System.Drawing.Size(40, 20); - this.tocToolStripMenuItem.Text = "TO&C"; + this.mTocToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mShowhideTableOfCOntentsToolStripMenuItem, + this.toolStripSeparator1, + this.mAddSectionAtSameLevelToolStripMenuItem, + this.mAddsubsectionToolStripMenuItem, + this.mDeleteSectionToolStripMenuItem}); + this.mTocToolStripMenuItem.Name = "mTocToolStripMenuItem"; + this.mTocToolStripMenuItem.Size = new System.Drawing.Size(40, 20); + this.mTocToolStripMenuItem.Text = "TO&C"; // - // viewToolStripMenuItem + // mShowhideTableOfCOntentsToolStripMenuItem // - this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.tableOfContentsToolStripMenuItem}); - this.viewToolStripMenuItem.Name = "viewToolStripMenuItem"; - this.viewToolStripMenuItem.Size = new System.Drawing.Size(42, 20); - this.viewToolStripMenuItem.Text = "&View"; + this.mShowhideTableOfCOntentsToolStripMenuItem.Name = "mShowhideTableOfCOntentsToolStripMenuItem"; + this.mShowhideTableOfCOntentsToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.mShowhideTableOfCOntentsToolStripMenuItem.Text = "Show &table of contents "; + this.mShowhideTableOfCOntentsToolStripMenuItem.Click += new System.EventHandler(this.mShowhideTableOfContentsToolStripMenuItem_Click); // - // tableOfContentsToolStripMenuItem + // toolStripSeparator1 // - this.tableOfContentsToolStripMenuItem.Name = "tableOfContentsToolStripMenuItem"; - this.tableOfContentsToolStripMenuItem.Size = new System.Drawing.Size(153, 22); - this.tableOfContentsToolStripMenuItem.Text = "Show/Hide &TOC"; - this.tableOfContentsToolStripMenuItem.Click += new System.EventHandler(this.tableOfContentsToolStripMenuItem_Click); + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(201, 6); // + // mStripsToolStripMenuItem + // + this.mStripsToolStripMenuItem.Name = "mStripsToolStripMenuItem"; + this.mStripsToolStripMenuItem.Size = new System.Drawing.Size(47, 20); + this.mStripsToolStripMenuItem.Text = "Strips"; + // // toolsToolStripMenuItem // this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -257,6 +267,24 @@ this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; this.toolStripStatusLabel1.Size = new System.Drawing.Size(0, 17); // + // mAddSectionAtSameLevelToolStripMenuItem + // + this.mAddSectionAtSameLevelToolStripMenuItem.Name = "mAddSectionAtSameLevelToolStripMenuItem"; + this.mAddSectionAtSameLevelToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.mAddSectionAtSameLevelToolStripMenuItem.Text = "&Add section at same level"; + // + // mAddsubsectionToolStripMenuItem + // + this.mAddsubsectionToolStripMenuItem.Name = "mAddsubsectionToolStripMenuItem"; + this.mAddsubsectionToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.mAddsubsectionToolStripMenuItem.Text = "Add &sub-section"; + // + // mDeleteSectionToolStripMenuItem + // + this.mDeleteSectionToolStripMenuItem.Name = "mDeleteSectionToolStripMenuItem"; + this.mDeleteSectionToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.mDeleteSectionToolStripMenuItem.Text = "&Delete section"; + // // mProjectPanel // this.mProjectPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -269,12 +297,6 @@ this.mProjectPanel.Size = new System.Drawing.Size(767, 450); this.mProjectPanel.TabIndex = 4; // - // mAddSectionAtSameLevelToolStripMenuItem - // - this.mAddSectionAtSameLevelToolStripMenuItem.Name = "mAddSectionAtSameLevelToolStripMenuItem"; - this.mAddSectionAtSameLevelToolStripMenuItem.Size = new System.Drawing.Size(204, 22); - this.mAddSectionAtSameLevelToolStripMenuItem.Text = "&Add section at same level"; - // // ObiForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -288,6 +310,7 @@ this.Name = "ObiForm"; this.Text = "Obi"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ObiForm_FormClosing); + this.Load += new System.EventHandler(this.ObiForm_Load); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.statusStrip1.ResumeLayout(false); @@ -322,10 +345,13 @@ private System.Windows.Forms.ToolStripMenuItem preferencesToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem metadataToolStripMenuItem; private Obi.UserControls.ProjectPanel mProjectPanel; - private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem tableOfContentsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem tocToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem mTocToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem mStripsToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripMenuItem mShowhideTableOfCOntentsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem mAddSectionAtSameLevelToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem mAddsubsectionToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem mDeleteSectionToolStripMenuItem; } Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-22 02:15:39 UTC (rev 633) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-22 04:22:47 UTC (rev 634) @@ -36,6 +36,8 @@ mSettings = null; mCmdMngr = new Commands.CommandManager(); InitializeSettings(); + + mOpenRecentProjectToolStripMenuItem.Enabled = mSettings.RecentProjects.Count > 0; FormUpdateClosedProject(); // no project opened, same as if we closed a project. } @@ -57,6 +59,7 @@ mProject.Create(dialog.Path, dialog.Title, mSettings.IdTemplate, mSettings.UserProfile, dialog.CreateTitleSection); mSettings.CreateTitleSection = dialog.CreateTitleSection; + AddRecentProject(mProject.XUKPath); } else { @@ -219,7 +222,7 @@ /// <summary> /// Show or hide the NCX panel in the project panel. /// </summary> - private void tableOfContentsToolStripMenuItem_Click(object sender, EventArgs e) + private void mShowhideTableOfContentsToolStripMenuItem_Click(object sender, EventArgs e) { if (mProjectPanel.TOCPanelVisible) { @@ -289,8 +292,6 @@ case Obi.Events.Project.StateChange.Opened: mProjectPanel.Project = mProject; mProjectPanel.SynchronizeWithCoreTree(mProject.getPresentation().getRootNode()); - //mAddSectionAtSameLevelToolStripMenuItem.Click += - // new System.EventHandler(mProjectPanel.TOCPanel.addSectionAtSameLevelToolStripMenuItem_Click); FormUpdateOpenedProject(); break; case Obi.Events.Project.StateChange.Saved: @@ -299,6 +300,19 @@ } } + /// <summary> + /// Setup the TOC and strip menus in the same way as the context menus for TOCPanel and StripManager. + /// </summary> + private void ObiForm_Load(object sender, EventArgs e) + { + mAddSectionAtSameLevelToolStripMenuItem.Click += + new EventHandler(mProjectPanel.TOCPanel.addSectionAtSameLevelToolStripMenuItem_Click); + mAddsubsectionToolStripMenuItem.Click += + new EventHandler(mProjectPanel.TOCPanel.addSubSectionToolStripMenuItem_Click); + mDeleteSectionToolStripMenuItem.Click += + new EventHandler(mProjectPanel.TOCPanel.deleteSectionToolStripMenuItem_Click); + } + #endregion /// <summary> @@ -334,6 +348,7 @@ { MessageBox.Show(e.Message, Localizer.Message("open_project_error_caption"), MessageBoxButtons.OK, MessageBoxIcon.Error); + mProject = null; } } @@ -344,10 +359,9 @@ private void InitializeSettings() { mSettings = Settings.GetSettings(); - ClearRecentList(); for (int i = mSettings.RecentProjects.Count - 1; i >= 0; --i) { - AddRecentProject((string)mSettings.RecentProjects[i]); + AddRecentProjectsItem((string)mSettings.RecentProjects[i]); } } @@ -356,9 +370,9 @@ /// </summary> private void ClearRecentList() { - for (int i = mSettings.RecentProjects.Count - 1; i >= 0; --i) + while (mOpenRecentProjectToolStripMenuItem.DropDownItems.Count > 2) { - mOpenRecentProjectToolStripMenuItem.DropDownItems.RemoveAt(i); + mOpenRecentProjectToolStripMenuItem.DropDownItems.RemoveAt(0); } mSettings.RecentProjects.Clear(); mOpenRecentProjectToolStripMenuItem.Enabled = false; @@ -386,6 +400,15 @@ } } mSettings.RecentProjects.Insert(0, path); + AddRecentProjectsItem(path); + } + + /// <summary> + /// Add an item in the recent projects list + /// </summary> + /// <param name="path">The path of the item to add.</param> + private void AddRecentProjectsItem(string path) + { ToolStripMenuItem item = new ToolStripMenuItem(); item.Text = Path.GetFileName(path); item.Click += new System.EventHandler(delegate(object sender, EventArgs e) { OpenProject(path); }); @@ -406,14 +429,10 @@ { item.Enabled = false; } - foreach (ToolStripItem item in tocToolStripMenuItem.DropDownItems) // cannot modify the TOC + foreach (ToolStripItem item in mTocToolStripMenuItem.DropDownItems) // cannot modify the TOC { item.Enabled = false; } - foreach (ToolStripItem item in viewToolStripMenuItem.DropDownItems) // cannot change view - { - item.Enabled = false; - } mProjectPanel.Project = null; if (mProject == null) { @@ -439,14 +458,10 @@ { item.Enabled = true; } - foreach (ToolStripItem item in tocToolStripMenuItem.DropDownItems) // can modify the TOC + foreach (ToolStripItem item in mTocToolStripMenuItem.DropDownItems) // can modify the TOC { item.Enabled = true; } - foreach (ToolStripItem item in viewToolStripMenuItem.DropDownItems) // can change view - { - item.Enabled = true; - } FormUpdateShowHideTOC(); toolStripStatusLabel1.Text = String.Format(Localizer.Message("opened_project"), mProject.XUKPath); } @@ -480,12 +495,13 @@ /// </summary> private void FormUpdateShowHideTOC() { - tableOfContentsToolStripMenuItem.Text = + mShowhideTableOfCOntentsToolStripMenuItem.Text = Localizer.Message(mProjectPanel.TOCPanelVisible ? "hide_toc_label" : "show_toc_label"); - foreach (ToolStripItem item in tocToolStripMenuItem.DropDownItems) + foreach (ToolStripItem item in mTocToolStripMenuItem.DropDownItems) { item.Enabled = mProjectPanel.TOCPanelVisible; } + mShowhideTableOfCOntentsToolStripMenuItem.Enabled = true; } /// <summary> Modified: trunk/urakawa/application/Obi/Obi/Project.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-22 02:15:39 UTC (rev 633) +++ trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-22 04:22:47 UTC (rev 634) @@ -381,10 +381,13 @@ /// </summary> public void RemoveNode(object origin, CoreNode node) { - node.detach(); - DeletedNode(this, new Events.Sync.DeletedNodeEventArgs(origin, node)); - mUnsaved = true; - StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); + if (node != null) + { + node.detach(); + DeletedNode(this, new Events.Sync.DeletedNodeEventArgs(origin, node)); + mUnsaved = true; + StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); + } } public void RemoveNodeRequested(object sender, Events.Node.DeleteSectionEventArgs e) Modified: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-22 02:15:39 UTC (rev 633) +++ trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-22 04:22:47 UTC (rev 634) @@ -42,6 +42,17 @@ } /// <summary> + /// Get the context menu strip of the tree view so that we can replicate it in the form. + /// </summary> + public ContextMenuStrip TocTreeContextMenuStrip + { + get + { + return tocTree.ContextMenuStrip; + } + } + + /// <summary> /// Synchronize the tree view with the core tree. /// Since we need priviledged access to the class for synchronization, /// we make it implement ICoreNodeVisitor directly. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-07-24 10:58:28
|
Revision: 645 Author: julienq Date: 2006-07-24 03:58:15 -0700 (Mon, 24 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=645&view=rev Log Message: ----------- Some work on the strip manager. Section strips now have a flow layout for the audio strip. Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Obi.csproj trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs trunk/urakawa/application/Obi/Obi/ObiForm.cs trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.cs trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.resx Added Paths: ----------- trunk/urakawa/application/Obi/Obi/DescendantsVisitor.cs Added: trunk/urakawa/application/Obi/Obi/DescendantsVisitor.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/DescendantsVisitor.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/DescendantsVisitor.cs 2006-07-24 10:58:15 UTC (rev 645) @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using urakawa.core; + +namespace Obi +{ + /// <summary> + /// Visitor building a flat list of all descendant nodes (including the root.) + /// </summary> + public class DescendantsVisitor: ICoreNodeVisitor + { + private List<CoreNode> mNodes; + + public List<CoreNode> Nodes + { + get + { + return mNodes; + } + } + + public DescendantsVisitor() + { + mNodes = new List<CoreNode>(); + } + + #region ICoreNodeVisitor Members + + public void postVisit(ICoreNode node) + { + } + + public bool preVisit(ICoreNode node) + { + mNodes.Add((CoreNode)node); + return true; + } + + #endregion + } +} Modified: trunk/urakawa/application/Obi/Obi/Obi.csproj =================================================================== --- trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-24 02:04:30 UTC (rev 644) +++ trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-24 10:58:15 UTC (rev 645) @@ -69,6 +69,7 @@ <ItemGroup> <Compile Include="Commands\CommandManager.cs" /> <Compile Include="Commands\TOC\AddChild.cs" /> + <Compile Include="DescendantsVisitor.cs" /> <Compile Include="Dialogs\EditSimpleMetadata.cs"> <SubType>Form</SubType> </Compile> Modified: trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs 2006-07-24 02:04:30 UTC (rev 644) +++ trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs 2006-07-24 10:58:15 UTC (rev 645) @@ -57,8 +57,9 @@ this.preferencesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.mRenameSectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mAddStripToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mProjectPanel = new Obi.UserControls.ProjectPanel(); - this.mRenameSectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); @@ -243,6 +244,8 @@ // // mStripsToolStripMenuItem // + this.mStripsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mAddStripToolStripMenuItem}); this.mStripsToolStripMenuItem.Name = "mStripsToolStripMenuItem"; this.mStripsToolStripMenuItem.Size = new System.Drawing.Size(47, 20); this.mStripsToolStripMenuItem.Text = "Strips"; @@ -287,6 +290,18 @@ this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; this.toolStripStatusLabel1.Size = new System.Drawing.Size(0, 17); // + // mRenameSectionToolStripMenuItem + // + this.mRenameSectionToolStripMenuItem.Name = "mRenameSectionToolStripMenuItem"; + this.mRenameSectionToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.mRenameSectionToolStripMenuItem.Text = "&Rename section"; + // + // mAddStripToolStripMenuItem + // + this.mAddStripToolStripMenuItem.Name = "mAddStripToolStripMenuItem"; + this.mAddStripToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.mAddStripToolStripMenuItem.Text = "&Add strip"; + // // mProjectPanel // this.mProjectPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -299,12 +314,6 @@ this.mProjectPanel.Size = new System.Drawing.Size(767, 450); this.mProjectPanel.TabIndex = 4; // - // mRenameSectionToolStripMenuItem - // - this.mRenameSectionToolStripMenuItem.Name = "mRenameSectionToolStripMenuItem"; - this.mRenameSectionToolStripMenuItem.Size = new System.Drawing.Size(204, 22); - this.mRenameSectionToolStripMenuItem.Text = "&Rename section"; - // // ObiForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -361,6 +370,7 @@ private System.Windows.Forms.ToolStripMenuItem mAddsubsectionToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem mDeleteSectionToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem mRenameSectionToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem mAddStripToolStripMenuItem; } Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-24 02:04:30 UTC (rev 644) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-24 10:58:15 UTC (rev 645) @@ -313,6 +313,8 @@ new EventHandler(mProjectPanel.TOCPanel.editLabelToolStripMenuItem_Click); mDeleteSectionToolStripMenuItem.Click += new EventHandler(mProjectPanel.TOCPanel.deleteSectionToolStripMenuItem_Click); + mAddStripToolStripMenuItem.Click += + new EventHandler(mProjectPanel.StripManager.addStripToolStripMenuItem_Click); } #endregion Modified: trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-24 02:04:30 UTC (rev 644) +++ trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-24 10:58:15 UTC (rev 645) @@ -29,6 +29,8 @@ if (mProject != null) { mTOCPanel.AddSiblingSection -= new Events.Node.AddSiblingSectionHandler(mProject.CreateSiblingSectionRequested); + mStripManagerPanel.AddSiblingSection -= + new Events.Node.AddSiblingSectionHandler(mProject.CreateSiblingSectionRequested); mProject.AddedSiblingNode -= new Events.Sync.AddedSiblingNodeHandler(mTOCPanel.SyncAddedSiblingNode); mProject.AddedSiblingNode -= new Events.Sync.AddedSiblingNodeHandler(mStripManagerPanel.SyncAddedSiblingNode); @@ -50,6 +52,8 @@ if (value != null) { mTOCPanel.AddSiblingSection += new Events.Node.AddSiblingSectionHandler(value.CreateSiblingSectionRequested); + mStripManagerPanel.AddSiblingSection += + new Events.Node.AddSiblingSectionHandler(value.CreateSiblingSectionRequested); value.AddedSiblingNode += new Events.Sync.AddedSiblingNodeHandler(mTOCPanel.SyncAddedSiblingNode); value.AddedSiblingNode += new Events.Sync.AddedSiblingNodeHandler(mStripManagerPanel.SyncAddedSiblingNode); Modified: trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.Designer.cs 2006-07-24 02:04:30 UTC (rev 644) +++ trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.Designer.cs 2006-07-24 10:58:15 UTC (rev 645) @@ -29,6 +29,7 @@ private void InitializeComponent() { this.mLabel = new System.Windows.Forms.Label(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.SuspendLayout(); // // mLabel @@ -40,17 +41,32 @@ this.mLabel.Size = new System.Drawing.Size(32, 16); this.mLabel.TabIndex = 0; this.mLabel.Text = "xxx"; + this.mLabel.Click += new System.EventHandler(this.SectionStrip_Click); // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.flowLayoutPanel1.AutoSize = true; + this.flowLayoutPanel1.BackColor = System.Drawing.SystemColors.ControlLight; + this.flowLayoutPanel1.Location = new System.Drawing.Point(2, 19); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(236, 58); + this.flowLayoutPanel1.TabIndex = 1; + this.flowLayoutPanel1.WrapContents = false; + // // SectionStrip // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSize = true; this.BackColor = System.Drawing.Color.PaleGreen; + this.Controls.Add(this.flowLayoutPanel1); this.Controls.Add(this.mLabel); this.Margin = new System.Windows.Forms.Padding(0, 0, 0, 3); this.Name = "SectionStrip"; - this.Size = new System.Drawing.Size(295, 49); + this.Size = new System.Drawing.Size(240, 80); + this.Click += new System.EventHandler(this.SectionStrip_Click); this.ResumeLayout(false); this.PerformLayout(); @@ -59,5 +75,6 @@ #endregion private System.Windows.Forms.Label mLabel; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.cs 2006-07-24 02:04:30 UTC (rev 644) +++ trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.cs 2006-07-24 10:58:15 UTC (rev 645) @@ -6,10 +6,15 @@ using System.Text; using System.Windows.Forms; +using urakawa.core; + namespace Obi.UserControls { public partial class SectionStrip : UserControl { + private StripManagerPanel mManager; // the manager for this strip + private CoreNode mNode; // the core node for this strip + public string Label { get @@ -22,9 +27,43 @@ } } + public StripManagerPanel Manager + { + set + { + mManager = value; + } + } + + public CoreNode Node + { + set + { + mNode = value; + } + } + public SectionStrip() { InitializeComponent(); } + + private void SectionStrip_Click(object sender, EventArgs e) + { + mManager.SelectedNode = mNode; + Console.WriteLine("Selected {0}", mLabel); + } + + public void MarkSelected() + { + BackColor = Color.Gold; + Console.WriteLine("{0} becomes gold!", mLabel); + } + + public void MarkDeselected() + { + BackColor = Color.PaleGreen; + Console.WriteLine("{0} becomes green!", mLabel); + } } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs 2006-07-24 02:04:30 UTC (rev 644) +++ trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs 2006-07-24 10:58:15 UTC (rev 645) @@ -28,8 +28,12 @@ /// </summary> private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.label1 = new System.Windows.Forms.Label(); this.mFlowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.addStripToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.contextMenuStrip1.SuspendLayout(); this.SuspendLayout(); // // label1 @@ -44,7 +48,9 @@ // // mFlowLayoutPanel // + this.mFlowLayoutPanel.AutoScroll = true; this.mFlowLayoutPanel.BackColor = System.Drawing.Color.Transparent; + this.mFlowLayoutPanel.ContextMenuStrip = this.contextMenuStrip1; this.mFlowLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.mFlowLayoutPanel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; this.mFlowLayoutPanel.Location = new System.Drawing.Point(0, 0); @@ -52,7 +58,23 @@ this.mFlowLayoutPanel.Size = new System.Drawing.Size(150, 150); this.mFlowLayoutPanel.TabIndex = 1; this.mFlowLayoutPanel.WrapContents = false; + this.mFlowLayoutPanel.Click += new System.EventHandler(this.mFlowLayoutPanel_Click); // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.addStripToolStripMenuItem}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.ShowImageMargin = false; + this.contextMenuStrip1.Size = new System.Drawing.Size(93, 26); + // + // addStripToolStripMenuItem + // + this.addStripToolStripMenuItem.Name = "addStripToolStripMenuItem"; + this.addStripToolStripMenuItem.Size = new System.Drawing.Size(127, 22); + this.addStripToolStripMenuItem.Text = "&Add strip"; + this.addStripToolStripMenuItem.Click += new System.EventHandler(this.addStripToolStripMenuItem_Click); + // // StripManagerPanel // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -61,6 +83,7 @@ this.Controls.Add(this.mFlowLayoutPanel); this.Controls.Add(this.label1); this.Name = "StripManagerPanel"; + this.contextMenuStrip1.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -70,5 +93,7 @@ private System.Windows.Forms.Label label1; private System.Windows.Forms.FlowLayoutPanel mFlowLayoutPanel; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem addStripToolStripMenuItem; } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-07-24 02:04:30 UTC (rev 644) +++ trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-07-24 10:58:15 UTC (rev 645) @@ -15,12 +15,30 @@ /// </summary> public partial class StripManagerPanel : UserControl, ICoreNodeVisitor { - private Dictionary<CoreNode, SectionStrip> mNodeMap; + private Dictionary<CoreNode, SectionStrip> mNodeMap; // find a strip for a given node + private CoreNode mSelectedNode; // the selected node + public event Events.Node.AddSiblingSectionHandler AddSiblingSection; + + public CoreNode SelectedNode + { + get + { + return mSelectedNode; + } + set + { + if (mSelectedNode != null) mNodeMap[mSelectedNode].MarkDeselected(); + mSelectedNode = value; + if (mSelectedNode != null) mNodeMap[mSelectedNode].MarkSelected(); + } + } + public StripManagerPanel() { InitializeComponent(); mNodeMap = new Dictionary<CoreNode, SectionStrip>(); + mSelectedNode = null; } /// <summary> @@ -56,6 +74,8 @@ { SectionStrip strip = new SectionStrip(); strip.Label = Project.GetTextMedia((CoreNode)node).getText(); + strip.Manager = this; + strip.Node = (CoreNode)node; mNodeMap[(CoreNode)node] = strip; mFlowLayoutPanel.Controls.Add(strip); } @@ -69,17 +89,21 @@ internal void SyncAddedSiblingNode(object sender, Events.Sync.AddedSiblingNodeEventArgs e) { AddStripFromNode(e.Node, e.Position); + if (e.Node != null) SelectedNode = e.Node; } internal void SyncAddedChildNode(object sender, Events.Sync.AddedChildNodeEventArgs e) { AddStripFromNode(e.Node, e.Position); + if (e.Node != null) SelectedNode = e.Node; } private void AddStripFromNode(CoreNode node, int position) { SectionStrip strip = new SectionStrip(); strip.Label = Project.GetTextMedia(node).getText(); + strip.Manager = this; + strip.Node = node; mNodeMap[node] = strip; mFlowLayoutPanel.Controls.Add(strip); mFlowLayoutPanel.Controls.SetChildIndex(strip, position); @@ -91,15 +115,37 @@ strip.Label = e.Label; } + /// <summary> + /// When deleting a node from the tree, all descendants are deleted as well. + /// </summary> internal void SyncDeletedNode(object sender, Events.Sync.DeletedNodeEventArgs e) { if (e.Node != null) { - SectionStrip strip = mNodeMap[e.Node]; - mFlowLayoutPanel.Controls.Remove(strip); + DescendantsVisitor visitor = new DescendantsVisitor(); + e.Node.acceptDepthFirst(visitor); + foreach (CoreNode node in visitor.Nodes) + { + SectionStrip strip = mNodeMap[node]; + mFlowLayoutPanel.Controls.Remove(strip); + } } } #endregion + + private void mFlowLayoutPanel_Click(object sender, EventArgs e) + { + SelectedNode = null; + } + + #region Menu items + + internal void addStripToolStripMenuItem_Click(object sender, EventArgs e) + { + AddSiblingSection(this, new Events.Node.AddSiblingSectionEventArgs(mSelectedNode)); + } + + #endregion } -} +} \ No newline at end of file Modified: trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.resx =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.resx 2006-07-24 02:04:30 UTC (rev 644) +++ trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.resx 2006-07-24 10:58:15 UTC (rev 645) @@ -117,4 +117,7 @@ <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> + <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>17, 17</value> + </metadata> </root> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-07-25 21:17:32
|
Revision: 657 Author: marisademeglio Date: 2006-07-25 14:04:11 -0700 (Tue, 25 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=657&view=rev Log Message: ----------- Added move section up and move section down functionality for TOC panel and core tree. If you move a section, the change shows up in the tree view and core tree (XUK file), but not in the strip view (yet) Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Events/Sync/DeletedNodeEventArgs.cs trunk/urakawa/application/Obi/Obi/Obi.csproj trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs trunk/urakawa/application/Obi/Obi/ObiForm.cs trunk/urakawa/application/Obi/Obi/Project.cs trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs Modified: trunk/urakawa/application/Obi/Obi/Events/Sync/DeletedNodeEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Sync/DeletedNodeEventArgs.cs 2006-07-25 14:39:02 UTC (rev 656) +++ trunk/urakawa/application/Obi/Obi/Events/Sync/DeletedNodeEventArgs.cs 2006-07-25 21:04:11 UTC (rev 657) @@ -7,6 +7,7 @@ namespace Obi.Events.Sync { public delegate void DeletedNodeHandler(object sender, DeletedNodeEventArgs e); + public delegate void ShallowDeletedNodeHandler(object sender, DeletedNodeEventArgs e); class DeletedNodeEventArgs : EventArgs { Modified: trunk/urakawa/application/Obi/Obi/Obi.csproj =================================================================== --- trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-25 14:39:02 UTC (rev 656) +++ trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-25 21:04:11 UTC (rev 657) @@ -96,22 +96,15 @@ <DependentUpon>UserProfile.cs</DependentUpon> </Compile> <Compile Include="Events\Node\DeleteSectionEventArgs.cs" /> - <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\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\Node\AddSectionEventArgs.cs" /> + <Compile Include="Events\Node\ChangeSectionLevelEventArgs.cs" /> + <Compile Include="Events\Node\MoveSectionEventArgs.cs" /> <Compile Include="Events\Node\RenameSectionEventArgs.cs" /> <Compile Include="Events\Project\StateChangedEventArgs.cs" /> <Compile Include="Events\Strip\SelectedEventArgs.cs" /> - <Compile Include="Events\Sync\AddedChildNodeEventArgs.cs" /> <Compile Include="Events\Sync\AddedSectionNodeEventArgs.cs" /> - <Compile Include="Events\Sync\AddedSiblingNodeEventArgs.cs" /> <Compile Include="Events\Sync\DeletedNodeEventArgs.cs" /> + <Compile Include="Events\Sync\MovedNodeEventArgs.cs" /> <Compile Include="Events\Sync\RenamedNodeEventArgs.cs" /> <Compile Include="Localizer.cs" /> <Compile Include="messages.Designer.cs"> Modified: trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs 2006-07-25 14:39:02 UTC (rev 656) +++ trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs 2006-07-25 21:04:11 UTC (rev 657) @@ -54,13 +54,14 @@ this.mDeleteSectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mStripsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mAddStripToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.renameStripToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.userSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.preferencesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.mProjectPanel = new Obi.UserControls.ProjectPanel(); - this.renameStripToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mMoveSectionUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); @@ -93,20 +94,20 @@ this.toolStripSeparator3, this.exitToolStripMenuItem}); this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; - this.fileToolStripMenuItem.Size = new System.Drawing.Size(36, 20); + this.fileToolStripMenuItem.Size = new System.Drawing.Size(35, 20); this.fileToolStripMenuItem.Text = "&File"; // // mNewProjectToolStripMenuItem // this.mNewProjectToolStripMenuItem.Name = "mNewProjectToolStripMenuItem"; - this.mNewProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); + this.mNewProjectToolStripMenuItem.Size = new System.Drawing.Size(173, 22); this.mNewProjectToolStripMenuItem.Text = "&New project"; this.mNewProjectToolStripMenuItem.Click += new System.EventHandler(this.mNewProjectToolStripMenuItem_Click); // // mOpenProjectToolStripMenuItem // this.mOpenProjectToolStripMenuItem.Name = "mOpenProjectToolStripMenuItem"; - this.mOpenProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); + this.mOpenProjectToolStripMenuItem.Size = new System.Drawing.Size(173, 22); this.mOpenProjectToolStripMenuItem.Text = "&Open project"; this.mOpenProjectToolStripMenuItem.Click += new System.EventHandler(this.mOpenProjectToolStripMenuItem_Click); // @@ -116,64 +117,64 @@ this.openrecentSeparator, this.mClearListToolStripMenuItem}); this.mOpenRecentProjectToolStripMenuItem.Name = "mOpenRecentProjectToolStripMenuItem"; - this.mOpenRecentProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); + this.mOpenRecentProjectToolStripMenuItem.Size = new System.Drawing.Size(173, 22); this.mOpenRecentProjectToolStripMenuItem.Text = "Open &recent project"; // // openrecentSeparator // this.openrecentSeparator.Name = "openrecentSeparator"; - this.openrecentSeparator.Size = new System.Drawing.Size(114, 6); + this.openrecentSeparator.Size = new System.Drawing.Size(112, 6); // // mClearListToolStripMenuItem // this.mClearListToolStripMenuItem.Name = "mClearListToolStripMenuItem"; - this.mClearListToolStripMenuItem.Size = new System.Drawing.Size(117, 22); + this.mClearListToolStripMenuItem.Size = new System.Drawing.Size(115, 22); this.mClearListToolStripMenuItem.Text = "&Clear list"; this.mClearListToolStripMenuItem.Click += new System.EventHandler(this.mClearListToolStripMenuItem_Click); // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(168, 6); + this.toolStripSeparator2.Size = new System.Drawing.Size(170, 6); // // mSaveProjectToolStripMenuItem // this.mSaveProjectToolStripMenuItem.Name = "mSaveProjectToolStripMenuItem"; this.mSaveProjectToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); - this.mSaveProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); + this.mSaveProjectToolStripMenuItem.Size = new System.Drawing.Size(173, 22); this.mSaveProjectToolStripMenuItem.Text = "&Save project"; this.mSaveProjectToolStripMenuItem.Click += new System.EventHandler(this.mSaveProjectToolStripMenuItem_Click); // // mSaveProjectasToolStripMenuItem // this.mSaveProjectasToolStripMenuItem.Name = "mSaveProjectasToolStripMenuItem"; - this.mSaveProjectasToolStripMenuItem.Size = new System.Drawing.Size(171, 22); + this.mSaveProjectasToolStripMenuItem.Size = new System.Drawing.Size(173, 22); this.mSaveProjectasToolStripMenuItem.Text = "Save project &as"; this.mSaveProjectasToolStripMenuItem.Click += new System.EventHandler(this.mSaveProjectasToolStripMenuItem_Click); // // mDiscardChangesToolStripMenuItem // this.mDiscardChangesToolStripMenuItem.Name = "mDiscardChangesToolStripMenuItem"; - this.mDiscardChangesToolStripMenuItem.Size = new System.Drawing.Size(171, 22); + this.mDiscardChangesToolStripMenuItem.Size = new System.Drawing.Size(173, 22); this.mDiscardChangesToolStripMenuItem.Text = "&Discard changes"; this.mDiscardChangesToolStripMenuItem.Click += new System.EventHandler(this.mDiscardChangesToolStripMenuItem_Click); // // mCloseProjectToolStripMenuItem // this.mCloseProjectToolStripMenuItem.Name = "mCloseProjectToolStripMenuItem"; - this.mCloseProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); + this.mCloseProjectToolStripMenuItem.Size = new System.Drawing.Size(173, 22); this.mCloseProjectToolStripMenuItem.Text = "&Close project"; this.mCloseProjectToolStripMenuItem.Click += new System.EventHandler(this.mCloseProjectToolStripMenuItem_Click); // // toolStripSeparator3 // this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(168, 6); + this.toolStripSeparator3.Size = new System.Drawing.Size(170, 6); // // exitToolStripMenuItem // this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(171, 22); + this.exitToolStripMenuItem.Size = new System.Drawing.Size(173, 22); this.exitToolStripMenuItem.Text = "E&xit"; this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); // @@ -208,7 +209,8 @@ this.mAddSectionAtSameLevelToolStripMenuItem, this.mAddsubsectionToolStripMenuItem, this.mRenameSectionToolStripMenuItem, - this.mDeleteSectionToolStripMenuItem}); + this.mDeleteSectionToolStripMenuItem, + this.mMoveSectionUpToolStripMenuItem}); this.mTocToolStripMenuItem.Name = "mTocToolStripMenuItem"; this.mTocToolStripMenuItem.Size = new System.Drawing.Size(40, 20); this.mTocToolStripMenuItem.Text = "TO&C"; @@ -216,37 +218,37 @@ // mShowhideTableOfCOntentsToolStripMenuItem // this.mShowhideTableOfCOntentsToolStripMenuItem.Name = "mShowhideTableOfCOntentsToolStripMenuItem"; - this.mShowhideTableOfCOntentsToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.mShowhideTableOfCOntentsToolStripMenuItem.Size = new System.Drawing.Size(196, 22); this.mShowhideTableOfCOntentsToolStripMenuItem.Text = "Show &table of contents "; this.mShowhideTableOfCOntentsToolStripMenuItem.Click += new System.EventHandler(this.mShowhideTableOfContentsToolStripMenuItem_Click); // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(201, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(193, 6); // // mAddSectionAtSameLevelToolStripMenuItem // this.mAddSectionAtSameLevelToolStripMenuItem.Name = "mAddSectionAtSameLevelToolStripMenuItem"; - this.mAddSectionAtSameLevelToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.mAddSectionAtSameLevelToolStripMenuItem.Size = new System.Drawing.Size(196, 22); this.mAddSectionAtSameLevelToolStripMenuItem.Text = "&Add section at same level"; // // mAddsubsectionToolStripMenuItem // this.mAddsubsectionToolStripMenuItem.Name = "mAddsubsectionToolStripMenuItem"; - this.mAddsubsectionToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.mAddsubsectionToolStripMenuItem.Size = new System.Drawing.Size(196, 22); this.mAddsubsectionToolStripMenuItem.Text = "Add &sub-section"; // // mRenameSectionToolStripMenuItem // this.mRenameSectionToolStripMenuItem.Name = "mRenameSectionToolStripMenuItem"; - this.mRenameSectionToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.mRenameSectionToolStripMenuItem.Size = new System.Drawing.Size(196, 22); this.mRenameSectionToolStripMenuItem.Text = "&Rename section"; // // mDeleteSectionToolStripMenuItem // this.mDeleteSectionToolStripMenuItem.Name = "mDeleteSectionToolStripMenuItem"; - this.mDeleteSectionToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.mDeleteSectionToolStripMenuItem.Size = new System.Drawing.Size(196, 22); this.mDeleteSectionToolStripMenuItem.Text = "&Delete section"; // // mStripsToolStripMenuItem @@ -255,35 +257,41 @@ this.mAddStripToolStripMenuItem, this.renameStripToolStripMenuItem}); this.mStripsToolStripMenuItem.Name = "mStripsToolStripMenuItem"; - this.mStripsToolStripMenuItem.Size = new System.Drawing.Size(47, 20); + this.mStripsToolStripMenuItem.Size = new System.Drawing.Size(46, 20); this.mStripsToolStripMenuItem.Text = "Strips"; // // mAddStripToolStripMenuItem // this.mAddStripToolStripMenuItem.Name = "mAddStripToolStripMenuItem"; - this.mAddStripToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.mAddStripToolStripMenuItem.Size = new System.Drawing.Size(137, 22); this.mAddStripToolStripMenuItem.Text = "&Add strip"; // + // renameStripToolStripMenuItem + // + this.renameStripToolStripMenuItem.Name = "renameStripToolStripMenuItem"; + this.renameStripToolStripMenuItem.Size = new System.Drawing.Size(137, 22); + this.renameStripToolStripMenuItem.Text = "&Rename strip"; + // // toolsToolStripMenuItem // this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.userSettingsToolStripMenuItem, this.preferencesToolStripMenuItem}); this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem"; - this.toolsToolStripMenuItem.Size = new System.Drawing.Size(45, 20); + this.toolsToolStripMenuItem.Size = new System.Drawing.Size(44, 20); this.toolsToolStripMenuItem.Text = "&Tools"; // // userSettingsToolStripMenuItem // this.userSettingsToolStripMenuItem.Name = "userSettingsToolStripMenuItem"; - this.userSettingsToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.userSettingsToolStripMenuItem.Size = new System.Drawing.Size(132, 22); this.userSettingsToolStripMenuItem.Text = "&User profile"; this.userSettingsToolStripMenuItem.Click += new System.EventHandler(this.userSettingsToolStripMenuItem_Click); // // preferencesToolStripMenuItem // this.preferencesToolStripMenuItem.Name = "preferencesToolStripMenuItem"; - this.preferencesToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.preferencesToolStripMenuItem.Size = new System.Drawing.Size(132, 22); this.preferencesToolStripMenuItem.Text = "&Preferences"; this.preferencesToolStripMenuItem.Click += new System.EventHandler(this.preferencesToolStripMenuItem_Click); // @@ -291,7 +299,7 @@ // this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripStatusLabel1}); - this.statusStrip1.Location = new System.Drawing.Point(0, 480); + this.statusStrip1.Location = new System.Drawing.Point(0, 522); this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.ManagerRenderMode; this.statusStrip1.Size = new System.Drawing.Size(775, 22); @@ -310,24 +318,24 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.mProjectPanel.BackColor = System.Drawing.Color.White; - this.mProjectPanel.Location = new System.Drawing.Point(4, 27); + this.mProjectPanel.Location = new System.Drawing.Point(4, 29); this.mProjectPanel.Name = "mProjectPanel"; this.mProjectPanel.Project = null; - this.mProjectPanel.Size = new System.Drawing.Size(767, 450); + this.mProjectPanel.Size = new System.Drawing.Size(767, 488); this.mProjectPanel.TabIndex = 4; // - // renameStripToolStripMenuItem + // moveSectionupToolStripMenuItem // - this.renameStripToolStripMenuItem.Name = "renameStripToolStripMenuItem"; - this.renameStripToolStripMenuItem.Size = new System.Drawing.Size(152, 22); - this.renameStripToolStripMenuItem.Text = "&Rename strip"; + this.mMoveSectionUpToolStripMenuItem.Name = "mMoveSectionUpToolStripMenuItem"; + this.mMoveSectionUpToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + this.mMoveSectionUpToolStripMenuItem.Text = "Move section &up"; // // ObiForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(775, 502); + this.ClientSize = new System.Drawing.Size(775, 544); this.Controls.Add(this.mProjectPanel); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.menuStrip1); @@ -380,6 +388,7 @@ private System.Windows.Forms.ToolStripMenuItem mRenameSectionToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem mAddStripToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem renameStripToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem mMoveSectionUpToolStripMenuItem; } Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-25 14:39:02 UTC (rev 656) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-25 21:04:11 UTC (rev 657) @@ -313,6 +313,8 @@ new EventHandler(mProjectPanel.TOCPanel.editLabelToolStripMenuItem_Click); mDeleteSectionToolStripMenuItem.Click += new EventHandler(mProjectPanel.TOCPanel.deleteSectionToolStripMenuItem_Click); + mMoveSectionUpToolStripMenuItem.Click += + new EventHandler(mProjectPanel.TOCPanel.moveUpToolStripMenuItem_Click); mProjectPanel.StripManager.SelectedStrip += new Events.Strip.SelectedHandler(StripManager_Selected); mAddStripToolStripMenuItem.Click += @@ -576,5 +578,7 @@ { toolStripStatusLabel1.Text = Localizer.Message("ready"); } + + } } \ No newline at end of file Modified: trunk/urakawa/application/Obi/Obi/Project.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-25 14:39:02 UTC (rev 656) +++ trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-25 21:04:11 UTC (rev 657) @@ -36,11 +36,10 @@ public event Events.Project.StateChangedHandler StateChanged; // the state of the project changed (modified, saved...) public event Events.Sync.AddedSectionNodeHandler AddedSectionNode; // a section node was added to the TOC - public event Events.Sync.AddedChildNodeHandler AddedChildNode; // a new child node was added to the presentation - public event Events.Sync.AddedSiblingNodeHandler AddedSiblingNode; // a new sibling node was added to the presentation public event Events.Sync.DeletedNodeHandler DeletedNode; // a node was deleted from the presentation public event Events.Sync.RenamedNodeHandler RenamedNode; // a node was renamed in the presentation - + public event Events.Sync.MovedNodeUpHandler MovedNodeUp; // a node was moved up in the presentation + public event Events.Sync.MovedNodeDownHandler MovedNodeDown; // a node was moved down in the presentation /// <summary> /// This flag is set to true if the project contains modifications that have not been saved. /// </summary> @@ -351,7 +350,7 @@ StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); } - public void CreateSiblingSectionRequested(object sender, Events.Node.AddSiblingSectionEventArgs e) + public void CreateSiblingSectionRequested(object sender, Events.Node.AddSectionEventArgs e) { System.Diagnostics.Debug.WriteLine("create sibling request from " + sender.ToString() + " with hash: " + sender.GetHashCode()); CreateSiblingSection(sender, e.ContextNode); @@ -372,7 +371,7 @@ StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); } - public void CreateChildSectionRequested(object sender, Events.Node.AddChildSectionEventArgs e) + public void CreateChildSectionRequested(object sender, Events.Node.AddSectionEventArgs e) { CreateChildSection(sender, e.ContextNode); } @@ -414,16 +413,116 @@ /// </summary> public void MoveNodeUp(object origin, CoreNode node) { - // doesn't do much yet - mUnsaved = true; - StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); + //a facade API function could do this for us + bool moveUpSucceeded = ExecuteMoveNodeUpLogic(node); + if (moveUpSucceeded) + { + MovedNodeUp(this, new Events.Sync.MovedNodeEventArgs(origin, node)); + mUnsaved = true; + StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); + } } - public void MoveNodeUpRequested(object sender, Events.Node.MoveSectionUpEventArgs e) + private bool ExecuteMoveNodeUpLogic(CoreNode node) { - MoveNodeUp(sender, e.ContextNode); + CoreNode newParent = null; + int newIndex = 0; + + int currentIndex = ((CoreNode)node.getParent()).indexOf(node); + + //if it is the first node in its list + //change its level and move it to be the previous sibling of its parent + if (currentIndex == 0) + { + //it will be a sibling of its parent (soon to be former parent) + if (node.getParent().getParent() != null) + { + newParent = (CoreNode)node.getParent().getParent(); + + newIndex = newParent.indexOf((CoreNode)node.getParent()); + + } + } + else + { + //keep our current parent + newParent = (CoreNode)node.getParent(); + newIndex = currentIndex - 1; + } + + if (newParent != null) + { + CoreNode movedNode = (CoreNode)node.detach(); + newParent.insert(movedNode, newIndex); + return true; + } + else + { + return false; + } + } + + public void MoveNodeUpRequested(object sender, Events.Node.MoveSectionEventArgs e) + { + MoveNodeUp(sender, e.Node); } + public void MoveNodeDown(object origin, CoreNode node) + { + //a facade API function could do this for us + bool moveDownSucceeded = ExecuteMoveNodeDownLogic(node); + if (moveDownSucceeded) + { + MovedNodeDown(this, new Events.Sync.MovedNodeEventArgs(origin, node)); + mUnsaved = true; + StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); + } + } + + private bool ExecuteMoveNodeDownLogic(CoreNode node) + { + CoreNode newParent = null; + int newIndex = 0; + + int currentIndex = ((CoreNode)node.getParent()).indexOf(node); + + //if it is the last node in its list + //change its level and move it to be the next sibling of its parent + if (currentIndex == node.getParent().getChildCount() - 1) + { + //it will be a sibling of its parent (soon to be former parent) + if (node.getParent().getParent() != null) + { + newParent = (CoreNode)node.getParent().getParent(); + + newIndex = newParent.indexOf((CoreNode)node.getParent()) + 1; + + } + } + else + { + //keep our current parent + newParent = (CoreNode)node.getParent(); + newIndex = currentIndex + 1; + } + + if (newParent != null) + { + CoreNode movedNode = (CoreNode)node.detach(); + newParent.insert(movedNode, newIndex); + return true; + } + else + { + return false; + } + } + + public void MoveNodeDownRequested(object sender, Events.Node.MoveSectionEventArgs e) + { + MoveNodeDown(sender, e.Node); + } + /// <summary> /// Change the text label of a node. /// </summary> @@ -440,6 +539,7 @@ RenameNode(sender, e.Node, e.Label); } + #endregion /// <summary> Modified: trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-25 14:39:02 UTC (rev 656) +++ trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-25 21:04:11 UTC (rev 657) @@ -42,7 +42,11 @@ //mProject.AddedChildNode -= new Events.Sync.AddedChildNodeHandler(mStripManagerPanel.SyncAddedChildNode); mTOCPanel.MoveSectionUp -= new Events.Node.MoveSectionUpHandler(mProject.MoveNodeUpRequested); + mProject.MovedNodeUp -= new Events.Sync.MovedNodeUpHandler(mTOCPanel.SyncMovedNodeUp); + mTOCPanel.MoveSectionDown -= new Events.Node.MoveSectionDownHandler(mProject.MoveNodeDownRequested); + mProject.MovedNodeDown -= new Events.Sync.MovedNodeDownHandler(mTOCPanel.SyncMovedNodeDown); + mTOCPanel.RenameSection -= new Events.Node.RenameSectionHandler(mProject.RenameNodeRequested); mStripManagerPanel.RenameSection -= new Events.Node.RenameSectionHandler(mProject.RenameNodeRequested); mProject.RenamedNode -= new Events.Sync.RenamedNodeHandler(mTOCPanel.SyncRenamedNode); @@ -50,7 +54,9 @@ mTOCPanel.DeleteSection -= new Events.Node.DeleteSectionHandler(mProject.RemoveNodeRequested); mProject.DeletedNode -= new Events.Sync.DeletedNodeHandler(mTOCPanel.SyncDeletedNode); - mProject.DeletedNode += new Events.Sync.DeletedNodeHandler(mStripManagerPanel.SyncDeletedNode); + + //comment: this used to say += but I think it was a typo + mProject.DeletedNode -= new Events.Sync.DeletedNodeHandler(mStripManagerPanel.SyncDeletedNode); } // Set up the handlers for the new project if (value != null) @@ -58,9 +64,6 @@ mTOCPanel.AddSiblingSection += new Events.Node.AddSiblingSectionHandler(value.CreateSiblingSectionRequested); mStripManagerPanel.AddSiblingSection += new Events.Node.AddSiblingSectionHandler(value.CreateSiblingSectionRequested); - //value.AddedSiblingNode += new Events.Sync.AddedSiblingNodeHandler(mTOCPanel.SyncAddedSiblingNode); - //value.AddedSiblingNode += new Events.Sync.AddedSiblingNodeHandler(mStripManagerPanel.SyncAddedSiblingNode); - value.AddedSectionNode += new Events.Sync.AddedSectionNodeHandler(mTOCPanel.SyncAddedSectionNode); value.AddedSectionNode += new Events.Sync.AddedSectionNodeHandler(mStripManagerPanel.SyncAddedSectionNode); @@ -69,7 +72,11 @@ //value.AddedChildNode += new Events.Sync.AddedChildNodeHandler(mStripManagerPanel.SyncAddedChildNode); mTOCPanel.MoveSectionUp += new Events.Node.MoveSectionUpHandler(value.MoveNodeUpRequested); + value.MovedNodeUp += new Events.Sync.MovedNodeUpHandler(mTOCPanel.SyncMovedNodeUp); + mTOCPanel.MoveSectionDown += new Events.Node.MoveSectionDownHandler(value.MoveNodeDownRequested); + value.MovedNodeDown += new Events.Sync.MovedNodeDownHandler(mTOCPanel.SyncMovedNodeDown); + mTOCPanel.RenameSection += new Events.Node.RenameSectionHandler(value.RenameNodeRequested); mStripManagerPanel.RenameSection += new Events.Node.RenameSectionHandler(value.RenameNodeRequested); value.RenamedNode += new Events.Sync.RenamedNodeHandler(mTOCPanel.SyncRenamedNode); Modified: trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-07-25 14:39:02 UTC (rev 656) +++ trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-07-25 21:04:11 UTC (rev 657) @@ -104,7 +104,7 @@ AddStripFromNode(e.Node, e.Position, e.Origin == this); } - internal void SyncAddedSiblingNode(object sender, Events.Sync.AddedSiblingNodeEventArgs e) + /* internal void SyncAddedSiblingNode(object sender, Events.Sync.AddedSiblingNodeEventArgs e) { AddStripFromNode(e.Node, e.Position, e.Origin == this); } @@ -112,7 +112,7 @@ internal void SyncAddedChildNode(object sender, Events.Sync.AddedChildNodeEventArgs e) { AddStripFromNode(e.Node, e.Position, e.Origin == this); - } + }*/ private void AddStripFromNode(CoreNode node, int position, bool rename) { @@ -161,7 +161,7 @@ internal void addStripToolStripMenuItem_Click(object sender, EventArgs e) { - AddSiblingSection(this, new Events.Node.AddSiblingSectionEventArgs(mSelectedNode)); + AddSiblingSection(this, new Events.Node.AddSectionEventArgs(mSelectedNode)); } internal void renameStripToolStripMenuItem_Click(object sender, EventArgs e) Modified: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-25 14:39:02 UTC (rev 656) +++ trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-25 21:04:11 UTC (rev 657) @@ -21,15 +21,13 @@ { 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; public event Events.Node.RenameSectionHandler RenameSection; public event Events.Node.DeleteSectionHandler DeleteSection; - + /// <summary> /// Test whether a node is currently selected or not. /// </summary> @@ -88,7 +86,7 @@ System.Windows.Forms.TreeNode newTreeNode; if (node.getParent().getParent() != null) { - System.Windows.Forms.TreeNode parentTreeNode = findTreeNodeFromCoreNode((CoreNode)node.getParent()); + System.Windows.Forms.TreeNode parentTreeNode = FindTreeNodeFromCoreNode((CoreNode)node.getParent()); newTreeNode = parentTreeNode.Nodes.Add(node.GetHashCode().ToString(), label); } else @@ -120,115 +118,6 @@ InitializeComponent(); } - - - - - /* - * you might move left if you go up and down - * you won't move right - */ - public void MoveCurrentSectionUp() - { - System.Windows.Forms.TreeNode selected = this.tocTree.SelectedNode; - System.Windows.Forms.TreeNode clone = (System.Windows.Forms.TreeNode) - selected.Clone(); - System.Windows.Forms.TreeNodeCollection siblingCollection = null; - - - if (selected.Parent != null) - { - siblingCollection = selected.Parent.Nodes; - } - else - { - siblingCollection = tocTree.Nodes; - } - - //it is the first node in its list - //change its level and move it to be the previous sibling of its parent - if (selected.Index == 0) - { - if (selected.Parent != null) - { - //it will be a sibling of its parent (soon to be former parent) - if (selected.Parent.Parent != null) - { - siblingCollection = selected.Parent.Parent.Nodes; - } - //it is moving to the outermost level - else - { - siblingCollection = tocTree.Nodes; - } - } - //else it has index = 0 and no parent - //so it's the first node in the tree and can't move up - } - - if (siblingCollection != null) - { - //insert the clone at one above the node to be moved - siblingCollection.Insert(selected.Index - 1, clone); - - //remove the node which was just moved - selected.Remove(); - - tocTree.SelectedNode = clone; - - clone.Expand(); - } - - } - - public void MoveCurrentSectionDown() - { - System.Windows.Forms.TreeNode selected = this.tocTree.SelectedNode; - System.Windows.Forms.TreeNode clone = (System.Windows.Forms.TreeNode) - selected.Clone(); - System.Windows.Forms.TreeNodeCollection siblingCollection = null; - - //get the set of sibling nodes that surround the selected node - if (selected.Parent != null) - { - siblingCollection = selected.Parent.Nodes; - } - else - { - siblingCollection = tocTree.Nodes; - } - - //if this is the last node in its collection - if (selected.Index >= siblingCollection.Count - 1) - { - if (selected.Parent != null) - { - //move it out a level - if (selected.Parent.Parent != null) - { - siblingCollection = selected.Parent.Parent.Nodes; - } - else - { - siblingCollection = tocTree.Nodes; - } - } - } - - if (siblingCollection != null) - { - //insert the clone at one above the node to be moved - siblingCollection.Insert(selected.Index + 2, clone); - - //remove the node which was just moved - selected.Remove(); - - tocTree.SelectedNode = clone; - - clone.Expand(); - } - } - //always allowed until level 1 public void DecreaseCurrentSectionLevel() { @@ -268,7 +157,7 @@ /// <returns>true or false, depending on if the selection was successful</returns> public bool SetSelectedSection(CoreNode node) { - System.Windows.Forms.TreeNode sel = findTreeNodeFromCoreNode(node); + System.Windows.Forms.TreeNode sel = FindTreeNodeFromCoreNode(node); if (sel != null) { @@ -281,6 +170,7 @@ } } + #region context menu handlers /* * *************************************** * These functions "...ToolStripMenuItem_Click" are triggered @@ -297,7 +187,7 @@ System.Diagnostics.Debug.WriteLine("TOC panel click!\n"); AddSiblingSection(this, - new Events.Node.AddSiblingSectionEventArgs(GetSelectedSection())); + new Events.Node.AddSectionEventArgs(GetSelectedSection())); } /// <summary> @@ -306,7 +196,7 @@ internal void addSubSectionToolStripMenuItem_Click(object sender, EventArgs e) { AddChildSection(this, - new Events.Node.AddChildSectionEventArgs(GetSelectedSection())); + new Events.Node.AddSectionEventArgs(GetSelectedSection())); } /// <summary> @@ -315,7 +205,7 @@ internal void moveUpToolStripMenuItem_Click(object sender, EventArgs e) { MoveSectionUp(this, - new Events.Node.MoveSectionUpEventArgs(GetSelectedSection())); + new Events.Node.MoveSectionEventArgs(GetSelectedSection())); } /// <summary> @@ -335,13 +225,13 @@ internal void moveDownToolStripMenuItem_Click(object sender, EventArgs e) { MoveSectionDown(this, - new Events.Node.MoveSectionDownEventArgs(GetSelectedSection())); + new Events.Node.MoveSectionEventArgs(GetSelectedSection())); } internal void increaseLevelToolStripMenuItem_Click(object sender, EventArgs e) { IncreaseSectionLevel(this, - new Events.Node.IncreaseSectionLevelEventArgs(GetSelectedSection())); + new Events.Node.ChangeSectionLevelEventArgs(GetSelectedSection())); } internal void decreaseLevelToolStripMenuItem_Click(object sender, EventArgs e) @@ -350,8 +240,9 @@ sel.BeginEdit(); DecreaseSectionLevel(this, - new Events.Node.DecreaseSectionLevelEventArgs(GetSelectedSection())); + new Events.Node.ChangeSectionLevelEventArgs(GetSelectedSection())); } + #endregion /// <summary> /// The user has edited a label in the tree, so an event is raised to rename the node. @@ -378,85 +269,7 @@ } } - /// <summary> - /// helper function to get a channel based on its name - /// </summary> - /// <param name="node">the node (points to its own presentation)</param> - /// <param name="channelName">the channel name</param> - /// <returns></returns> - private Channel GetChannelByName(CoreNode node, string channelName) - { - ChannelsProperty channelsProp = (ChannelsProperty)node.getProperty(typeof(ChannelsProperty)); - Channel foundChannel = null; - IList channelsList = channelsProp.getListOfUsedChannels(); - - for (int i = 0; i < channelsList.Count; i++) - { - string name = ((IChannel)channelsList[i]).getName(); - if (name == channelName) - { - foundChannel = (Channel)channelsList[i]; - break; - } - } - - return foundChannel; - } - - /// <summary> - /// A helper function to get the <see cref="System.Windows.Forms.TreeNode"/>, given a - /// <see cref="CoreNode"/>. - /// The <see cref="TOCPanel"/> puts the value of <see cref="CoreNode.GetHashCode()"/> - /// into the <see cref="System.Windows.Forms.TreeNode"/> as a key value when it adds a - /// new node to the tree. This function searches the tree view based on key values, and - /// assumes that when they were generated, they came from <see cref="CoreNode.GetHashCode()"/>. - /// </summary> - /// <param name="node"></param> - /// <returns></returns> - private System.Windows.Forms.TreeNode findTreeNodeFromCoreNode(CoreNode node) - { - System.Windows.Forms.TreeNode foundNode = FindTreeNodeWithoutLabel(node); - if (foundNode.Text != Project.GetTextMedia(node).getText()) - { - throw new Exception(String.Format("Found tree node matching core node #{0} but labels mismatch (wanted \"{1}\" but got \"{2}\").", - node.GetHashCode(), Project.GetTextMedia(node).getText(), foundNode.Text)); - } - return foundNode; - } - - /// <summary> - /// Find a tree node for a core node, regardless of its label (used by rename.) - /// </summary> - /// <param name="node">The node to find.</param> - /// <returns>The corresponding tree node.</returns> - private System.Windows.Forms.TreeNode FindTreeNodeWithoutLabel(CoreNode node) - { - System.Windows.Forms.TreeNode foundNode = null; - System.Windows.Forms.TreeNode[] treeNodes - = tocTree.Nodes.Find(node.GetHashCode().ToString(), true); - //(please try to enjoy this long comment:) - //since a key isn't unique and we get a list back from Nodes.Find, - //try to be as sure as possible that it's the same node - //however, this is questionably valuable as it will get more complicated - //as text support improves and as multiple labels are supported on TOC items - for (int i = 0; i < treeNodes.GetLength(0); i++) - { - //check the tag field only - if (treeNodes[i].Tag == node) - { - foundNode = treeNodes[i]; - break; - } - } - // The node must be found, so raise an exception if it couldn't - if (foundNode == null) - { - throw new Exception(String.Format("Could not find tree node matching core node #{0} with label \"{1}\".", - node.GetHashCode(), Project.GetTextMedia(node).getText())); - } - return foundNode; - } - + //trying to figure out which event to call when the tree gets right-clicked //it's really annoying to not have the node get selected when you right click it //because then, menu actions are applied to whichever node *is* selected @@ -469,13 +282,28 @@ #region Sync event handlers + /// <summary> + /// Add a section to the tree view. If we were the ones to request its addition, + /// also start editing its label right now. + /// + /// The new heading has already been created as a <see cref="CoreNode"/>. + /// It is in its correct place in the core tree. + /// Now we need to add it as a <see cref="System.Windows.Forms.TreeNode"/> so + /// it shows up in the tree view. Internally, the new <see cref="System.Windows.Forms.TreeNode"/> + /// is given the key of its <see cref="CoreNode"/> object's hash code. + /// This makes it faster to find a <see cref="System.Windows.Forms.TreeNode"/> + /// based on a given <see cref="CoreNode"/>. + /// </summary> + /// <param name="sender">The sender of this event notification</param> + /// <param name="e"><see cref="e.Node"/> is the new heading to add to the tree</param> + internal void SyncAddedSectionNode(object sender, Events.Sync.AddedSectionNodeEventArgs e) { System.Windows.Forms.TreeNode newTreeNode; string label = Project.GetTextMedia(e.Node).getText(); if (e.Node.getParent().getParent() != null) { - System.Windows.Forms.TreeNode relTreeNode = findTreeNodeFromCoreNode((CoreNode)e.Node.getParent()); + System.Windows.Forms.TreeNode relTreeNode = FindTreeNodeFromCoreNode((CoreNode)e.Node.getParent()); newTreeNode = relTreeNode.Nodes.Insert(e.Index, e.Node.GetHashCode().ToString(), label); } else @@ -494,132 +322,246 @@ } /// <summary> - /// Show the child node that was added in the tree (if it is a section.) - /// If we were the ones to request its addition, also start editing its label right now. - /// - /// The new heading has already been created as a <see cref="CoreNode"/>. It is in its correct - /// place in the core tree. - /// Now we need to add it as a <see cref="System.Windows.Forms.TreeNode"/> so it shows up in the tree view. - /// Internally, the new <see cref="System.Windows.Forms.TreeNode"/> - /// is given the key of its <see cref="CoreNode"/> object's hash code. - /// This makes it faster to find a <see cref="System.Windows.Forms.TreeNode"/> - /// based on a given <see cref="CoreNode"/>. - /// If the relative node is null, then the new node is created as a child of the - /// presentation root. + /// Change the label of the tree view node. + /// This is in response to external renames (i.e. those not originating from within the tree view itself) /// </summary> /// <param name="sender">The sender of this event notification</param> - /// <param name="e"><see cref="e.Node"/> is the new heading to add to the tree</param> - internal void SyncAddedChildNode(object sender, Events.Sync.AddedChildNodeEventArgs e) + /// <param name="e"><see cref="e.Node"/> is the tree node being renamed.</param> + internal void SyncRenamedNode(object sender, Events.Sync.RenamedNodeEventArgs e) { - - System.Windows.Forms.TreeNode newTreeNode; - string label = Project.GetTextMedia(e.Node).getText(); + if (e.Origin != this) + { + System.Windows.Forms.TreeNode treeNode = FindTreeNodeWithoutLabel(e.Node); + treeNode.Text = e.Label; + } + } - System.Diagnostics.Debug.WriteLine("TocPanel: SyncAddedChildNode -- " + label); + /// <summary> + /// Remove a node from the tree view. + /// This will remove the whole subtree. + /// </summary> + /// <param name="sender">The sender of this event notification</param> + /// <param name="e"><see cref="e.Node"/> is the node to be removed.</param> + internal void SyncDeletedNode(object sender, Events.Sync.DeletedNodeEventArgs e) + { + if (e.Node != null) + { + System.Windows.Forms.TreeNode treeNode = FindTreeNodeFromCoreNode(e.Node); + treeNode.Remove(); + } + } - if (e.Node.getParent().getParent() != null) + /// <summary> + /// This function deletes a node and promotes its children to be one level shallower + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + internal void SyncShallowDeletedNode(object sender, Events.Sync.DeletedNodeEventArgs e) + { + } + + /// <summary> + /// Move a tree node up + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + internal void SyncMovedNodeUp(object sender, Events.Sync.MovedNodeEventArgs e) + { + System.Windows.Forms.TreeNode selected = FindTreeNodeFromCoreNode(e.Node); + + System.Windows.Forms.TreeNode clone = (System.Windows.Forms.TreeNode)selected.Clone(); + System.Windows.Forms.TreeNodeCollection siblingCollection = null; + + int newIndex = 0; + + if (selected.Parent != null) { - System.Windows.Forms.TreeNode relTreeNode = findTreeNodeFromCoreNode((CoreNode)e.Node.getParent()); - newTreeNode = relTreeNode.Nodes.Add(e.Node.GetHashCode().ToString(), label); + siblingCollection = selected.Parent.Nodes; } else { - newTreeNode = tocTree.Nodes.Add(e.Node.GetHashCode().ToString(), label); + siblingCollection = tocTree.Nodes; } - newTreeNode.Tag = e.Node; - newTreeNode.ExpandAll(); - newTreeNode.EnsureVisible(); - tocTree.SelectedNode = newTreeNode; - //start editing if the request to add a node happened in the tree view - if (e.Origin.Equals(this)) + //it is the first node in its list + //change its level and move it to be the previous sibling of its parent + if (selected.Index == 0) { - newTreeNode.BeginEdit(); + if (selected.Parent != null) + { + newIndex = selected.Parent.Index; + + //it will be a sibling of its parent (soon to be former parent) + if (selected.Parent.Parent != null) + { + siblingCollection = selected.Parent.Parent.Nodes; + } + //it is moving to the outermost level + else + { + siblingCollection = tocTree.Nodes; + } + } + //else it has index = 0 and no parent + //so it's the first node in the tree and can't move up } + else + { + newIndex = selected.Index - 1; + } + + if (siblingCollection != null) + { + //insert the clone at one above the node to be moved + siblingCollection.Insert(newIndex, clone); + + //remove the node which was just moved + selected.Remove(); + + tocTree.SelectedNode = clone; + + clone.Expand(); + } + } - /// <summary> - /// Add a new heading as an immediate sibling of the relative node. - /// If we were the ones to request its addition, also start editing its label right now. - /// - /// The new heading has already been created as a <see cref="CoreNode"/>. Now we - /// need to add it as a <see cref="System.Windows.Forms.TreeNode"/>. - /// Internally, the new <see cref="System.Windows.Forms.TreeNode"/> - /// is given the key of its <see cref="CoreNode"/> object's hash code. - /// This makes it faster to find a <see cref="System.Windows.Forms.TreeNode"/> - /// based on a given <see cref="CoreNode"/>. - /// A <see cref="CoreNode"/> can always be found from a <see cref="System.Windows.Forms.TreeNode"/> - /// because the <see cref="System.Windows.Forms.TreeNode.Tag"/> field contains a reference to the <see cref="CoreNode"/> - /// </summary> - /// <param name="sender">The sender of this event notification</param> - /// <param name="e"><see cref="e.Node"/> is the new heading to add to the tree, and - /// <see cref="e.ContextNode"/> is the relative sibling node.</param> - /// <remarks>We don't actually need a context node parameter since the core node is already - /// in the correct place in its tree. However, having the parameter doesn't hurt.</remarks> - internal void SyncAddedSiblingNode(object sender, Events.Sync.AddedSiblingNodeEventArgs e) + internal void SyncMovedNodeDown(object sender, Events.Sync.MovedNodeEventArgs e) { - - System.Windows.Forms.TreeNode relTreeNode = findTreeNodeFromCoreNode(e.ContextNode); - string label = Project.GetTextMedia(e.Node).getText(); + System.Windows.Forms.TreeNode selected = FindTreeNodeFromCoreNode(e.Node); + System.Windows.Forms.TreeNode clone = (System.Windows.Forms.TreeNode) + selected.Clone(); + System.Windows.Forms.TreeNodeCollection siblingCollection = null; - System.Diagnostics.Debug.WriteLine("TocPanel: SyncAddedSiblingNode -- " + label); + int newIndex = 0; - //add as a sibling - System.Windows.Forms.TreeNodeCollection siblingCollection = null; - if (relTreeNode.Parent != null) + //get the set of sibling nodes that surround the selected node + if (selected.Parent != null) { - siblingCollection = relTreeNode.Parent.Nodes; + siblingCollection = selected.Parent.Nodes; } else { siblingCollection = tocTree.Nodes; } - System.Windows.Forms.TreeNode newTreeNode = - siblingCollection.Insert - (relTreeNode.Index + 1, e.Node.GetHashCode().ToString(), label); - newTreeNode.Tag = e.Node; - newTreeNode.ExpandAll(); - newTreeNode.EnsureVisible(); - tocTree.SelectedNode = newTreeNode; - //start editing if the request to add a node happened in the tree view - if (e.Origin.Equals(this)) + //if this is the last node in its collection + if (selected.Index >= siblingCollection.Count - 1) { - newTreeNode.BeginEdit(); + if (selected.Parent != null) + { + newIndex = selected.Parent.Index + 1; + + //move it out a level + if (selected.Parent.Parent != null) + { + siblingCollection = selected.Parent.Parent.Nodes; + } + else + { + siblingCollection = tocTree.Nodes; + } + } } + else + { + newIndex = selected.Index + 2; + } + + if (siblingCollection != null) + { + //insert the clone at one above the node to be moved + siblingCollection.Insert(newIndex, clone); + + //remove the node which was just moved + selected.Remove(); + + tocTree.SelectedNode = clone; + + clone.Expand(); + } } + #endregion + + #region helper functions /// <summary> - /// Change the label of the tree view node. - /// This is in response to external renames (i.e. those not originating from within the tree view itself) + /// helper function to get a channel based on its name /// </summary> - /// <param name="sender">The sender of this event notification</param> - /// <param name="e"><see cref="e.Node"/> is the tree node being renamed.</param> - internal void SyncRenamedNode(object sender, Events.Sync.RenamedNodeEventArgs e) + /// <param name="node">the node (points to its own presentation)</param> + /// <param name="channelName">the channel name</param> + /// <returns></returns> + private Channel GetChannelByName(CoreNode node, string channelName) { - if (e.Origin != this) + ChannelsProperty channelsProp = (ChannelsProperty)node.getProperty(typeof(ChannelsProperty)); + Channel foundChannel = null; + IList channelsList = channelsProp.getListOfUsedChannels(); + + for (int i = 0; i < channelsList.Count; i++) { - System.Windows.Forms.TreeNode treeNode = FindTreeNodeWithoutLabel(e.Node); - treeNode.Text = e.Label; + string name = ((IChannel)channelsList[i]).getName(); + if (name == channelName) + { + foundChannel = (Channel)channelsList[i]; + break; + } } + + return foundChannel; } /// <summary> - /// Remove a node from the tree view. - /// This will remove the whole subtree. + /// A helper function to get the <see cref="System.Windows.Forms.TreeNode"/>, given a + /// <see cref="CoreNode"/>. + /// The <see cref="TOCPanel"/> puts the value of <see cref="CoreNode.GetHashCode()"/> + /// into the <see cref="System.Windows.Forms.TreeNode"/> as a key value when it adds a + /// new node to the tree. This function searches the tree view based on key values, and + /// assumes that when they were generated, they came from <see cref="CoreNode.GetHashCode()"/>. /// </summary> - /// <param name="sender">The sender of this event notification</param> - /// <param name="e"><see cref="e.Node"/> is the node to be removed.</param> - internal void SyncDeletedNode(object sender, Events.Sync.DeletedNodeEventArgs e) + /// <param name="node"></param> + /// <returns></returns> + private System.Windows.Forms.TreeNode FindTreeN... [truncated message content] |
From: <ju...@us...> - 2006-07-26 11:46:51
|
Revision: 660 Author: julienq Date: 2006-07-26 04:04:27 -0700 (Wed, 26 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=660&view=rev Log Message: ----------- Undo is starting to work! I said STARTING. Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Commands/CommandManager.cs trunk/urakawa/application/Obi/Obi/Commands/TOC/AddSection.cs trunk/urakawa/application/Obi/Obi/Obi.csproj trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs trunk/urakawa/application/Obi/Obi/ObiForm.cs trunk/urakawa/application/Obi/Obi/Project.cs trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.cs trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs trunk/urakawa/application/Obi/Obi/messages.Designer.cs trunk/urakawa/application/Obi/Obi/messages.resx Added Paths: ----------- trunk/urakawa/application/Obi/Obi/Events/Project/CommandCreatedEventArgs.cs Modified: trunk/urakawa/application/Obi/Obi/Commands/CommandManager.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Commands/CommandManager.cs 2006-07-25 23:08:00 UTC (rev 659) +++ trunk/urakawa/application/Obi/Obi/Commands/CommandManager.cs 2006-07-26 11:04:27 UTC (rev 660) @@ -65,6 +65,15 @@ } /// <summary> + /// Clear the undo/redo stack, used when reading in a new project. + /// </summary> + public void Clear() + { + mUndo.Clear(); + mRedo.Clear(); + } + + /// <summary> /// Push a new command to the undo stack and clear the redo stack. /// It is assumed that the command just has, or will immediatly be executed. /// </summary> Modified: trunk/urakawa/application/Obi/Obi/Commands/TOC/AddSection.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Commands/TOC/AddSection.cs 2006-07-25 23:08:00 UTC (rev 659) +++ trunk/urakawa/application/Obi/Obi/Commands/TOC/AddSection.cs 2006-07-26 11:04:27 UTC (rev 660) @@ -11,14 +11,27 @@ { private Project mProject; private CoreNode mNode; + private CoreNode mParent; + private int mIndex; private int mPosition; - private int mIndex; + private string mOriginalLabel; - public AddSection(Project project, CoreNode node, int index, int position) + public override string Label { + get + { + return Localizer.Message("add_section_command_label"); + } + } + + public AddSection(Project project, CoreNode node, CoreNode parent, int index, int position) + { mProject = project; mNode = node; + mParent = parent; mIndex = index; + mPosition = position; + mOriginalLabel = Project.GetTextMedia(node).getText(); } /// <summary> @@ -27,7 +40,7 @@ /// </summary> public override void Do() { - mProject.RedoAddSection(mNode, mIndex, mPosition); + mProject.RedoAddSection(mNode, mParent, mIndex, mPosition, mOriginalLabel); } /// <summary> Added: trunk/urakawa/application/Obi/Obi/Events/Project/CommandCreatedEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Project/CommandCreatedEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Project/CommandCreatedEventArgs.cs 2006-07-26 11:04:27 UTC (rev 660) @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using Commands; +using urakawa.core; + +namespace Obi.Events.Project +{ + public delegate void CommandCreatedHandler(object sender, CommandCreatedEventArgs e); + + /// <summary> + /// This event indicates that the state of the project has changed. + /// The project may have been opened, saved, modified, etc. + /// </summary> + public class CommandCreatedEventArgs : EventArgs + { + private Command mCommand; + + public Command Command + { + get + { + return mCommand; + } + } + + public CommandCreatedEventArgs(Command command) + { + mCommand = command; + } + } +} Modified: trunk/urakawa/application/Obi/Obi/Obi.csproj =================================================================== --- trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-25 23:08:00 UTC (rev 659) +++ trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-26 11:04:27 UTC (rev 660) @@ -97,6 +97,7 @@ </Compile> <Compile Include="Events\Node\NodeEventArgs.cs" /> <Compile Include="Events\Node\RenameNodeEventArgs.cs" /> + <Compile Include="Events\Project\CommandCreatedEventArgs.cs" /> <Compile Include="Events\Project\StateChangedEventArgs.cs" /> <Compile Include="Events\Strip\SelectedEventArgs.cs" /> <Compile Include="Events\Node\AddedSectionNodeEventArgs.cs" /> Modified: trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs 2006-07-25 23:08:00 UTC (rev 659) +++ trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs 2006-07-26 11:04:27 UTC (rev 660) @@ -52,6 +52,7 @@ this.mAddsubsectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mRenameSectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mDeleteSectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mMoveSectionUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mStripsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mAddStripToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.renameStripToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -61,7 +62,9 @@ this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.mProjectPanel = new Obi.UserControls.ProjectPanel(); - this.mMoveSectionUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mUndoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mRedoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); @@ -94,20 +97,20 @@ this.toolStripSeparator3, this.exitToolStripMenuItem}); this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; - this.fileToolStripMenuItem.Size = new System.Drawing.Size(35, 20); + this.fileToolStripMenuItem.Size = new System.Drawing.Size(36, 20); this.fileToolStripMenuItem.Text = "&File"; // // mNewProjectToolStripMenuItem // this.mNewProjectToolStripMenuItem.Name = "mNewProjectToolStripMenuItem"; - this.mNewProjectToolStripMenuItem.Size = new System.Drawing.Size(173, 22); + this.mNewProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.mNewProjectToolStripMenuItem.Text = "&New project"; this.mNewProjectToolStripMenuItem.Click += new System.EventHandler(this.mNewProjectToolStripMenuItem_Click); // // mOpenProjectToolStripMenuItem // this.mOpenProjectToolStripMenuItem.Name = "mOpenProjectToolStripMenuItem"; - this.mOpenProjectToolStripMenuItem.Size = new System.Drawing.Size(173, 22); + this.mOpenProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.mOpenProjectToolStripMenuItem.Text = "&Open project"; this.mOpenProjectToolStripMenuItem.Click += new System.EventHandler(this.mOpenProjectToolStripMenuItem_Click); // @@ -117,70 +120,73 @@ this.openrecentSeparator, this.mClearListToolStripMenuItem}); this.mOpenRecentProjectToolStripMenuItem.Name = "mOpenRecentProjectToolStripMenuItem"; - this.mOpenRecentProjectToolStripMenuItem.Size = new System.Drawing.Size(173, 22); + this.mOpenRecentProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.mOpenRecentProjectToolStripMenuItem.Text = "Open &recent project"; // // openrecentSeparator // this.openrecentSeparator.Name = "openrecentSeparator"; - this.openrecentSeparator.Size = new System.Drawing.Size(112, 6); + this.openrecentSeparator.Size = new System.Drawing.Size(114, 6); // // mClearListToolStripMenuItem // this.mClearListToolStripMenuItem.Name = "mClearListToolStripMenuItem"; - this.mClearListToolStripMenuItem.Size = new System.Drawing.Size(115, 22); + this.mClearListToolStripMenuItem.Size = new System.Drawing.Size(117, 22); this.mClearListToolStripMenuItem.Text = "&Clear list"; this.mClearListToolStripMenuItem.Click += new System.EventHandler(this.mClearListToolStripMenuItem_Click); // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(170, 6); + this.toolStripSeparator2.Size = new System.Drawing.Size(168, 6); // // mSaveProjectToolStripMenuItem // this.mSaveProjectToolStripMenuItem.Name = "mSaveProjectToolStripMenuItem"; this.mSaveProjectToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); - this.mSaveProjectToolStripMenuItem.Size = new System.Drawing.Size(173, 22); + this.mSaveProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.mSaveProjectToolStripMenuItem.Text = "&Save project"; this.mSaveProjectToolStripMenuItem.Click += new System.EventHandler(this.mSaveProjectToolStripMenuItem_Click); // // mSaveProjectasToolStripMenuItem // this.mSaveProjectasToolStripMenuItem.Name = "mSaveProjectasToolStripMenuItem"; - this.mSaveProjectasToolStripMenuItem.Size = new System.Drawing.Size(173, 22); + this.mSaveProjectasToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.mSaveProjectasToolStripMenuItem.Text = "Save project &as"; this.mSaveProjectasToolStripMenuItem.Click += new System.EventHandler(this.mSaveProjectasToolStripMenuItem_Click); // // mDiscardChangesToolStripMenuItem // this.mDiscardChangesToolStripMenuItem.Name = "mDiscardChangesToolStripMenuItem"; - this.mDiscardChangesToolStripMenuItem.Size = new System.Drawing.Size(173, 22); + this.mDiscardChangesToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.mDiscardChangesToolStripMenuItem.Text = "&Discard changes"; this.mDiscardChangesToolStripMenuItem.Click += new System.EventHandler(this.mDiscardChangesToolStripMenuItem_Click); // // mCloseProjectToolStripMenuItem // this.mCloseProjectToolStripMenuItem.Name = "mCloseProjectToolStripMenuItem"; - this.mCloseProjectToolStripMenuItem.Size = new System.Drawing.Size(173, 22); + this.mCloseProjectToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.mCloseProjectToolStripMenuItem.Text = "&Close project"; this.mCloseProjectToolStripMenuItem.Click += new System.EventHandler(this.mCloseProjectToolStripMenuItem_Click); // // toolStripSeparator3 // this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(170, 6); + this.toolStripSeparator3.Size = new System.Drawing.Size(168, 6); // // exitToolStripMenuItem // this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(173, 22); + this.exitToolStripMenuItem.Size = new System.Drawing.Size(171, 22); this.exitToolStripMenuItem.Text = "E&xit"; this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); // // editToolStripMenuItem // this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mUndoToolStripMenuItem, + this.mRedoToolStripMenuItem, + this.toolStripSeparator4, this.metadataToolStripMenuItem, this.touchProjectToolStripMenuItem}); this.editToolStripMenuItem.Name = "editToolStripMenuItem"; @@ -190,14 +196,14 @@ // metadataToolStripMenuItem // this.metadataToolStripMenuItem.Name = "metadataToolStripMenuItem"; - this.metadataToolStripMenuItem.Size = new System.Drawing.Size(140, 22); + this.metadataToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.metadataToolStripMenuItem.Text = "&Metadata"; this.metadataToolStripMenuItem.Click += new System.EventHandler(this.metadataToolStripMenuItem_Click); // // touchProjectToolStripMenuItem // this.touchProjectToolStripMenuItem.Name = "touchProjectToolStripMenuItem"; - this.touchProjectToolStripMenuItem.Size = new System.Drawing.Size(140, 22); + this.touchProjectToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.touchProjectToolStripMenuItem.Text = "&Touch project"; this.touchProjectToolStripMenuItem.Click += new System.EventHandler(this.touchProjectToolStripMenuItem_Click); // @@ -218,58 +224,64 @@ // mShowhideTableOfCOntentsToolStripMenuItem // this.mShowhideTableOfCOntentsToolStripMenuItem.Name = "mShowhideTableOfCOntentsToolStripMenuItem"; - this.mShowhideTableOfCOntentsToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + this.mShowhideTableOfCOntentsToolStripMenuItem.Size = new System.Drawing.Size(204, 22); this.mShowhideTableOfCOntentsToolStripMenuItem.Text = "Show &table of contents "; this.mShowhideTableOfCOntentsToolStripMenuItem.Click += new System.EventHandler(this.mShowhideTableOfContentsToolStripMenuItem_Click); // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(193, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(201, 6); // // mAddSectionAtSameLevelToolStripMenuItem // this.mAddSectionAtSameLevelToolStripMenuItem.Name = "mAddSectionAtSameLevelToolStripMenuItem"; - this.mAddSectionAtSameLevelToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + this.mAddSectionAtSameLevelToolStripMenuItem.Size = new System.Drawing.Size(204, 22); this.mAddSectionAtSameLevelToolStripMenuItem.Text = "&Add section at same level"; // // mAddsubsectionToolStripMenuItem // this.mAddsubsectionToolStripMenuItem.Name = "mAddsubsectionToolStripMenuItem"; - this.mAddsubsectionToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + this.mAddsubsectionToolStripMenuItem.Size = new System.Drawing.Size(204, 22); this.mAddsubsectionToolStripMenuItem.Text = "Add &sub-section"; // // mRenameSectionToolStripMenuItem // this.mRenameSectionToolStripMenuItem.Name = "mRenameSectionToolStripMenuItem"; - this.mRenameSectionToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + this.mRenameSectionToolStripMenuItem.Size = new System.Drawing.Size(204, 22); this.mRenameSectionToolStripMenuItem.Text = "&Rename section"; // // mDeleteSectionToolStripMenuItem // this.mDeleteSectionToolStripMenuItem.Name = "mDeleteSectionToolStripMenuItem"; - this.mDeleteSectionToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + this.mDeleteSectionToolStripMenuItem.Size = new System.Drawing.Size(204, 22); this.mDeleteSectionToolStripMenuItem.Text = "&Delete section"; // + // mMoveSectionUpToolStripMenuItem + // + this.mMoveSectionUpToolStripMenuItem.Name = "mMoveSectionUpToolStripMenuItem"; + this.mMoveSectionUpToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.mMoveSectionUpToolStripMenuItem.Text = "Move section &up"; + // // mStripsToolStripMenuItem // this.mStripsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.mAddStripToolStripMenuItem, this.renameStripToolStripMenuItem}); this.mStripsToolStripMenuItem.Name = "mStripsToolStripMenuItem"; - this.mStripsToolStripMenuItem.Size = new System.Drawing.Size(46, 20); + this.mStripsToolStripMenuItem.Size = new System.Drawing.Size(47, 20); this.mStripsToolStripMenuItem.Text = "Strips"; // // mAddStripToolStripMenuItem // this.mAddStripToolStripMenuItem.Name = "mAddStripToolStripMenuItem"; - this.mAddStripToolStripMenuItem.Size = new System.Drawing.Size(137, 22); + this.mAddStripToolStripMenuItem.Size = new System.Drawing.Size(138, 22); this.mAddStripToolStripMenuItem.Text = "&Add strip"; // // renameStripToolStripMenuItem // this.renameStripToolStripMenuItem.Name = "renameStripToolStripMenuItem"; - this.renameStripToolStripMenuItem.Size = new System.Drawing.Size(137, 22); + this.renameStripToolStripMenuItem.Size = new System.Drawing.Size(138, 22); this.renameStripToolStripMenuItem.Text = "&Rename strip"; // // toolsToolStripMenuItem @@ -278,20 +290,20 @@ this.userSettingsToolStripMenuItem, this.preferencesToolStripMenuItem}); this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem"; - this.toolsToolStripMenuItem.Size = new System.Drawing.Size(44, 20); + this.toolsToolStripMenuItem.Size = new System.Drawing.Size(45, 20); this.toolsToolStripMenuItem.Text = "&Tools"; // // userSettingsToolStripMenuItem // this.userSettingsToolStripMenuItem.Name = "userSettingsToolStripMenuItem"; - this.userSettingsToolStripMenuItem.Size = new System.Drawing.Size(132, 22); + this.userSettingsToolStripMenuItem.Size = new System.Drawing.Size(131, 22); this.userSettingsToolStripMenuItem.Text = "&User profile"; this.userSettingsToolStripMenuItem.Click += new System.EventHandler(this.userSettingsToolStripMenuItem_Click); // // preferencesToolStripMenuItem // this.preferencesToolStripMenuItem.Name = "preferencesToolStripMenuItem"; - this.preferencesToolStripMenuItem.Size = new System.Drawing.Size(132, 22); + this.preferencesToolStripMenuItem.Size = new System.Drawing.Size(131, 22); this.preferencesToolStripMenuItem.Text = "&Preferences"; this.preferencesToolStripMenuItem.Click += new System.EventHandler(this.preferencesToolStripMenuItem_Click); // @@ -299,7 +311,7 @@ // this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripStatusLabel1}); - this.statusStrip1.Location = new System.Drawing.Point(0, 522); + this.statusStrip1.Location = new System.Drawing.Point(0, 480); this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.ManagerRenderMode; this.statusStrip1.Size = new System.Drawing.Size(775, 22); @@ -318,24 +330,39 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.mProjectPanel.BackColor = System.Drawing.Color.White; - this.mProjectPanel.Location = new System.Drawing.Point(4, 29); + this.mProjectPanel.Location = new System.Drawing.Point(4, 27); this.mProjectPanel.Name = "mProjectPanel"; this.mProjectPanel.Project = null; - this.mProjectPanel.Size = new System.Drawing.Size(767, 488); + this.mProjectPanel.Size = new System.Drawing.Size(767, 450); this.mProjectPanel.TabIndex = 4; // - // moveSectionupToolStripMenuItem + // mUndoToolStripMenuItem // - this.mMoveSectionUpToolStripMenuItem.Name = "mMoveSectionUpToolStripMenuItem"; - this.mMoveSectionUpToolStripMenuItem.Size = new System.Drawing.Size(196, 22); - this.mMoveSectionUpToolStripMenuItem.Text = "Move section &up"; + this.mUndoToolStripMenuItem.Name = "mUndoToolStripMenuItem"; + this.mUndoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z))); + this.mUndoToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.mUndoToolStripMenuItem.Text = "&Undo"; + this.mUndoToolStripMenuItem.Click += new System.EventHandler(this.mUndoToolStripMenuItem_Click); // + // mRedoToolStripMenuItem + // + this.mRedoToolStripMenuItem.Name = "mRedoToolStripMenuItem"; + this.mRedoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y))); + this.mRedoToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.mRedoToolStripMenuItem.Text = "&Redo"; + this.mRedoToolStripMenuItem.Click += new System.EventHandler(this.mRedoToolStripMenuItem_Click); + // + // toolStripSeparator4 + // + this.toolStripSeparator4.Name = "toolStripSeparator4"; + this.toolStripSeparator4.Size = new System.Drawing.Size(149, 6); + // // ObiForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(775, 544); + this.ClientSize = new System.Drawing.Size(775, 502); this.Controls.Add(this.mProjectPanel); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.menuStrip1); @@ -389,6 +416,9 @@ private System.Windows.Forms.ToolStripMenuItem mAddStripToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem renameStripToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem mMoveSectionUpToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem mUndoToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem mRedoToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; } Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-25 23:08:00 UTC (rev 659) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-26 11:04:27 UTC (rev 660) @@ -36,7 +36,6 @@ mSettings = null; mCmdMngr = new Commands.CommandManager(); InitializeSettings(); - mOpenRecentProjectToolStripMenuItem.Enabled = mSettings.RecentProjects.Count > 0; FormUpdateClosedProject(); // no project opened, same as if we closed a project. } @@ -118,6 +117,7 @@ if (mProject.Unsaved) { mProject.SaveAs(mProject.XUKPath); + mCmdMngr.Clear(); } else { @@ -177,6 +177,7 @@ { mProject.Close(); mProject = null; + mCmdMngr.Clear(); } } @@ -292,6 +293,7 @@ case Obi.Events.Project.StateChange.Opened: mProjectPanel.Project = mProject; FormUpdateOpenedProject(); + mCmdMngr.Clear(); mProjectPanel.SynchronizeWithCoreTree(mProject.getPresentation().getRootNode()); break; case Obi.Events.Project.StateChange.Saved: @@ -300,6 +302,12 @@ } } + private void mProject_CommandCreated(object sender, Events.Project.CommandCreatedEventArgs e) + { + mCmdMngr.Add(e.Command); + FormUpdateUndoRedoLabels(); + } + /// <summary> /// Setup the TOC and strip menus in the same way as the context menus for TOCPanel and StripManager. /// </summary> @@ -356,6 +364,7 @@ { mProject = new Project(); mProject.StateChanged += new Obi.Events.Project.StateChangedHandler(mProject_StateChanged); + mProject.CommandCreated += new Obi.Events.Project.CommandCreatedHandler(mProject_CommandCreated); mProject.Open(path); AddRecentProject(path); } @@ -456,6 +465,7 @@ { item.Enabled = false; } + FormUpdateUndoRedoLabels(); foreach (ToolStripItem item in mTocToolStripMenuItem.DropDownItems) // cannot modify the TOC { item.Enabled = false; @@ -489,6 +499,7 @@ { item.Enabled = true; } + FormUpdateUndoRedoLabels(); foreach (ToolStripItem item in mTocToolStripMenuItem.DropDownItems) // can modify the TOC { item.Enabled = true; @@ -509,6 +520,7 @@ this.Text = String.Format("{0} - {1}", mProject.Metadata.Title, Localizer.Message("obi")); mSaveProjectToolStripMenuItem.Enabled = false; mDiscardChangesToolStripMenuItem.Enabled = false; + FormUpdateUndoRedoLabels(); toolStripStatusLabel1.Text = String.Format(Localizer.Message("saved_project"), mProject.LastPath); } @@ -539,6 +551,32 @@ mShowhideTableOfCOntentsToolStripMenuItem.Enabled = true; } + private void FormUpdateUndoRedoLabels() + { + if (mCmdMngr.HasUndo) + { + mUndoToolStripMenuItem.Enabled = true; + mUndoToolStripMenuItem.Text = String.Format(Localizer.Message("undo_label"), Localizer.Message("undo"), + mCmdMngr.UndoLabel); + } + else + { + mUndoToolStripMenuItem.Enabled = false; + mUndoToolStripMenuItem.Text = Localizer.Message("undo"); + } + if (mCmdMngr.HasRedo) + { + mRedoToolStripMenuItem.Enabled = true; + mRedoToolStripMenuItem.Text = String.Format(Localizer.Message("redo_label"), Localizer.Message("redo"), + mCmdMngr.UndoLabel); + } + else + { + mRedoToolStripMenuItem.Enabled = false; + mRedoToolStripMenuItem.Text = Localizer.Message("redo"); + } + } + /// <summary> /// Check whether a project is currently open and not saved; prompt the user about what to do. /// </summary> @@ -579,6 +617,23 @@ toolStripStatusLabel1.Text = Localizer.Message("ready"); } - + private void mUndoToolStripMenuItem_Click(object sender, EventArgs e) + { + if (mCmdMngr.HasUndo) + { + mCmdMngr.Undo(); + FormUpdateUndoRedoLabels(); + } + } + + private void mRedoToolStripMenuItem_Click(object sender, EventArgs e) + { + if (mCmdMngr.HasRedo) + { + mCmdMngr.Redo(); + FormUpdateUndoRedoLabels(); + } + } + } } \ No newline at end of file Modified: trunk/urakawa/application/Obi/Obi/Project.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-25 23:08:00 UTC (rev 659) +++ trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-26 11:04:27 UTC (rev 660) @@ -35,6 +35,8 @@ public static readonly string AnnotationChannel = "obi.annotation"; // canonical name of the annotation channel public event Events.Project.StateChangedHandler StateChanged; // the state of the project changed (modified, saved...) + public event Events.Project.CommandCreatedHandler CommandCreated; // a new command must be added to the command manager + public event Events.Node.AddedSectionNodeHandler AddedSectionNode; // a section node was added to the TOC public event Events.Node.DeletedNodeHandler DeletedNode; // a node was deleted from the presentation public event Events.Node.RenamedNodeHandler RenamedNode; // a node was renamed in the presentation @@ -328,26 +330,25 @@ /// </summary> public void CreateSiblingSection(object origin, CoreNode contextNode) { + CoreNode parent = (CoreNode)(contextNode == null ? getPresentation().getRootNode() : contextNode.getParent()); CoreNode sibling = CreateSectionNode(); if (contextNode == null) { - getPresentation().getRootNode().appendChild(sibling); - NodePositionVisitor visitor = new NodePositionVisitor(sibling); - getPresentation().getRootNode().acceptDepthFirst(visitor); - AddedSectionNode(this, new Events.Node.AddedSectionNodeEventArgs(origin, sibling, - ((CoreNode)sibling.getParent()).indexOf(sibling), visitor.Position)); + parent.appendChild(sibling); } else { - CoreNode parent = (CoreNode)contextNode.getParent(); parent.insert(sibling, parent.indexOf(contextNode) + 1); - NodePositionVisitor visitor = new NodePositionVisitor(sibling); - getPresentation().getRootNode().acceptDepthFirst(visitor); - AddedSectionNode(this, new Events.Node.AddedSectionNodeEventArgs(origin, sibling, parent.indexOf(sibling), - visitor.Position)); } + NodePositionVisitor visitor = new NodePositionVisitor(sibling); + getPresentation().getRootNode().acceptDepthFirst(visitor); + AddedSectionNode(this, new Events.Node.AddedSectionNodeEventArgs(origin, sibling, parent.indexOf(sibling), + visitor.Position)); mUnsaved = true; StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); + Commands.TOC.AddSection command = new Commands.TOC.AddSection(this, sibling, parent, parent.indexOf(sibling), + visitor.Position); + CommandCreated(this, new Events.Project.CommandCreatedEventArgs(command)); } public void CreateSiblingSectionRequested(object sender, Events.Node.NodeEventArgs e) @@ -369,6 +370,9 @@ AddedSectionNode(this, new Events.Node.AddedSectionNodeEventArgs(origin, child, parent.indexOf(child), visitor.Position)); mUnsaved = true; StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); + Commands.TOC.AddSection command = new Commands.TOC.AddSection(this, child, parent, parent.indexOf(child), + visitor.Position); + CommandCreated(this, new Events.Project.CommandCreatedEventArgs(command)); } public void CreateChildSectionRequested(object sender, Events.Node.NodeEventArgs e) @@ -380,10 +384,10 @@ /// This should be used by add child/add sibling. /// AddedSectionNode event to replace AddedChild/Sibling as well. /// </summary> - public void RedoAddSection(CoreNode node, int index, int position) + public void RedoAddSection(CoreNode node, CoreNode parent, int index, int position, string originalLabel) { - CoreNode parent = (CoreNode)node.getParent(); parent.insert(node, index); + Project.GetTextMedia(node).setText(originalLabel); AddedSectionNode(this, new Events.Node.AddedSectionNodeEventArgs(this, node, index, position)); mUnsaved = true; StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); Modified: trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.Designer.cs 2006-07-25 23:08:00 UTC (rev 659) +++ trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.Designer.cs 2006-07-26 11:04:27 UTC (rev 660) @@ -60,6 +60,7 @@ // this.mTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.mTextBox.BackColor = System.Drawing.Color.LemonChiffon; this.mTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; this.mTextBox.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); this.mTextBox.Location = new System.Drawing.Point(3, 0); Modified: trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.cs 2006-07-25 23:08:00 UTC (rev 659) +++ trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.cs 2006-07-26 11:04:27 UTC (rev 660) @@ -54,20 +54,25 @@ private void SectionStrip_Click(object sender, EventArgs e) { - mManager.SelectedNode = mNode; - Console.WriteLine("Selected {0}", mLabel); + if (mManager.SelectedNode == mNode) + { + StartRenaming(); + } + else + { + mManager.SelectedNode = mNode; + } } public void MarkSelected() { BackColor = Color.Gold; - Console.WriteLine("{0} becomes gold!", mLabel); } public void MarkDeselected() { + mTextBox.Visible = false; BackColor = Color.PaleGreen; - Console.WriteLine("{0} becomes green!", mLabel); } /// <summary> @@ -91,7 +96,8 @@ /// </summary> private void mTextBox_Leave(object sender, EventArgs e) { - UpdateText(); + System.Diagnostics.Debug.Print("Leaving the text box..."); + mTextBox.Visible = false; } /// <summary> Modified: trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs 2006-07-25 23:08:00 UTC (rev 659) +++ trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs 2006-07-26 11:04:27 UTC (rev 660) @@ -60,6 +60,7 @@ this.mFlowLayoutPanel.TabIndex = 1; this.mFlowLayoutPanel.WrapContents = false; this.mFlowLayoutPanel.Click += new System.EventHandler(this.mFlowLayoutPanel_Click); + this.mFlowLayoutPanel.Leave += new System.EventHandler(this.mFlowLayoutPanel_Leave); // // contextMenuStrip1 // @@ -73,14 +74,14 @@ // addStripToolStripMenuItem // this.addStripToolStripMenuItem.Name = "addStripToolStripMenuItem"; - this.addStripToolStripMenuItem.Size = new System.Drawing.Size(127, 22); + this.addStripToolStripMenuItem.Size = new System.Drawing.Size(113, 22); this.addStripToolStripMenuItem.Text = "&Add strip"; this.addStripToolStripMenuItem.Click += new System.EventHandler(this.addStripToolStripMenuItem_Click); // // renameStripToolStripMenuItem // this.renameStripToolStripMenuItem.Name = "renameStripToolStripMenuItem"; - this.renameStripToolStripMenuItem.Size = new System.Drawing.Size(127, 22); + this.renameStripToolStripMenuItem.Size = new System.Drawing.Size(113, 22); this.renameStripToolStripMenuItem.Text = "&Rename strip"; this.renameStripToolStripMenuItem.Click += new System.EventHandler(this.renameStripToolStripMenuItem_Click); // Modified: trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-07-25 23:08:00 UTC (rev 659) +++ trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-07-26 11:04:27 UTC (rev 660) @@ -104,16 +104,6 @@ AddStripFromNode(e.Node, e.Position, e.Origin == this); } - /* internal void SyncAddedSiblingNode(object sender, Events.Sync.AddedSiblingNodeEventArgs e) - { - AddStripFromNode(e.Node, e.Position, e.Origin == this); - } - - internal void SyncAddedChildNode(object sender, Events.Sync.AddedChildNodeEventArgs e) - { - AddStripFromNode(e.Node, e.Position, e.Origin == this); - }*/ - private void AddStripFromNode(CoreNode node, int position, bool rename) { SectionStrip strip = new SectionStrip(); @@ -152,11 +142,6 @@ #endregion - private void mFlowLayoutPanel_Click(object sender, EventArgs e) - { - SelectedNode = null; - } - #region Menu items internal void addStripToolStripMenuItem_Click(object sender, EventArgs e) @@ -183,5 +168,15 @@ { RenameSection(this, new Events.Node.RenameNodeEventArgs(this, strip.Node, strip.Label)); } + + private void mFlowLayoutPanel_Click(object sender, EventArgs e) + { + SelectedNode = null; + } + + private void mFlowLayoutPanel_Leave(object sender, EventArgs e) + { + SelectedNode = null; + } } } \ No newline at end of file Modified: trunk/urakawa/application/Obi/Obi/messages.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/messages.Designer.cs 2006-07-25 23:08:00 UTC (rev 659) +++ trunk/urakawa/application/Obi/Obi/messages.Designer.cs 2006-07-26 11:04:27 UTC (rev 660) @@ -61,15 +61,6 @@ } /// <summary> - /// Looks up a localized string similar to add sub-section. - /// </summary> - internal static string add_child_command_label { - get { - return ResourceManager.GetString("add_child_command_label", resourceCulture); - } - } - - /// <summary> /// Looks up a localized string similar to add section. /// </summary> internal static string add_section_command_label { @@ -291,6 +282,15 @@ } /// <summary> + /// Looks up a localized string similar to &Redo. + /// </summary> + internal static string redo { + get { + return ResourceManager.GetString("redo", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to {0} {1}. /// </summary> internal static string redo_label { @@ -366,6 +366,15 @@ } /// <summary> + /// Looks up a localized string similar to &Undo. + /// </summary> + internal static string undo { + get { + return ResourceManager.GetString("undo", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to {0} {1}. /// </summary> internal static string undo_label { Modified: trunk/urakawa/application/Obi/Obi/messages.resx =================================================================== --- trunk/urakawa/application/Obi/Obi/messages.resx 2006-07-25 23:08:00 UTC (rev 659) +++ trunk/urakawa/application/Obi/Obi/messages.resx 2006-07-26 11:04:27 UTC (rev 660) @@ -117,9 +117,6 @@ <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> - <data name="add_child_command_label" xml:space="preserve"> - <value>add sub-section</value> - </data> <data name="cancelled" xml:space="preserve"> <value>Cancelled</value> </data> @@ -230,4 +227,10 @@ <data name="add_section_command_label" xml:space="preserve"> <value>add section</value> </data> + <data name="redo" xml:space="preserve"> + <value>&Redo</value> + </data> + <data name="undo" xml:space="preserve"> + <value>&Undo</value> + </data> </root> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-07-26 17:02:26
|
Revision: 662 Author: marisademeglio Date: 2006-07-26 10:02:16 -0700 (Wed, 26 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=662&view=rev Log Message: ----------- Increase and decrease level are STARTING to work. Automatically merged changes from last revision (661) Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Project.cs trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs Modified: trunk/urakawa/application/Obi/Obi/Project.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-26 16:07:14 UTC (rev 661) +++ trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-26 17:02:16 UTC (rev 662) @@ -42,6 +42,8 @@ public event Events.Node.RenamedNodeHandler RenamedNode; // a node was renamed in the presentation public event Events.Node.MovedNodeUpHandler MovedNodeUp; // a node was moved up in the presentation public event Events.Node.MovedNodeDownHandler MovedNodeDown; // a node was moved down in the presentation + public event Events.Node.IncreasedNodeLevelHandler IncreasedNodeLevel; //a node's level was increased in the presentation + public event Events.Node.DecreasedNodeLevelHandler DecreasedNodeLevel; //a node's level was decreased in the presentation /// <summary> /// This flag is set to true if the project contains modifications that have not been saved. /// </summary> @@ -444,8 +446,8 @@ public void MoveNodeUp(object origin, CoreNode node) { //a facade API function could do this for us - bool moveUpSucceeded = ExecuteMoveNodeUpLogic(node); - if (moveUpSucceeded) + bool succeeded = ExecuteMoveNodeUp(node); + if (succeeded) { MovedNodeUp(this, new Events.Node.NodeEventArgs(origin, node)); mUnsaved = true; @@ -453,7 +455,7 @@ } } - private bool ExecuteMoveNodeUpLogic(CoreNode node) + private bool ExecuteMoveNodeUp(CoreNode node) { CoreNode newParent = null; int newIndex = 0; @@ -500,8 +502,8 @@ public void MoveNodeDown(object origin, CoreNode node) { //a facade API function could do this for us - bool moveDownSucceeded = ExecuteMoveNodeDownLogic(node); - if (moveDownSucceeded) + bool succeeded = ExecuteMoveNodeDown(node); + if (succeeded) { MovedNodeDown(this, new Events.Node.NodeEventArgs(origin, node)); mUnsaved = true; @@ -509,7 +511,13 @@ } } - private bool ExecuteMoveNodeDownLogic(CoreNode node) + /// <summary> + /// Move a node down in the presentation. If it has a younger sibling, then they swap + /// places. If not, it changes level and becomes a younger sibling of its parent. + /// </summary> + /// <param name="node"></param> + /// <returns></returns> + private bool ExecuteMoveNodeDown(CoreNode node) { CoreNode newParent = null; int newIndex = 0; @@ -524,9 +532,7 @@ if (node.getParent().getParent() != null) { newParent = (CoreNode)node.getParent().getParent(); - newIndex = newParent.indexOf((CoreNode)node.getParent()) + 1; - } } else @@ -553,6 +559,99 @@ MoveNodeDown(sender, e.Node); } + public void IncreaseNodeLevel(object origin, CoreNode node) + { + //a facade API function could do this for us + bool succeeded = ExecuteIncreaseNodeLevel(node); + if (succeeded) + { + IncreasedNodeLevel(this, new Events.Node.NodeEventArgs(origin, node)); + mUnsaved = true; + StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); + } + } + + private bool ExecuteIncreaseNodeLevel(CoreNode node) + { + int nodeIndex = ((CoreNode)node.getParent()).indexOf(node); + + //the node's level can be increased if it has an older sibling + if (nodeIndex == 0) + { + return false; + } + + CoreNode newParent = ((CoreNode)node.getParent()).getChild(nodeIndex - 1); + + if (newParent != null) + { + CoreNode movedNode = (CoreNode)node.detach(); + newParent.appendChild(movedNode); + return true; + } + else + { + return false; + } + } + + public void IncreaseNodeLevelRequested(object sender, Events.Node.NodeEventArgs e) + { + IncreaseNodeLevel(sender, e.Node); + } + + public void DecreaseNodeLevel(object origin, CoreNode node) + { + //a facade API function could do this for us + bool succeeded = ExecuteDecreaseNodeLevel(node); + if (succeeded) + { + DecreasedNodeLevel(this, new Events.Node.NodeEventArgs(origin, node)); + mUnsaved = true; + StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); + } + } + + private bool ExecuteDecreaseNodeLevel(CoreNode node) + { + //the only reason we can't decrease the level is if the node is already + //at the outermost level + if (node.getParent() == null || + node.getParent().Equals(node.getPresentation().getRootNode())) + { + return false; + } + + ArrayList futureChildren = new ArrayList(); + int nodeIndex = ((CoreNode)node.getParent()).indexOf(node); + + //make copies of our future children, and remove them from the tree + for (int i = nodeIndex + 1; i<node.getParent().getChildCount(); i++) + { + futureChildren.Add(node.getParent().getChild(i).detach()); + } + + CoreNode newParent = (CoreNode)node.getParent().getParent(); + int newIndex = newParent.indexOf((CoreNode)node.getParent()) + 1; + + CoreNode clone = (CoreNode)node.detach(); + + newParent.insert(clone, newIndex); + + foreach (object childnode in futureChildren) + { + clone.appendChild((CoreNode)childnode); + } + + return true; + + } + + public void DecreaseNodeLevelRequested(object sender, Events.Node.NodeEventArgs e) + { + DecreaseNodeLevel(sender, e.Node); + } + /// <summary> /// Change the text label of a node. /// </summary> Modified: trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-26 16:07:14 UTC (rev 661) +++ trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-26 17:02:16 UTC (rev 662) @@ -47,6 +47,12 @@ mTOCPanel.MoveSectionDown -= new Events.Node.RequestToMoveNodeDownHandler(mProject.MoveNodeDownRequested); mProject.MovedNodeDown -= new Events.Node.MovedNodeDownHandler(mTOCPanel.SyncMovedNodeDown); + mTOCPanel.IncreaseSectionLevel -= new Events.Node.RequestToIncreaseNodeLevelHandler(mProject.IncreaseNodeLevelRequested); + mProject.IncreasedNodeLevel -= new Events.Node.IncreasedNodeLevelHandler(mTOCPanel.SyncIncreasedNodeLevel); + + mTOCPanel.DecreaseSectionLevel -= new Events.Node.RequestToDecreaseNodeLevelHandler(mProject.DecreaseNodeLevelRequested); + mProject.DecreasedNodeLevel -= new Events.Node.DecreasedNodeLevelHandler(mTOCPanel.SyncDecreasedNodeLevel); + mTOCPanel.RenameSection -= new Events.Node.RequestToRenameNodeHandler(mProject.RenameNodeRequested); mStripManagerPanel.RenameSection -= new Events.Node.RequestToRenameNodeHandler(mProject.RenameNodeRequested); mProject.RenamedNode -= new Events.Node.RenamedNodeHandler(mTOCPanel.SyncRenamedNode); @@ -77,6 +83,12 @@ mTOCPanel.MoveSectionDown += new Events.Node.RequestToMoveNodeDownHandler(value.MoveNodeDownRequested); value.MovedNodeDown += new Events.Node.MovedNodeDownHandler(mTOCPanel.SyncMovedNodeDown); + mTOCPanel.IncreaseSectionLevel += new Events.Node.RequestToIncreaseNodeLevelHandler(value.IncreaseNodeLevelRequested); + value.IncreasedNodeLevel += new Events.Node.IncreasedNodeLevelHandler(mTOCPanel.SyncIncreasedNodeLevel); + + mTOCPanel.DecreaseSectionLevel += new Events.Node.RequestToDecreaseNodeLevelHandler(value.DecreaseNodeLevelRequested); + value.DecreasedNodeLevel += new Events.Node.DecreasedNodeLevelHandler(mTOCPanel.SyncDecreasedNodeLevel); + mTOCPanel.RenameSection += new Events.Node.RequestToRenameNodeHandler(value.RenameNodeRequested); mStripManagerPanel.RenameSection += new Events.Node.RequestToRenameNodeHandler(value.RenameNodeRequested); value.RenamedNode += new Events.Node.RenamedNodeHandler(mTOCPanel.SyncRenamedNode); Modified: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-26 16:07:14 UTC (rev 661) +++ trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-26 17:02:16 UTC (rev 662) @@ -5,7 +5,6 @@ using System.Data; using System.Text; using System.Windows.Forms; -using urakawa.core; using urakawa.media; using System.Collections; @@ -17,7 +16,7 @@ /// change the label, etc. of headings.) /// This control implements the CoreTreeView interface so that it can be synchronized with the core tree. /// </summary> - public partial class TOCPanel : UserControl, ICoreNodeVisitor + public partial class TOCPanel : UserControl, urakawa.core.ICoreNodeVisitor { public event Events.Node.RequestToAddSiblingNodeHandler AddSiblingSection; public event Events.Node.RequestToAddChildNodeHandler AddChildSection; @@ -55,7 +54,7 @@ /// Since we need priviledged access to the class for synchronization, /// we make it implement ICoreNodeVisitor directly. /// </summary> - public void SynchronizeWithCoreTree(CoreNode root) + public void SynchronizeWithCoreTree(urakawa.core.CoreNode root) { tocTree.Nodes.Clear(); tocTree.SelectedNode = null; @@ -68,7 +67,7 @@ /// Do nothing. /// </summary> /// <param name="node">The node to do nothing with.</param> - public void postVisit(ICoreNode node) + public void postVisit(urakawa.core.ICoreNode node) { } @@ -78,15 +77,15 @@ /// </summary> /// <param name="node">The node to add to the tree.</param> /// <returns>True </returns> - public bool preVisit(ICoreNode node) + public bool preVisit(urakawa.core.ICoreNode node) { if (node.getParent() != null) { - string label = Project.GetTextMedia((CoreNode)node).getText(); - System.Windows.Forms.TreeNode newTreeNode; + string label = Project.GetTextMedia((urakawa.core.CoreNode)node).getText(); + TreeNode newTreeNode; if (node.getParent().getParent() != null) { - System.Windows.Forms.TreeNode parentTreeNode = FindTreeNodeFromCoreNode((CoreNode)node.getParent()); + TreeNode parentTreeNode = FindTreeNodeFromCoreNode((urakawa.core.CoreNode)node.getParent()); newTreeNode = parentTreeNode.Nodes.Add(node.GetHashCode().ToString(), label); } else @@ -134,9 +133,9 @@ /// Return the core node version of the selected tree node. /// </summary> /// <returns>The selected section, or null if no section is selected.</returns> - public CoreNode GetSelectedSection() + public urakawa.core.CoreNode GetSelectedSection() { - System.Windows.Forms.TreeNode selected = this.tocTree.SelectedNode; + TreeNode selected = this.tocTree.SelectedNode; return selected == null ? null : (urakawa.core.CoreNode)selected.Tag; } @@ -145,9 +144,9 @@ /// </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) + public bool SetSelectedSection(urakawa.core.CoreNode node) { - System.Windows.Forms.TreeNode sel = FindTreeNodeFromCoreNode(node); + TreeNode sel = FindTreeNodeFromCoreNode(node); if (sel != null) { @@ -174,9 +173,7 @@ /// </summary> internal void addSectionAtSameLevelToolStripMenuItem_Click(object sender, EventArgs e) { - System.Diagnostics.Debug.WriteLine("TOC panel click!\n"); - - AddSiblingSection(this, + AddSiblingSection(this, new Events.Node.NodeEventArgs(this, GetSelectedSection())); } @@ -208,7 +205,7 @@ internal void editLabelToolStripMenuItem_Click(object sender, EventArgs e) { - System.Windows.Forms.TreeNode sel = this.tocTree.SelectedNode; + TreeNode sel = this.tocTree.SelectedNode; sel.BeginEdit(); } @@ -226,7 +223,7 @@ internal void decreaseLevelToolStripMenuItem_Click(object sender, EventArgs e) { - System.Windows.Forms.TreeNode sel = this.tocTree.SelectedNode; + TreeNode sel = this.tocTree.SelectedNode; sel.BeginEdit(); DecreaseSectionLevel(this, @@ -252,9 +249,9 @@ Localizer.Message("empty_label_warning_caption"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } - else if (e.Label != Project.GetTextMedia((CoreNode)e.Node.Tag).getText()) + else if (e.Label != Project.GetTextMedia((urakawa.core.CoreNode)e.Node.Tag).getText()) { - RenameSection(this, new Events.Node.RenameNodeEventArgs(this, (CoreNode)e.Node.Tag, e.Label)); + RenameSection(this, new Events.Node.RenameNodeEventArgs(this, (urakawa.core.CoreNode)e.Node.Tag, e.Label)); } } } @@ -278,10 +275,10 @@ /// /// The new heading has already been created as a <see cref="CoreNode"/>. /// It is in its correct place in the core tree. - /// Now we need to add it as a <see cref="System.Windows.Forms.TreeNode"/> so - /// it shows up in the tree view. Internally, the new <see cref="System.Windows.Forms.TreeNode"/> + /// Now we need to add it as a <see cref="TreeNode"/> so + /// it shows up in the tree view. Internally, the new <see cref="TreeNode"/> /// is given the key of its <see cref="CoreNode"/> object's hash code. - /// This makes it faster to find a <see cref="System.Windows.Forms.TreeNode"/> + /// This makes it faster to find a <see cref="TreeNode"/> /// based on a given <see cref="CoreNode"/>. /// </summary> /// <param name="sender">The sender of this event notification</param> @@ -289,11 +286,11 @@ internal void SyncAddedSectionNode(object sender, Events.Node.AddedSectionNodeEventArgs e) { - System.Windows.Forms.TreeNode newTreeNode; + TreeNode newTreeNode; string label = Project.GetTextMedia(e.Node).getText(); if (e.Node.getParent().getParent() != null) { - System.Windows.Forms.TreeNode relTreeNode = FindTreeNodeFromCoreNode((CoreNode)e.Node.getParent()); + TreeNode relTreeNode = FindTreeNodeFromCoreNode((urakawa.core.CoreNode)e.Node.getParent()); newTreeNode = relTreeNode.Nodes.Insert(e.Index, e.Node.GetHashCode().ToString(), label); } else @@ -321,7 +318,7 @@ { if (e.Origin != this) { - System.Windows.Forms.TreeNode treeNode = FindTreeNodeWithoutLabel(e.Node); + TreeNode treeNode = FindTreeNodeWithoutLabel(e.Node); treeNode.Text = e.Label; } } @@ -336,7 +333,7 @@ { if (e.Node != null) { - System.Windows.Forms.TreeNode treeNode = FindTreeNodeFromCoreNode(e.Node); + TreeNode treeNode = FindTreeNodeFromCoreNode(e.Node); treeNode.Remove(); } } @@ -359,8 +356,8 @@ { System.Windows.Forms.TreeNode selected = FindTreeNodeFromCoreNode(e.Node); - System.Windows.Forms.TreeNode clone = (System.Windows.Forms.TreeNode)selected.Clone(); - System.Windows.Forms.TreeNodeCollection siblingCollection = null; + TreeNode clone = (TreeNode)selected.Clone(); + TreeNodeCollection siblingCollection = null; int newIndex = 0; @@ -422,10 +419,10 @@ /// <param name="e"></param> internal void SyncMovedNodeDown(object sender, Events.Node.NodeEventArgs e) { - System.Windows.Forms.TreeNode selected = FindTreeNodeFromCoreNode(e.Node); - System.Windows.Forms.TreeNode clone = (System.Windows.Forms.TreeNode) + TreeNode selected = FindTreeNodeFromCoreNode(e.Node); + TreeNode clone = (TreeNode) selected.Clone(); - System.Windows.Forms.TreeNodeCollection siblingCollection = null; + TreeNodeCollection siblingCollection = null; int newIndex = 0; @@ -476,9 +473,107 @@ } } - internal void SyncIncreaseNodeLevel(object sender, Events.Node.NodeEventArgs e) + internal void SyncIncreasedNodeLevel(object sender, Events.Node.NodeEventArgs e) { + TreeNode selected = FindTreeNodeFromCoreNode(e.Node); + + //you can always increase a node's level if it has an older sibling + if (selected.Index == 0) + { + return; + } + + TreeNode clone = (TreeNode)selected.Clone(); + TreeNodeCollection siblingCollection = null; + + TreeNode newParent = null; + + if (selected.Parent != null) + { + siblingCollection = selected.Parent.Nodes; + } + else + { + siblingCollection = tocTree.Nodes; + } + + newParent = siblingCollection[selected.Index - 1]; + + if (newParent != null) + { + //insert the clone as another child of its new parent + newParent.Nodes.Add(clone); + + //remove the node which was just moved + selected.Remove(); + + tocTree.SelectedNode = clone; + + clone.Expand(); + } } + + /// <summary> + /// Decrease the node level. + /// When a node becomes shallower, it adopts its former younger siblings. + /// We'll have to get feedback on how users like this behavior. + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + internal void SyncDecreasedNodeLevel(object sender, Events.Node.NodeEventArgs e) + { + TreeNode selected = FindTreeNodeFromCoreNode(e.Node); + + //the only reason we can't decrease the level is if the node is already + //at the outermost level + if (selected.Parent == null) + { + return; + } + + ArrayList futureChildren = new ArrayList(); + + int idx = 0; + //make copies of our future children, and remove them from the tree + foreach (TreeNode node in selected.Parent.Nodes) + { + if (node.Index > selected.Index) + { + futureChildren.Add(node.Clone()); + node.Remove(); + idx++; + } + } + + TreeNodeCollection siblingCollection = null; + + //move it out a level + if (selected.Parent.Parent != null) + { + siblingCollection = selected.Parent.Parent.Nodes; + } + else + { + siblingCollection = tocTree.Nodes; + } + + int newIndex = selected.Parent.Index + 1; + + TreeNode clone = + (TreeNode)selected.Clone(); + selected.Remove(); + + siblingCollection.Insert(newIndex, clone); + + foreach (object node in futureChildren) + { + clone.Nodes.Add((TreeNode)node); + } + + clone.Expand(); + clone.EnsureVisible(); + } + #endregion #region helper functions @@ -488,18 +583,19 @@ /// <param name="node">the node (points to its own presentation)</param> /// <param name="channelName">the channel name</param> /// <returns></returns> - private Channel GetChannelByName(CoreNode node, string channelName) + private urakawa.core.Channel GetChannelByName(urakawa.core.CoreNode node, string channelName) { - ChannelsProperty channelsProp = (ChannelsProperty)node.getProperty(typeof(ChannelsProperty)); - Channel foundChannel = null; + urakawa.core.ChannelsProperty channelsProp = + (urakawa.core.ChannelsProperty)node.getProperty(typeof(urakawa.core.ChannelsProperty)); + urakawa.core.Channel foundChannel = null; IList channelsList = channelsProp.getListOfUsedChannels(); for (int i = 0; i < channelsList.Count; i++) { - string name = ((IChannel)channelsList[i]).getName(); + string name = ((urakawa.core.IChannel)channelsList[i]).getName(); if (name == channelName) { - foundChannel = (Channel)channelsList[i]; + foundChannel = (urakawa.core.Channel)channelsList[i]; break; } } @@ -517,9 +613,9 @@ /// </summary> /// <param name="node"></param> /// <returns></returns> - private System.Windows.Forms.TreeNode FindTreeNodeFromCoreNode(CoreNode node) + private TreeNode FindTreeNodeFromCoreNode(urakawa.core.CoreNode node) { - System.Windows.Forms.TreeNode foundNode = FindTreeNodeWithoutLabel(node); + TreeNode foundNode = FindTreeNodeWithoutLabel(node); if (foundNode.Text != Project.GetTextMedia(node).getText()) { throw new Exception(String.Format("Found tree node matching core node #{0} but labels mismatch (wanted \"{1}\" but got \"{2}\").", @@ -533,10 +629,10 @@ /// </summary> /// <param name="node">The node to find.</param> /// <returns>The corresponding tree node.</returns> - private System.Windows.Forms.TreeNode FindTreeNodeWithoutLabel(CoreNode node) + private TreeNode FindTreeNodeWithoutLabel(urakawa.core.CoreNode node) { - System.Windows.Forms.TreeNode foundNode = null; - System.Windows.Forms.TreeNode[] treeNodes + TreeNode foundNode = null; + TreeNode[] treeNodes = tocTree.Nodes.Find(node.GetHashCode().ToString(), true); //since a key isn't unique and we get a list back from Nodes.Find, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-07-27 17:11:36
|
Revision: 664 Author: marisademeglio Date: 2006-07-26 12:04:34 -0700 (Wed, 26 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=664&view=rev Log Message: ----------- Increase/decrease level works Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Project.cs trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs Modified: trunk/urakawa/application/Obi/Obi/Project.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-26 18:04:54 UTC (rev 663) +++ trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-26 19:04:34 UTC (rev 664) @@ -350,7 +350,7 @@ StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); Commands.TOC.AddSection command = new Commands.TOC.AddSection(this, sibling, parent, parent.indexOf(sibling), visitor.Position); - CommandCreated(this, new Events.Project.CommandCreatedEventArgs(command)); + //MED CommandCreated(this, new Events.Project.CommandCreatedEventArgs(command)); } public void CreateSiblingSectionRequested(object sender, Events.Node.NodeEventArgs e) @@ -374,7 +374,7 @@ StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); Commands.TOC.AddSection command = new Commands.TOC.AddSection(this, child, parent, parent.indexOf(child), visitor.Position); - CommandCreated(this, new Events.Project.CommandCreatedEventArgs(command)); + //MEDCommandCreated(this, new Events.Project.CommandCreatedEventArgs(command)); } public void CreateChildSectionRequested(object sender, Events.Node.NodeEventArgs e) @@ -625,11 +625,15 @@ ArrayList futureChildren = new ArrayList(); int nodeIndex = ((CoreNode)node.getParent()).indexOf(node); + int numChildren = node.getParent().getChildCount(); + //make copies of our future children, and remove them from the tree - for (int i = nodeIndex + 1; i<node.getParent().getChildCount(); i++) + for (int i = numChildren-1; i>nodeIndex; i--) { futureChildren.Add(node.getParent().getChild(i).detach()); } + //since the list was built in backwards order, rearrange it + futureChildren.Reverse(); CoreNode newParent = (CoreNode)node.getParent().getParent(); int newIndex = newParent.indexOf((CoreNode)node.getParent()) + 1; @@ -663,7 +667,7 @@ RenamedNode(this, new Events.Node.RenameNodeEventArgs(origin, node, label)); mUnsaved = true; StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); - if (command != null) CommandCreated(this, new Events.Project.CommandCreatedEventArgs(command)); + //MEDif (command != null) CommandCreated(this, new Events.Project.CommandCreatedEventArgs(command)); } public void RenameNodeRequested(object sender, Events.Node.RenameNodeEventArgs e) Modified: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-26 18:04:54 UTC (rev 663) +++ trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-26 19:04:34 UTC (rev 664) @@ -464,9 +464,9 @@ //remove the node which was just moved selected.Remove(); + clone.ExpandAll(); + clone.EnsureVisible(); tocTree.SelectedNode = clone; - - clone.Expand(); } } @@ -506,7 +506,9 @@ tocTree.SelectedNode = clone; - clone.Expand(); + clone.ExpandAll(); + clone.EnsureVisible(); + tocTree.SelectedNode = clone; } } @@ -567,8 +569,9 @@ clone.Nodes.Add((TreeNode)node); } - clone.Expand(); + clone.ExpandAll(); clone.EnsureVisible(); + tocTree.SelectedNode = clone; } #endregion This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-07-28 21:41:36
|
Revision: 667 Author: julienq Date: 2006-07-27 08:47:59 -0700 (Thu, 27 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=667&view=rev Log Message: ----------- Starting to add assets. Not much there yet. Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Events/Node/NodeEventArgs.cs trunk/urakawa/application/Obi/Obi/Obi.csproj trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs trunk/urakawa/application/Obi/Obi/ObiForm.cs trunk/urakawa/application/Obi/Obi/Project.cs trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs Added Paths: ----------- trunk/urakawa/application/Obi/Obi/Events/Strip/ImportAssetEventArgs.cs Modified: trunk/urakawa/application/Obi/Obi/Events/Node/NodeEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/NodeEventArgs.cs 2006-07-27 10:08:09 UTC (rev 666) +++ trunk/urakawa/application/Obi/Obi/Events/Node/NodeEventArgs.cs 2006-07-27 15:47:59 UTC (rev 667) @@ -14,7 +14,6 @@ public delegate void RequestToMoveNodeUpHandler(object sender, NodeEventArgs e); public delegate void RequestToMoveNodeDownHandler(object sender, NodeEventArgs e); - public delegate void IncreasedNodeLevelHandler(object sender, NodeEventArgs e); public delegate void DecreasedNodeLevelHandler(object sender, NodeEventArgs e); public delegate void DeletedNodeHandler(object sender, NodeEventArgs e); Added: trunk/urakawa/application/Obi/Obi/Events/Strip/ImportAssetEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Strip/ImportAssetEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Strip/ImportAssetEventArgs.cs 2006-07-27 15:47:59 UTC (rev 667) @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using urakawa.core; + +namespace Obi.Events.Strip +{ + public delegate void RequestToImportAssetHandler(object sender, ImportAssetEventArgs e); + + // TODO: position of the phrase in this asset + public class ImportAssetEventArgs + { + private CoreNode mSectionNode; // the section in which the phrase is to be added + private string mAssetPath; // the path of the asset to add + + public CoreNode SectionNode + { + get + { + return mSectionNode; + } + } + + public string AssetPath + { + get + { + return mAssetPath; + } + } + + public ImportAssetEventArgs(CoreNode sectionNode, string assetPath) + { + mSectionNode = sectionNode; + mAssetPath = assetPath; + } + } +} Modified: trunk/urakawa/application/Obi/Obi/Obi.csproj =================================================================== --- trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-27 10:08:09 UTC (rev 666) +++ trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-27 15:47:59 UTC (rev 667) @@ -47,9 +47,9 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> - <Reference Include="Commands, Version=1.0.2392.27219, Culture=neutral"> + <Reference Include="Commands, Version=1.0.2399.28565, Culture=neutral"> <SpecificVersion>False</SpecificVersion> - <HintPath>..\..\Commands\bin\Debug\Commands.dll</HintPath> + <HintPath>..\..\VirtualAudioBackend\bin\Debug\Commands.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> @@ -66,6 +66,10 @@ <SpecificVersion>False</SpecificVersion> <HintPath>..\..\UrakawaApplicationBackend\obj\Debug\UrakawaApplicationBackend.dll</HintPath> </Reference> + <Reference Include="VirtualAudioBackend, Version=1.0.2399.28607, Culture=neutral"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\VirtualAudioBackend\bin\Debug\VirtualAudioBackend.dll</HintPath> + </Reference> </ItemGroup> <ItemGroup> <Compile Include="Commands\CommandManager.cs" /> @@ -101,6 +105,7 @@ <Compile Include="Events\Node\RenameNodeEventArgs.cs" /> <Compile Include="Events\Project\CommandCreatedEventArgs.cs" /> <Compile Include="Events\Project\StateChangedEventArgs.cs" /> + <Compile Include="Events\Strip\ImportAssetEventArgs.cs" /> <Compile Include="Events\Strip\SelectedEventArgs.cs" /> <Compile Include="Events\Node\AddedSectionNodeEventArgs.cs" /> <Compile Include="Localizer.cs" /> Modified: trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs 2006-07-27 10:08:09 UTC (rev 666) +++ trunk/urakawa/application/Obi/Obi/ObiForm.Designer.cs 2006-07-27 15:47:59 UTC (rev 667) @@ -43,6 +43,9 @@ this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mUndoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mRedoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); this.metadataToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.touchProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mTocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -62,9 +65,8 @@ this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.mProjectPanel = new Obi.UserControls.ProjectPanel(); - this.mUndoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.mRedoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); + this.importAssetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); @@ -193,17 +195,38 @@ this.editToolStripMenuItem.Size = new System.Drawing.Size(37, 20); this.editToolStripMenuItem.Text = "&Edit"; // + // mUndoToolStripMenuItem + // + this.mUndoToolStripMenuItem.Name = "mUndoToolStripMenuItem"; + this.mUndoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z))); + this.mUndoToolStripMenuItem.Size = new System.Drawing.Size(140, 22); + this.mUndoToolStripMenuItem.Text = "&Undo"; + this.mUndoToolStripMenuItem.Click += new System.EventHandler(this.mUndoToolStripMenuItem_Click); + // + // mRedoToolStripMenuItem + // + this.mRedoToolStripMenuItem.Name = "mRedoToolStripMenuItem"; + this.mRedoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y))); + this.mRedoToolStripMenuItem.Size = new System.Drawing.Size(140, 22); + this.mRedoToolStripMenuItem.Text = "&Redo"; + this.mRedoToolStripMenuItem.Click += new System.EventHandler(this.mRedoToolStripMenuItem_Click); + // + // toolStripSeparator4 + // + this.toolStripSeparator4.Name = "toolStripSeparator4"; + this.toolStripSeparator4.Size = new System.Drawing.Size(137, 6); + // // metadataToolStripMenuItem // this.metadataToolStripMenuItem.Name = "metadataToolStripMenuItem"; - this.metadataToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.metadataToolStripMenuItem.Size = new System.Drawing.Size(140, 22); this.metadataToolStripMenuItem.Text = "&Metadata"; this.metadataToolStripMenuItem.Click += new System.EventHandler(this.metadataToolStripMenuItem_Click); // // touchProjectToolStripMenuItem // this.touchProjectToolStripMenuItem.Name = "touchProjectToolStripMenuItem"; - this.touchProjectToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.touchProjectToolStripMenuItem.Size = new System.Drawing.Size(140, 22); this.touchProjectToolStripMenuItem.Text = "&Touch project"; this.touchProjectToolStripMenuItem.Click += new System.EventHandler(this.touchProjectToolStripMenuItem_Click); // @@ -267,7 +290,9 @@ // this.mStripsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.mAddStripToolStripMenuItem, - this.renameStripToolStripMenuItem}); + this.renameStripToolStripMenuItem, + this.toolStripSeparator5, + this.importAssetToolStripMenuItem}); this.mStripsToolStripMenuItem.Name = "mStripsToolStripMenuItem"; this.mStripsToolStripMenuItem.Size = new System.Drawing.Size(47, 20); this.mStripsToolStripMenuItem.Text = "Strips"; @@ -275,13 +300,13 @@ // mAddStripToolStripMenuItem // this.mAddStripToolStripMenuItem.Name = "mAddStripToolStripMenuItem"; - this.mAddStripToolStripMenuItem.Size = new System.Drawing.Size(138, 22); + this.mAddStripToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.mAddStripToolStripMenuItem.Text = "&Add strip"; // // renameStripToolStripMenuItem // this.renameStripToolStripMenuItem.Name = "renameStripToolStripMenuItem"; - this.renameStripToolStripMenuItem.Size = new System.Drawing.Size(138, 22); + this.renameStripToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.renameStripToolStripMenuItem.Text = "&Rename strip"; // // toolsToolStripMenuItem @@ -336,27 +361,17 @@ this.mProjectPanel.Size = new System.Drawing.Size(767, 450); this.mProjectPanel.TabIndex = 4; // - // mUndoToolStripMenuItem + // toolStripSeparator5 // - this.mUndoToolStripMenuItem.Name = "mUndoToolStripMenuItem"; - this.mUndoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z))); - this.mUndoToolStripMenuItem.Size = new System.Drawing.Size(152, 22); - this.mUndoToolStripMenuItem.Text = "&Undo"; - this.mUndoToolStripMenuItem.Click += new System.EventHandler(this.mUndoToolStripMenuItem_Click); + this.toolStripSeparator5.Name = "toolStripSeparator5"; + this.toolStripSeparator5.Size = new System.Drawing.Size(149, 6); // - // mRedoToolStripMenuItem + // importAssetToolStripMenuItem // - this.mRedoToolStripMenuItem.Name = "mRedoToolStripMenuItem"; - this.mRedoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y))); - this.mRedoToolStripMenuItem.Size = new System.Drawing.Size(152, 22); - this.mRedoToolStripMenuItem.Text = "&Redo"; - this.mRedoToolStripMenuItem.Click += new System.EventHandler(this.mRedoToolStripMenuItem_Click); + this.importAssetToolStripMenuItem.Name = "importAssetToolStripMenuItem"; + this.importAssetToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.importAssetToolStripMenuItem.Text = "&Import asset"; // - // toolStripSeparator4 - // - this.toolStripSeparator4.Name = "toolStripSeparator4"; - this.toolStripSeparator4.Size = new System.Drawing.Size(149, 6); - // // ObiForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -419,6 +434,8 @@ private System.Windows.Forms.ToolStripMenuItem mUndoToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem mRedoToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; + private System.Windows.Forms.ToolStripMenuItem importAssetToolStripMenuItem; } Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-27 10:08:09 UTC (rev 666) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-07-27 15:47:59 UTC (rev 667) @@ -329,6 +329,8 @@ new EventHandler(mProjectPanel.StripManager.addStripToolStripMenuItem_Click); renameStripToolStripMenuItem.Click += new EventHandler(mProjectPanel.StripManager.renameStripToolStripMenuItem_Click); + importAssetToolStripMenuItem.Click += + new EventHandler(mProjectPanel.StripManager.importAssetToolStripMenuItem_Click); } private void StripManager_Selected(object sender, Events.Strip.SelectedEventArgs e) Modified: trunk/urakawa/application/Obi/Obi/Project.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-27 10:08:09 UTC (rev 666) +++ trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-27 15:47:59 UTC (rev 667) @@ -1,10 +1,12 @@ using System; using System.Collections; using System.Collections.Generic; +using System.IO; using System.Text; using urakawa.core; using urakawa.media; +using VirtualAudioBackend; namespace Obi { @@ -25,6 +27,9 @@ private Channel mTextChannel; // handy pointer to the text channel private Channel mAnnotationChannel; // handy pointer to the annotation channel + private AssetManager mAssManager; // the asset manager + private string mAssPath; // the path to the asset manager directory + private bool mUnsaved; // saved flag private string mXUKPath; // path to the project XUK file private string mLastPath; // last path to which the project was saved (see save as) @@ -98,6 +103,7 @@ public Project() : base() { + mAssManager = null; mUnsaved = false; mXUKPath = null; } @@ -114,6 +120,8 @@ public void Create(string xukPath, string title, string id, UserProfile userProfile, bool createTitle) { mXUKPath = xukPath; + mAssPath = GetAssetDirectory(xukPath); + mAssManager = new AssetManager(mAssPath); mMetadata = CreateMetadata(title, id, userProfile); mAudioChannel = getPresentation().getChannelFactory().createChannel(AudioChannel); getPresentation().getChannelsManager().addChannel(mAudioChannel); @@ -132,6 +140,18 @@ } /// <summary> + /// Get a suitable directory name to store the assets. + /// </summary> + /// <param name="xukPath"></param> + /// <returns></returns> + private string GetAssetDirectory(string path) + { + string assetdir = Path.GetDirectoryName(path) + @"\" + Path.GetFileNameWithoutExtension(path) + "_assets"; + System.Diagnostics.Debug.Print("Directory for assets: {0}", assetdir); + return assetdir; + } + + /// <summary> /// Open a project from a XUK file. /// Throw an exception if the file could not be read. /// </summary> @@ -166,10 +186,19 @@ case "dc:Publisher": mMetadata.Publisher = meta.getContent(); break; + case "obi:assetsdir": + mAssPath = meta.getContent(); + break; default: break; } } + if (mAssPath == null) + { + mAssPath = GetAssetDirectory(mXUKPath); + AddMetadata("obi:assetsdir", mAssPath); + } + mAssManager = new AssetManager(mAssPath); StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Opened)); } else @@ -210,6 +239,7 @@ urakawa.project.Metadata metaDate = AddMetadata("dc:Date", DateTime.Today.ToString("yyyy-MM-dd")); if (metaDate != null) metaDate.setScheme("YYYY-MM-DD"); AddMetadata("xuk:generator", "Obi+Urakawa toolkit; let's share the blame."); + AddMetadata("obi:assetsdir", mAssPath); return metadata; } @@ -350,7 +380,7 @@ StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); Commands.TOC.AddSection command = new Commands.TOC.AddSection(this, sibling, parent, parent.indexOf(sibling), visitor.Position); - //MED CommandCreated(this, new Events.Project.CommandCreatedEventArgs(command)); + CommandCreated(this, new Events.Project.CommandCreatedEventArgs(command)); } public void CreateSiblingSectionRequested(object sender, Events.Node.NodeEventArgs e) @@ -374,7 +404,7 @@ StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); Commands.TOC.AddSection command = new Commands.TOC.AddSection(this, child, parent, parent.indexOf(child), visitor.Position); - //MEDCommandCreated(this, new Events.Project.CommandCreatedEventArgs(command)); + CommandCreated(this, new Events.Project.CommandCreatedEventArgs(command)); } public void CreateChildSectionRequested(object sender, Events.Node.NodeEventArgs e) @@ -667,7 +697,7 @@ RenamedNode(this, new Events.Node.RenameNodeEventArgs(origin, node, label)); mUnsaved = true; StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); - //MEDif (command != null) CommandCreated(this, new Events.Project.CommandCreatedEventArgs(command)); + if (command != null) CommandCreated(this, new Events.Project.CommandCreatedEventArgs(command)); } public void RenameNodeRequested(object sender, Events.Node.RenameNodeEventArgs e) @@ -675,6 +705,21 @@ RenameNode(sender, e.Node, e.Label); } + /// <summary> + /// Create a new phrase node and add it to the section node. + /// (Well it's not added yet because otherwise it would create all sorts of problems.) + /// </summary> + public void ImportPhraseRequested(object sender, Events.Strip.ImportAssetEventArgs e) + { + ArrayList list = new ArrayList(1); + list.Add(new AudioClip(e.AssetPath)); + AudioMediaAsset asset = mAssManager.NewAudioMediaAsset(list); + CoreNode node = CreatePhraseNode(asset); + // e.SectionNode.appendChild(node); + mUnsaved = true; + StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); + // notify the strip panel + } #endregion @@ -687,13 +732,37 @@ { CoreNode node = getPresentation().getCoreNodeFactory().createNode(); ChannelsProperty prop = (ChannelsProperty)node.getProperty(typeof(ChannelsProperty)); - TextMedia text = (TextMedia)getPresentation().getMediaFactory().createMedia(MediaType.TEXT); + TextMedia text = (TextMedia)getPresentation().getMediaFactory().createMedia(urakawa.media.MediaType.TEXT); text.setText(Localizer.Message("default_section_label")); prop.setMedia(mTextChannel, text); return node; } /// <summary> + /// Create a new phrase node from an asset. + /// Add a default annotation with the name of the file (should be the original name, not the internal one.) + /// Add a seq media object with the clips of the audio asset. Do not forget to set begin/end time explicitely. + /// </summary> + /// <param name="asset">The asset for the phrase.</param> + /// <returns>The created node.</returns> + private CoreNode CreatePhraseNode(AudioMediaAsset asset) + { + CoreNode node = getPresentation().getCoreNodeFactory().createNode(); + ChannelsProperty prop = (ChannelsProperty)node.getProperty(typeof(ChannelsProperty)); + TextMedia annotation = (TextMedia)getPresentation().getMediaFactory().createMedia(urakawa.media.MediaType.TEXT); + annotation.setText(asset.Name); + prop.setMedia(mAnnotationChannel, annotation); + SequenceMedia seq = + (SequenceMedia)getPresentation().getMediaFactory().createMedia(urakawa.media.MediaType.EMPTY_SEQUENCE); + AudioMedia audio = (AudioMedia)getPresentation().getMediaFactory().createMedia(urakawa.media.MediaType.AUDIO); + AudioClip clip = (AudioClip)asset.m_alClipList[0]; // should be clip = asset.Clip(0); or better: foreach clip... + audio.setLocation(new MediaLocation(clip.Path)); + seq.appendItem(audio); + prop.setMedia(mAudioChannel, seq); + return node; + } + + /// <summary> /// Get the text media of a core node. The result can then be used to get or set the text of a node. /// Original comments: A helper function to get the text from the given <see cref="CoreNode"/>. /// The text channel which contains the desired text will be named so that we know Modified: trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-27 10:08:09 UTC (rev 666) +++ trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-27 15:47:59 UTC (rev 667) @@ -58,7 +58,10 @@ mProject.DeletedNode -= new Events.Node.DeletedNodeHandler(mTOCPanel.SyncDeletedNode); //comment: this used to say += but I think it was a typo + //reply: yes it was. -= is the way to go. mProject.DeletedNode -= new Events.Node.DeletedNodeHandler(mStripManagerPanel.SyncDeletedNode); + + mStripManagerPanel.ImportPhrase -= new Events.Strip.RequestToImportAssetHandler(mProject.ImportPhraseRequested); } // Set up the handlers for the new project if (value != null) @@ -91,6 +94,8 @@ mTOCPanel.RequestToDeleteSection += new Events.Node.RequestToDeleteNodeHandler(value.RemoveNodeRequested); value.DeletedNode += new Events.Node.DeletedNodeHandler(mTOCPanel.SyncDeletedNode); value.DeletedNode += new Events.Node.DeletedNodeHandler(mStripManagerPanel.SyncDeletedNode); + + mStripManagerPanel.ImportPhrase += new Events.Strip.RequestToImportAssetHandler(value.ImportPhraseRequested); } mProject = value; mSplitContainer.Visible = mProject != null; Modified: trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.Designer.cs 2006-07-27 10:08:09 UTC (rev 666) +++ trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.Designer.cs 2006-07-27 15:47:59 UTC (rev 667) @@ -68,7 +68,6 @@ this.mTextBox.Size = new System.Drawing.Size(235, 16); this.mTextBox.TabIndex = 2; this.mTextBox.Visible = false; - this.mTextBox.Leave += new System.EventHandler(this.mTextBox_Leave); this.mTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.mTextBox_KeyDown); // // SectionStrip Modified: trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs 2006-07-27 10:08:09 UTC (rev 666) +++ trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs 2006-07-27 15:47:59 UTC (rev 667) @@ -34,6 +34,8 @@ this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.addStripToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.renameStripToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.importAssetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.contextMenuStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -66,25 +68,39 @@ // this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.addStripToolStripMenuItem, - this.renameStripToolStripMenuItem}); + this.renameStripToolStripMenuItem, + this.toolStripSeparator1, + this.importAssetToolStripMenuItem}); this.contextMenuStrip1.Name = "contextMenuStrip1"; this.contextMenuStrip1.ShowImageMargin = false; - this.contextMenuStrip1.Size = new System.Drawing.Size(114, 48); + this.contextMenuStrip1.Size = new System.Drawing.Size(128, 98); // // addStripToolStripMenuItem // this.addStripToolStripMenuItem.Name = "addStripToolStripMenuItem"; - this.addStripToolStripMenuItem.Size = new System.Drawing.Size(113, 22); + this.addStripToolStripMenuItem.Size = new System.Drawing.Size(127, 22); this.addStripToolStripMenuItem.Text = "&Add strip"; this.addStripToolStripMenuItem.Click += new System.EventHandler(this.addStripToolStripMenuItem_Click); // // renameStripToolStripMenuItem // this.renameStripToolStripMenuItem.Name = "renameStripToolStripMenuItem"; - this.renameStripToolStripMenuItem.Size = new System.Drawing.Size(113, 22); + this.renameStripToolStripMenuItem.Size = new System.Drawing.Size(127, 22); this.renameStripToolStripMenuItem.Text = "&Rename strip"; this.renameStripToolStripMenuItem.Click += new System.EventHandler(this.renameStripToolStripMenuItem_Click); // + // importAssetToolStripMenuItem + // + this.importAssetToolStripMenuItem.Name = "importAssetToolStripMenuItem"; + this.importAssetToolStripMenuItem.Size = new System.Drawing.Size(127, 22); + this.importAssetToolStripMenuItem.Text = "&Import asset"; + this.importAssetToolStripMenuItem.Click += new System.EventHandler(this.importAssetToolStripMenuItem_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(124, 6); + // // StripManagerPanel // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -106,5 +122,7 @@ private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; private System.Windows.Forms.ToolStripMenuItem addStripToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem renameStripToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripMenuItem importAssetToolStripMenuItem; } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-07-27 10:08:09 UTC (rev 666) +++ trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-07-27 15:47:59 UTC (rev 667) @@ -20,6 +20,7 @@ public event Events.Node.RequestToAddSiblingNodeHandler AddSiblingSection; public event Events.Node.RequestToRenameNodeHandler RenameSection; + public event Events.Strip.RequestToImportAssetHandler ImportPhrase; public event Events.Strip.SelectedHandler SelectedStrip; public CoreNode SelectedNode @@ -157,6 +158,20 @@ } } + internal void importAssetToolStripMenuItem_Click(object sender, EventArgs e) + { + if (SelectedNode != null) + { + OpenFileDialog dialog = new OpenFileDialog(); + dialog.Filter = "WAVE file (*.wav)|*.wav|Any file|*.*"; + dialog.ShowDialog(); + if (dialog.ShowDialog() == DialogResult.OK) + { + ImportPhrase(this, new Events.Strip.ImportAssetEventArgs(mSelectedNode, dialog.FileName)); + } + } + } + #endregion /// <summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-07-28 22:17:12
|
Revision: 659 Author: marisademeglio Date: 2006-07-25 16:08:00 -0700 (Tue, 25 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=659&view=rev Log Message: ----------- Events related to nodes are a lot simpler. Since the event origin is now in all event arguments, we can probably omit it from a lot of the function parameters. This hasn't been done yet. Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Obi.csproj trunk/urakawa/application/Obi/Obi/Project.cs trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs Added Paths: ----------- trunk/urakawa/application/Obi/Obi/Events/Node/AddedSectionNodeEventArgs.cs trunk/urakawa/application/Obi/Obi/Events/Node/NodeEventArgs.cs trunk/urakawa/application/Obi/Obi/Events/Node/RenameNodeEventArgs.cs Removed Paths: ------------- trunk/urakawa/application/Obi/Obi/Events/Node/AddSectionEventArgs.cs trunk/urakawa/application/Obi/Obi/Events/Node/ChangeSectionLevelEventArgs.cs trunk/urakawa/application/Obi/Obi/Events/Node/DeleteSectionEventArgs.cs trunk/urakawa/application/Obi/Obi/Events/Node/MoveSectionEventArgs.cs trunk/urakawa/application/Obi/Obi/Events/Node/RenameSectionEventArgs.cs trunk/urakawa/application/Obi/Obi/Events/Sync/ Deleted: trunk/urakawa/application/Obi/Obi/Events/Node/AddSectionEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/AddSectionEventArgs.cs 2006-07-25 21:08:03 UTC (rev 658) +++ trunk/urakawa/application/Obi/Obi/Events/Node/AddSectionEventArgs.cs 2006-07-25 23:08:00 UTC (rev 659) @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using urakawa.core; - -namespace Obi.Events.Node -{ - public delegate void AddSiblingSectionHandler(object sender, AddSectionEventArgs e); - public delegate void AddChildSectionHandler(object sender, AddSectionEventArgs e); - - /// <summary> - /// This event is fired when a view wants to add a new sibling section node in the core tree. - /// </summary> - public class AddSectionEventArgs : EventArgs - { - private CoreNode mContextNode; // the node after which to add the new sibling - - public CoreNode ContextNode - { - get - { - return mContextNode; - } - } - - public AddSectionEventArgs(CoreNode contextNode) - { - mContextNode = contextNode; - } - } -} Added: trunk/urakawa/application/Obi/Obi/Events/Node/AddedSectionNodeEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/AddedSectionNodeEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Node/AddedSectionNodeEventArgs.cs 2006-07-25 23:08:00 UTC (rev 659) @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using urakawa.core; + +namespace Obi.Events.Node +{ + public delegate void AddedSectionNodeHandler(object sender, AddedSectionNodeEventArgs e); + + /// <summary> + /// A section node was added. + /// </summary> + class AddedSectionNodeEventArgs: NodeEventArgs + { + private int mPosition; // the position in the flat list of nodes + private int mIndex; // the index of the node in the parent's list of children + + public int Index + { + get + { + return mIndex; + } + } + + public int Position + { + get + { + return mPosition; + } + } + + public AddedSectionNodeEventArgs(object origin, CoreNode node, int index, int position) : + base(origin, node) + { + + mIndex = index; + mPosition = position; + } + } +} Deleted: trunk/urakawa/application/Obi/Obi/Events/Node/ChangeSectionLevelEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/ChangeSectionLevelEventArgs.cs 2006-07-25 21:08:03 UTC (rev 658) +++ trunk/urakawa/application/Obi/Obi/Events/Node/ChangeSectionLevelEventArgs.cs 2006-07-25 23:08:00 UTC (rev 659) @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using urakawa.core; - -namespace Obi.Events.Node -{ - public delegate void IncreaseSectionLevelHandler(object sender, - ChangeSectionLevelEventArgs e); - public delegate void DecreaseSectionLevelHandler(object sender, - ChangeSectionLevelEventArgs e); - - /// <summary> - /// This event is fired to request to increase a section by one level depth - /// </summary> - class ChangeSectionLevelEventArgs : EventArgs - { - private CoreNode mContextNode; // the node to be moved - - public CoreNode ContextNode - { - get - { - return mContextNode; - } - } - - public ChangeSectionLevelEventArgs(CoreNode contextNode) - { - mContextNode = contextNode; - } - } -} Deleted: trunk/urakawa/application/Obi/Obi/Events/Node/DeleteSectionEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/DeleteSectionEventArgs.cs 2006-07-25 21:08:03 UTC (rev 658) +++ trunk/urakawa/application/Obi/Obi/Events/Node/DeleteSectionEventArgs.cs 2006-07-25 23:08:00 UTC (rev 659) @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using urakawa.core; - -namespace Obi.Events.Node -{ - public delegate void DeleteSectionHandler(object sender, DeleteSectionEventArgs e); - - public class DeleteSectionEventArgs : EventArgs - { - private CoreNode mNode; - - public CoreNode Node - { - get - { - return mNode; - } - } - - public DeleteSectionEventArgs(CoreNode node) - { - mNode = node; - } - } -} Deleted: trunk/urakawa/application/Obi/Obi/Events/Node/MoveSectionEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/MoveSectionEventArgs.cs 2006-07-25 21:08:03 UTC (rev 658) +++ trunk/urakawa/application/Obi/Obi/Events/Node/MoveSectionEventArgs.cs 2006-07-25 23:08:00 UTC (rev 659) @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using urakawa.core; - -namespace Obi.Events.Node -{ - public delegate void MoveSectionUpHandler(object sender, MoveSectionEventArgs e); - public delegate void MoveSectionDownHandler(object sender, MoveSectionEventArgs e); - - /// <summary> - /// This event is fired when a view wants to move a node up (reorder) in the core tree. - /// </summary> - public class MoveSectionEventArgs : EventArgs - { - private CoreNode mNode; // the node that will move up - - public CoreNode Node - { - get - { - return mNode; - } - } - - public MoveSectionEventArgs(CoreNode node) - { - mNode = node; - } - } -} Added: trunk/urakawa/application/Obi/Obi/Events/Node/NodeEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/NodeEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Node/NodeEventArgs.cs 2006-07-25 23:08:00 UTC (rev 659) @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using urakawa.core; + +namespace Obi.Events.Node +{ + public delegate void RequestToAddSiblingNodeHandler(object sender, NodeEventArgs e); + public delegate void RequestToAddChildNodeHandler(object sender, NodeEventArgs e); + public delegate void RequestToIncreaseNodeLevelHandler(object sender, NodeEventArgs e); + public delegate void RequestToDecreaseNodeLevelHandler(object sender, NodeEventArgs e); + public delegate void RequestToDeleteNodeHandler(object sender, NodeEventArgs e); + public delegate void RequestToMoveNodeUpHandler(object sender, NodeEventArgs e); + public delegate void RequestToMoveNodeDownHandler(object sender, NodeEventArgs e); + + + public delegate void IncreasedNodeLevelHandler(object sender, NodeEventArgs e); + public delegate void DecreasedNodeLevelHandler(object sender, NodeEventArgs e); + public delegate void DeletedNodeHandler(object sender, NodeEventArgs e); + public delegate void ShallowDeletedNodeHandler(object sender, NodeEventArgs e); + public delegate void MovedNodeUpHandler(object sender, NodeEventArgs e); + public delegate void MovedNodeDownHandler(object sender, NodeEventArgs e); + + public class NodeEventArgs : EventArgs + { + private CoreNode mNode; // the node on which the operation is performed + private object mOrigin; // the origin of the event (initial requester) + + public CoreNode Node + { + get + { + return mNode; + } + } + + public object Origin + { + get + { + return mOrigin; + } + } + + public NodeEventArgs(object origin, CoreNode node) + { + mOrigin = origin; + mNode = node; + } + } +} Added: trunk/urakawa/application/Obi/Obi/Events/Node/RenameNodeEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/RenameNodeEventArgs.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Events/Node/RenameNodeEventArgs.cs 2006-07-25 23:08:00 UTC (rev 659) @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using urakawa.core; + +namespace Obi.Events.Node +{ + public delegate void RequestToRenameNodeHandler(object sender, RenameNodeEventArgs e); + public delegate void RenamedNodeHandler(object sender, RenameNodeEventArgs e); + + /// <summary> + /// This event is fired when a view wants to rename a section. + /// </summary> + public class RenameNodeEventArgs : NodeEventArgs + { + private string mLabel; // the new text label of the node + + public string Label + { + get + { + return mLabel; + } + } + + public RenameNodeEventArgs(object origin, CoreNode node, string label) : + base(origin, node) + { + mLabel = label; + } + } +} Deleted: trunk/urakawa/application/Obi/Obi/Events/Node/RenameSectionEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/RenameSectionEventArgs.cs 2006-07-25 21:08:03 UTC (rev 658) +++ trunk/urakawa/application/Obi/Obi/Events/Node/RenameSectionEventArgs.cs 2006-07-25 23:08:00 UTC (rev 659) @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using urakawa.core; - -namespace Obi.Events.Node -{ - public delegate void RenameSectionHandler(object sender, RenameSectionEventArgs e); - - /// <summary> - /// This event is fired when a view wants to rename a section. - /// </summary> - public class RenameSectionEventArgs : EventArgs - { - private CoreNode mNode; // the node to rename - private string mLabel; // the new text label of the node - - public CoreNode Node - { - get - { - return mNode; - } - } - - public string Label - { - get - { - return mLabel; - } - } - - public RenameSectionEventArgs(CoreNode node, string label) - { - mNode = node; - mLabel = label; - } - } -} Modified: trunk/urakawa/application/Obi/Obi/Obi.csproj =================================================================== --- trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-25 21:08:03 UTC (rev 658) +++ trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-25 23:08:00 UTC (rev 659) @@ -95,17 +95,11 @@ <Compile Include="Dialogs\UserProfile.Designer.cs"> <DependentUpon>UserProfile.cs</DependentUpon> </Compile> - <Compile Include="Events\Node\DeleteSectionEventArgs.cs" /> - <Compile Include="Events\Node\AddSectionEventArgs.cs" /> - <Compile Include="Events\Node\ChangeSectionLevelEventArgs.cs" /> - <Compile Include="Events\Node\MoveSectionEventArgs.cs" /> - <Compile Include="Events\Node\RenameSectionEventArgs.cs" /> + <Compile Include="Events\Node\NodeEventArgs.cs" /> + <Compile Include="Events\Node\RenameNodeEventArgs.cs" /> <Compile Include="Events\Project\StateChangedEventArgs.cs" /> <Compile Include="Events\Strip\SelectedEventArgs.cs" /> - <Compile Include="Events\Sync\AddedSectionNodeEventArgs.cs" /> - <Compile Include="Events\Sync\DeletedNodeEventArgs.cs" /> - <Compile Include="Events\Sync\MovedNodeEventArgs.cs" /> - <Compile Include="Events\Sync\RenamedNodeEventArgs.cs" /> + <Compile Include="Events\Node\AddedSectionNodeEventArgs.cs" /> <Compile Include="Localizer.cs" /> <Compile Include="messages.Designer.cs"> <AutoGen>True</AutoGen> Modified: trunk/urakawa/application/Obi/Obi/Project.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-25 21:08:03 UTC (rev 658) +++ trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-25 23:08:00 UTC (rev 659) @@ -35,11 +35,11 @@ public static readonly string AnnotationChannel = "obi.annotation"; // canonical name of the annotation channel public event Events.Project.StateChangedHandler StateChanged; // the state of the project changed (modified, saved...) - public event Events.Sync.AddedSectionNodeHandler AddedSectionNode; // a section node was added to the TOC - public event Events.Sync.DeletedNodeHandler DeletedNode; // a node was deleted from the presentation - public event Events.Sync.RenamedNodeHandler RenamedNode; // a node was renamed in the presentation - public event Events.Sync.MovedNodeUpHandler MovedNodeUp; // a node was moved up in the presentation - public event Events.Sync.MovedNodeDownHandler MovedNodeDown; // a node was moved down in the presentation + public event Events.Node.AddedSectionNodeHandler AddedSectionNode; // a section node was added to the TOC + public event Events.Node.DeletedNodeHandler DeletedNode; // a node was deleted from the presentation + public event Events.Node.RenamedNodeHandler RenamedNode; // a node was renamed in the presentation + public event Events.Node.MovedNodeUpHandler MovedNodeUp; // a node was moved up in the presentation + public event Events.Node.MovedNodeDownHandler MovedNodeDown; // a node was moved down in the presentation /// <summary> /// This flag is set to true if the project contains modifications that have not been saved. /// </summary> @@ -334,7 +334,7 @@ getPresentation().getRootNode().appendChild(sibling); NodePositionVisitor visitor = new NodePositionVisitor(sibling); getPresentation().getRootNode().acceptDepthFirst(visitor); - AddedSectionNode(this, new Events.Sync.AddedSectionNodeEventArgs(origin, sibling, + AddedSectionNode(this, new Events.Node.AddedSectionNodeEventArgs(origin, sibling, ((CoreNode)sibling.getParent()).indexOf(sibling), visitor.Position)); } else @@ -343,17 +343,17 @@ parent.insert(sibling, parent.indexOf(contextNode) + 1); NodePositionVisitor visitor = new NodePositionVisitor(sibling); getPresentation().getRootNode().acceptDepthFirst(visitor); - AddedSectionNode(this, new Events.Sync.AddedSectionNodeEventArgs(origin, sibling, parent.indexOf(sibling), + AddedSectionNode(this, new Events.Node.AddedSectionNodeEventArgs(origin, sibling, parent.indexOf(sibling), visitor.Position)); } mUnsaved = true; StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); } - public void CreateSiblingSectionRequested(object sender, Events.Node.AddSectionEventArgs e) + public void CreateSiblingSectionRequested(object sender, Events.Node.NodeEventArgs e) { System.Diagnostics.Debug.WriteLine("create sibling request from " + sender.ToString() + " with hash: " + sender.GetHashCode()); - CreateSiblingSection(sender, e.ContextNode); + CreateSiblingSection(sender, e.Node); } /// <summary> @@ -366,14 +366,14 @@ parent.appendChild(child); NodePositionVisitor visitor = new NodePositionVisitor(child); getPresentation().getRootNode().acceptDepthFirst(visitor); - AddedSectionNode(this, new Events.Sync.AddedSectionNodeEventArgs(origin, child, parent.indexOf(child), visitor.Position)); + AddedSectionNode(this, new Events.Node.AddedSectionNodeEventArgs(origin, child, parent.indexOf(child), visitor.Position)); mUnsaved = true; StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); } - public void CreateChildSectionRequested(object sender, Events.Node.AddSectionEventArgs e) + public void CreateChildSectionRequested(object sender, Events.Node.NodeEventArgs e) { - CreateChildSection(sender, e.ContextNode); + CreateChildSection(sender, e.Node); } /// <summary> @@ -384,7 +384,7 @@ { CoreNode parent = (CoreNode)node.getParent(); parent.insert(node, index); - AddedSectionNode(this, new Events.Sync.AddedSectionNodeEventArgs(this, node, index, position)); + AddedSectionNode(this, new Events.Node.AddedSectionNodeEventArgs(this, node, index, position)); mUnsaved = true; StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); } @@ -397,13 +397,13 @@ if (node != null) { node.detach(); - DeletedNode(this, new Events.Sync.DeletedNodeEventArgs(origin, node)); + DeletedNode(this, new Events.Node.NodeEventArgs(origin, node)); mUnsaved = true; StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); } } - public void RemoveNodeRequested(object sender, Events.Node.DeleteSectionEventArgs e) + public void RemoveNodeRequested(object sender, Events.Node.NodeEventArgs e) { RemoveNode(sender, e.Node); } @@ -417,7 +417,7 @@ bool moveUpSucceeded = ExecuteMoveNodeUpLogic(node); if (moveUpSucceeded) { - MovedNodeUp(this, new Events.Sync.MovedNodeEventArgs(origin, node)); + MovedNodeUp(this, new Events.Node.NodeEventArgs(origin, node)); mUnsaved = true; StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); } @@ -462,7 +462,7 @@ } } - public void MoveNodeUpRequested(object sender, Events.Node.MoveSectionEventArgs e) + public void MoveNodeUpRequested(object sender, Events.Node.NodeEventArgs e) { MoveNodeUp(sender, e.Node); } @@ -473,7 +473,7 @@ bool moveDownSucceeded = ExecuteMoveNodeDownLogic(node); if (moveDownSucceeded) { - MovedNodeDown(this, new Events.Sync.MovedNodeEventArgs(origin, node)); + MovedNodeDown(this, new Events.Node.NodeEventArgs(origin, node)); mUnsaved = true; StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); } @@ -518,7 +518,7 @@ } } - public void MoveNodeDownRequested(object sender, Events.Node.MoveSectionEventArgs e) + public void MoveNodeDownRequested(object sender, Events.Node.NodeEventArgs e) { MoveNodeDown(sender, e.Node); } @@ -529,12 +529,12 @@ public void RenameNode(object origin, CoreNode node, string label) { GetTextMedia(node).setText(label); - RenamedNode(this, new Events.Sync.RenamedNodeEventArgs(origin, node, label)); + RenamedNode(this, new Events.Node.RenameNodeEventArgs(origin, node, label)); mUnsaved = true; StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); } - public void RenameNodeRequested(object sender, Events.Node.RenameSectionEventArgs e) + public void RenameNodeRequested(object sender, Events.Node.RenameNodeEventArgs e) { RenameNode(sender, e.Node, e.Label); } Modified: trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-25 21:08:03 UTC (rev 658) +++ trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-25 23:08:00 UTC (rev 659) @@ -28,63 +28,63 @@ // Reset the handlers from the previous project if (mProject != null) { - mTOCPanel.AddSiblingSection -= new Events.Node.AddSiblingSectionHandler(mProject.CreateSiblingSectionRequested); + mTOCPanel.AddSiblingSection -= new Events.Node.RequestToAddSiblingNodeHandler(mProject.CreateSiblingSectionRequested); mStripManagerPanel.AddSiblingSection -= - new Events.Node.AddSiblingSectionHandler(mProject.CreateSiblingSectionRequested); + new Events.Node.RequestToAddSiblingNodeHandler(mProject.CreateSiblingSectionRequested); //mProject.AddedSiblingNode -= new Events.Sync.AddedSiblingNodeHandler(mTOCPanel.SyncAddedSiblingNode); //mProject.AddedSiblingNode -= new Events.Sync.AddedSiblingNodeHandler(mStripManagerPanel.SyncAddedSiblingNode); - mProject.AddedSectionNode -= new Events.Sync.AddedSectionNodeHandler(mTOCPanel.SyncAddedSectionNode); - mProject.AddedSectionNode -= new Events.Sync.AddedSectionNodeHandler(mStripManagerPanel.SyncAddedSectionNode); + mProject.AddedSectionNode -= new Events.Node.AddedSectionNodeHandler(mTOCPanel.SyncAddedSectionNode); + mProject.AddedSectionNode -= new Events.Node.AddedSectionNodeHandler(mStripManagerPanel.SyncAddedSectionNode); - mTOCPanel.AddChildSection -= new Events.Node.AddChildSectionHandler(mProject.CreateChildSectionRequested); + mTOCPanel.AddChildSection -= new Events.Node.RequestToAddChildNodeHandler(mProject.CreateChildSectionRequested); //mProject.AddedChildNode -= new Events.Sync.AddedChildNodeHandler(mTOCPanel.SyncAddedChildNode); //mProject.AddedChildNode -= new Events.Sync.AddedChildNodeHandler(mStripManagerPanel.SyncAddedChildNode); - mTOCPanel.MoveSectionUp -= new Events.Node.MoveSectionUpHandler(mProject.MoveNodeUpRequested); - mProject.MovedNodeUp -= new Events.Sync.MovedNodeUpHandler(mTOCPanel.SyncMovedNodeUp); + mTOCPanel.MoveSectionUp -= new Events.Node.RequestToMoveNodeUpHandler(mProject.MoveNodeUpRequested); + mProject.MovedNodeUp -= new Events.Node.MovedNodeUpHandler(mTOCPanel.SyncMovedNodeUp); - mTOCPanel.MoveSectionDown -= new Events.Node.MoveSectionDownHandler(mProject.MoveNodeDownRequested); - mProject.MovedNodeDown -= new Events.Sync.MovedNodeDownHandler(mTOCPanel.SyncMovedNodeDown); + mTOCPanel.MoveSectionDown -= new Events.Node.RequestToMoveNodeDownHandler(mProject.MoveNodeDownRequested); + mProject.MovedNodeDown -= new Events.Node.MovedNodeDownHandler(mTOCPanel.SyncMovedNodeDown); - mTOCPanel.RenameSection -= new Events.Node.RenameSectionHandler(mProject.RenameNodeRequested); - mStripManagerPanel.RenameSection -= new Events.Node.RenameSectionHandler(mProject.RenameNodeRequested); - mProject.RenamedNode -= new Events.Sync.RenamedNodeHandler(mTOCPanel.SyncRenamedNode); - mProject.RenamedNode -= new Events.Sync.RenamedNodeHandler(mStripManagerPanel.SyncRenamedNode); + mTOCPanel.RenameSection -= new Events.Node.RequestToRenameNodeHandler(mProject.RenameNodeRequested); + mStripManagerPanel.RenameSection -= new Events.Node.RequestToRenameNodeHandler(mProject.RenameNodeRequested); + mProject.RenamedNode -= new Events.Node.RenamedNodeHandler(mTOCPanel.SyncRenamedNode); + mProject.RenamedNode -= new Events.Node.RenamedNodeHandler(mStripManagerPanel.SyncRenamedNode); - mTOCPanel.DeleteSection -= new Events.Node.DeleteSectionHandler(mProject.RemoveNodeRequested); - mProject.DeletedNode -= new Events.Sync.DeletedNodeHandler(mTOCPanel.SyncDeletedNode); + mTOCPanel.DeleteSection -= new Events.Node.RequestToDeleteNodeHandler(mProject.RemoveNodeRequested); + mProject.DeletedNode -= new Events.Node.DeletedNodeHandler(mTOCPanel.SyncDeletedNode); //comment: this used to say += but I think it was a typo - mProject.DeletedNode -= new Events.Sync.DeletedNodeHandler(mStripManagerPanel.SyncDeletedNode); + mProject.DeletedNode -= new Events.Node.DeletedNodeHandler(mStripManagerPanel.SyncDeletedNode); } // Set up the handlers for the new project if (value != null) { - mTOCPanel.AddSiblingSection += new Events.Node.AddSiblingSectionHandler(value.CreateSiblingSectionRequested); + mTOCPanel.AddSiblingSection += new Events.Node.RequestToAddSiblingNodeHandler(value.CreateSiblingSectionRequested); mStripManagerPanel.AddSiblingSection += - new Events.Node.AddSiblingSectionHandler(value.CreateSiblingSectionRequested); - value.AddedSectionNode += new Events.Sync.AddedSectionNodeHandler(mTOCPanel.SyncAddedSectionNode); - value.AddedSectionNode += new Events.Sync.AddedSectionNodeHandler(mStripManagerPanel.SyncAddedSectionNode); + new Events.Node.RequestToAddSiblingNodeHandler(value.CreateSiblingSectionRequested); + value.AddedSectionNode += new Events.Node.AddedSectionNodeHandler(mTOCPanel.SyncAddedSectionNode); + value.AddedSectionNode += new Events.Node.AddedSectionNodeHandler(mStripManagerPanel.SyncAddedSectionNode); - mTOCPanel.AddChildSection += new Events.Node.AddChildSectionHandler(value.CreateChildSectionRequested); + mTOCPanel.AddChildSection += new Events.Node.RequestToAddChildNodeHandler(value.CreateChildSectionRequested); //value.AddedChildNode += new Events.Sync.AddedChildNodeHandler(mTOCPanel.SyncAddedChildNode); //value.AddedChildNode += new Events.Sync.AddedChildNodeHandler(mStripManagerPanel.SyncAddedChildNode); - mTOCPanel.MoveSectionUp += new Events.Node.MoveSectionUpHandler(value.MoveNodeUpRequested); - value.MovedNodeUp += new Events.Sync.MovedNodeUpHandler(mTOCPanel.SyncMovedNodeUp); + mTOCPanel.MoveSectionUp += new Events.Node.RequestToMoveNodeUpHandler(value.MoveNodeUpRequested); + value.MovedNodeUp += new Events.Node.MovedNodeUpHandler(mTOCPanel.SyncMovedNodeUp); - mTOCPanel.MoveSectionDown += new Events.Node.MoveSectionDownHandler(value.MoveNodeDownRequested); - value.MovedNodeDown += new Events.Sync.MovedNodeDownHandler(mTOCPanel.SyncMovedNodeDown); + mTOCPanel.MoveSectionDown += new Events.Node.RequestToMoveNodeDownHandler(value.MoveNodeDownRequested); + value.MovedNodeDown += new Events.Node.MovedNodeDownHandler(mTOCPanel.SyncMovedNodeDown); - mTOCPanel.RenameSection += new Events.Node.RenameSectionHandler(value.RenameNodeRequested); - mStripManagerPanel.RenameSection += new Events.Node.RenameSectionHandler(value.RenameNodeRequested); - value.RenamedNode += new Events.Sync.RenamedNodeHandler(mTOCPanel.SyncRenamedNode); - value.RenamedNode += new Events.Sync.RenamedNodeHandler(mStripManagerPanel.SyncRenamedNode); + mTOCPanel.RenameSection += new Events.Node.RequestToRenameNodeHandler(value.RenameNodeRequested); + mStripManagerPanel.RenameSection += new Events.Node.RequestToRenameNodeHandler(value.RenameNodeRequested); + value.RenamedNode += new Events.Node.RenamedNodeHandler(mTOCPanel.SyncRenamedNode); + value.RenamedNode += new Events.Node.RenamedNodeHandler(mStripManagerPanel.SyncRenamedNode); - mTOCPanel.DeleteSection += new Events.Node.DeleteSectionHandler(value.RemoveNodeRequested); - value.DeletedNode += new Events.Sync.DeletedNodeHandler(mTOCPanel.SyncDeletedNode); - value.DeletedNode += new Events.Sync.DeletedNodeHandler(mStripManagerPanel.SyncDeletedNode); + mTOCPanel.DeleteSection += new Events.Node.RequestToDeleteNodeHandler(value.RemoveNodeRequested); + value.DeletedNode += new Events.Node.DeletedNodeHandler(mTOCPanel.SyncDeletedNode); + value.DeletedNode += new Events.Node.DeletedNodeHandler(mStripManagerPanel.SyncDeletedNode); } mProject = value; mSplitContainer.Visible = mProject != null; Modified: trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-07-25 21:08:03 UTC (rev 658) +++ trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-07-25 23:08:00 UTC (rev 659) @@ -18,8 +18,8 @@ private Dictionary<CoreNode, SectionStrip> mNodeMap; // find a strip for a given node private CoreNode mSelectedNode; // the selected node - public event Events.Node.AddSiblingSectionHandler AddSiblingSection; - public event Events.Node.RenameSectionHandler RenameSection; + public event Events.Node.RequestToAddSiblingNodeHandler AddSiblingSection; + public event Events.Node.RequestToRenameNodeHandler RenameSection; public event Events.Strip.SelectedHandler SelectedStrip; public CoreNode SelectedNode @@ -99,7 +99,7 @@ #region Sync event handlers - internal void SyncAddedSectionNode(object sender, Events.Sync.AddedSectionNodeEventArgs e) + internal void SyncAddedSectionNode(object sender, Events.Node.AddedSectionNodeEventArgs e) { AddStripFromNode(e.Node, e.Position, e.Origin == this); } @@ -127,7 +127,7 @@ if (rename) strip.StartRenaming(); } - internal void SyncRenamedNode(object sender, Events.Sync.RenamedNodeEventArgs e) + internal void SyncRenamedNode(object sender, Events.Node.RenameNodeEventArgs e) { SectionStrip strip = mNodeMap[e.Node]; strip.Label = e.Label; @@ -136,7 +136,7 @@ /// <summary> /// When deleting a node from the tree, all descendants are deleted as well. /// </summary> - internal void SyncDeletedNode(object sender, Events.Sync.DeletedNodeEventArgs e) + internal void SyncDeletedNode(object sender, Events.Node.NodeEventArgs e) { if (e.Node != null) { @@ -161,7 +161,7 @@ internal void addStripToolStripMenuItem_Click(object sender, EventArgs e) { - AddSiblingSection(this, new Events.Node.AddSectionEventArgs(mSelectedNode)); + AddSiblingSection(this, new Events.Node.NodeEventArgs(this, mSelectedNode)); } internal void renameStripToolStripMenuItem_Click(object sender, EventArgs e) @@ -181,7 +181,7 @@ /// <param name="strip">The renamed strip (with its new name as a label.)</param> internal void RenamedSectionStrip(SectionStrip strip) { - RenameSection(this, new Events.Node.RenameSectionEventArgs(strip.Node, strip.Label)); + RenameSection(this, new Events.Node.RenameNodeEventArgs(this, strip.Node, strip.Label)); } } } \ No newline at end of file Modified: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-25 21:08:03 UTC (rev 658) +++ trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-25 23:08:00 UTC (rev 659) @@ -19,14 +19,14 @@ /// </summary> public partial class TOCPanel : UserControl, ICoreNodeVisitor { - public event Events.Node.AddSiblingSectionHandler AddSiblingSection; - public event Events.Node.AddChildSectionHandler AddChildSection; - public event Events.Node.DecreaseSectionLevelHandler DecreaseSectionLevel; - public event Events.Node.IncreaseSectionLevelHandler IncreaseSectionLevel; - public event Events.Node.MoveSectionDownHandler MoveSectionDown; - public event Events.Node.MoveSectionUpHandler MoveSectionUp; - public event Events.Node.RenameSectionHandler RenameSection; - public event Events.Node.DeleteSectionHandler DeleteSection; + public event Events.Node.RequestToAddSiblingNodeHandler AddSiblingSection; + public event Events.Node.RequestToAddChildNodeHandler AddChildSection; + public event Events.Node.RequestToDecreaseNodeLevelHandler DecreaseSectionLevel; + public event Events.Node.RequestToIncreaseNodeLevelHandler IncreaseSectionLevel; + public event Events.Node.RequestToMoveNodeDownHandler MoveSectionDown; + public event Events.Node.RequestToMoveNodeUpHandler MoveSectionUp; + public event Events.Node.RequestToRenameNodeHandler RenameSection; + public event Events.Node.RequestToDeleteNodeHandler DeleteSection; /// <summary> /// Test whether a node is currently selected or not. @@ -118,16 +118,6 @@ InitializeComponent(); } - //always allowed until level 1 - public void DecreaseCurrentSectionLevel() - { - } - - //allowed if you have a previous sibling - public void IncreaseCurrentSectionLevel() - { - } - public void LimitViewToDepthOfCurrentSection() { } @@ -187,7 +177,7 @@ System.Diagnostics.Debug.WriteLine("TOC panel click!\n"); AddSiblingSection(this, - new Events.Node.AddSectionEventArgs(GetSelectedSection())); + new Events.Node.NodeEventArgs(this, GetSelectedSection())); } /// <summary> @@ -196,7 +186,7 @@ internal void addSubSectionToolStripMenuItem_Click(object sender, EventArgs e) { AddChildSection(this, - new Events.Node.AddSectionEventArgs(GetSelectedSection())); + new Events.Node.NodeEventArgs(this, GetSelectedSection())); } /// <summary> @@ -205,7 +195,7 @@ internal void moveUpToolStripMenuItem_Click(object sender, EventArgs e) { MoveSectionUp(this, - new Events.Node.MoveSectionEventArgs(GetSelectedSection())); + new Events.Node.NodeEventArgs(this, GetSelectedSection())); } /// <summary> @@ -213,7 +203,7 @@ /// </summary> internal void deleteSectionToolStripMenuItem_Click(object sender, EventArgs e) { - DeleteSection(this, new Events.Node.DeleteSectionEventArgs(GetSelectedSection())); + DeleteSection(this, new Events.Node.NodeEventArgs(this, GetSelectedSection())); } internal void editLabelToolStripMenuItem_Click(object sender, EventArgs e) @@ -225,13 +215,13 @@ internal void moveDownToolStripMenuItem_Click(object sender, EventArgs e) { MoveSectionDown(this, - new Events.Node.MoveSectionEventArgs(GetSelectedSection())); + new Events.Node.NodeEventArgs(this, GetSelectedSection())); } internal void increaseLevelToolStripMenuItem_Click(object sender, EventArgs e) { IncreaseSectionLevel(this, - new Events.Node.ChangeSectionLevelEventArgs(GetSelectedSection())); + new Events.Node.NodeEventArgs(this, GetSelectedSection())); } internal void decreaseLevelToolStripMenuItem_Click(object sender, EventArgs e) @@ -240,7 +230,7 @@ sel.BeginEdit(); DecreaseSectionLevel(this, - new Events.Node.ChangeSectionLevelEventArgs(GetSelectedSection())); + new Events.Node.NodeEventArgs(this, GetSelectedSection())); } #endregion @@ -264,7 +254,7 @@ } else if (e.Label != Project.GetTextMedia((CoreNode)e.Node.Tag).getText()) { - RenameSection(this, new Events.Node.RenameSectionEventArgs((CoreNode)e.Node.Tag, e.Label)); + RenameSection(this, new Events.Node.RenameNodeEventArgs(this, (CoreNode)e.Node.Tag, e.Label)); } } } @@ -297,7 +287,7 @@ /// <param name="sender">The sender of this event notification</param> /// <param name="e"><see cref="e.Node"/> is the new heading to add to the tree</param> - internal void SyncAddedSectionNode(object sender, Events.Sync.AddedSectionNodeEventArgs e) + internal void SyncAddedSectionNode(object sender, Events.Node.AddedSectionNodeEventArgs e) { System.Windows.Forms.TreeNode newTreeNode; string label = Project.GetTextMedia(e.Node).getText(); @@ -327,7 +317,7 @@ /// </summary> /// <param name="sender">The sender of this event notification</param> /// <param name="e"><see cref="e.Node"/> is the tree node being renamed.</param> - internal void SyncRenamedNode(object sender, Events.Sync.RenamedNodeEventArgs e) + internal void SyncRenamedNode(object sender, Events.Node.RenameNodeEventArgs e) { if (e.Origin != this) { @@ -342,7 +332,7 @@ /// </summary> /// <param name="sender">The sender of this event notification</param> /// <param name="e"><see cref="e.Node"/> is the node to be removed.</param> - internal void SyncDeletedNode(object sender, Events.Sync.DeletedNodeEventArgs e) + internal void SyncDeletedNode(object sender, Events.Node.NodeEventArgs e) { if (e.Node != null) { @@ -356,7 +346,7 @@ /// </summary> /// <param name="sender"></param> /// <param name="e"></param> - internal void SyncShallowDeletedNode(object sender, Events.Sync.DeletedNodeEventArgs e) + internal void SyncShallowDeletedNode(object sender, Events.Node.NodeEventArgs e) { } @@ -365,7 +355,7 @@ /// </summary> /// <param name="sender"></param> /// <param name="e"></param> - internal void SyncMovedNodeUp(object sender, Events.Sync.MovedNodeEventArgs e) + internal void SyncMovedNodeUp(object sender, Events.Node.NodeEventArgs e) { System.Windows.Forms.TreeNode selected = FindTreeNodeFromCoreNode(e.Node); @@ -425,7 +415,12 @@ } - internal void SyncMovedNodeDown(object sender, Events.Sync.MovedNodeEventArgs e) + /// <summary> + /// Move a tree node down + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + internal void SyncMovedNodeDown(object sender, Events.Node.NodeEventArgs e) { System.Windows.Forms.TreeNode selected = FindTreeNodeFromCoreNode(e.Node); System.Windows.Forms.TreeNode clone = (System.Windows.Forms.TreeNode) @@ -481,6 +476,9 @@ } } + internal void SyncIncreaseNodeLevel(object sender, Events.Node.NodeEventArgs e) + { + } #endregion #region helper functions This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-07-31 11:53:57
|
Revision: 692 Author: julienq Date: 2006-07-31 04:53:38 -0700 (Mon, 31 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=692&view=rev Log Message: ----------- Added asset visitor to recreate the asset property of phrases when loading a file. Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/NodePositionVisitor.cs trunk/urakawa/application/Obi/Obi/Obi.csproj trunk/urakawa/application/Obi/Obi/Project.cs trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs Added Paths: ----------- trunk/urakawa/application/Obi/Obi/Visitors/AssetVisitor.cs Modified: trunk/urakawa/application/Obi/Obi/NodePositionVisitor.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/NodePositionVisitor.cs 2006-07-31 10:46:58 UTC (rev 691) +++ trunk/urakawa/application/Obi/Obi/NodePositionVisitor.cs 2006-07-31 11:53:38 UTC (rev 692) @@ -7,7 +7,7 @@ namespace Obi { /// <summary> - /// Find the position of a node in the core tree, as seen in a flat list. + /// Find the position of a node in the TOC tree, as seen in a flat list. /// </summary> public class NodePositionVisitor: ICoreNodeVisitor { Modified: trunk/urakawa/application/Obi/Obi/Obi.csproj =================================================================== --- trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-31 10:46:58 UTC (rev 691) +++ trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-31 11:53:38 UTC (rev 692) @@ -231,6 +231,7 @@ <DependentUpon>TOCPanel.cs</DependentUpon> </Compile> <Compile Include="UserProfile.cs" /> + <Compile Include="Visitors\AssetVisitor.cs" /> <Compile Include="Visitors\UndeleteSubtree.cs" /> </ItemGroup> <ItemGroup> Modified: trunk/urakawa/application/Obi/Obi/Project.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-31 10:46:58 UTC (rev 691) +++ trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-31 11:53:38 UTC (rev 692) @@ -211,6 +211,8 @@ AddMetadata("obi:assetsdir", mAssPath); } mAssManager = new AssetManager(mAssPath); + // Recreate the assets from the phrase nodes + getPresentation().getRootNode().acceptDepthFirst(new Visitors.AssetVisitor()); StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Opened)); } else Modified: trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.Designer.cs 2006-07-31 10:46:58 UTC (rev 691) +++ trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.Designer.cs 2006-07-31 11:53:38 UTC (rev 692) @@ -69,11 +69,11 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSize = true; - this.BackColor = System.Drawing.Color.LightPink; + this.BackColor = System.Drawing.Color.MistyRose; this.Controls.Add(this.mPlayLabel); this.Controls.Add(this.mTimeLabel); this.Controls.Add(this.mAnnotationLabel); - this.Margin = new System.Windows.Forms.Padding(0); + this.Margin = new System.Windows.Forms.Padding(0, 0, 1, 0); this.Name = "AudioBlock"; this.ResumeLayout(false); this.PerformLayout(); Modified: trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.Designer.cs 2006-07-31 10:46:58 UTC (rev 691) +++ trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.Designer.cs 2006-07-31 11:53:38 UTC (rev 692) @@ -52,7 +52,7 @@ this.mFlowLayoutPanel.BackColor = System.Drawing.SystemColors.ControlLight; this.mFlowLayoutPanel.Location = new System.Drawing.Point(2, 19); this.mFlowLayoutPanel.Name = "mFlowLayoutPanel"; - this.mFlowLayoutPanel.Size = new System.Drawing.Size(237, 58); + this.mFlowLayoutPanel.Size = new System.Drawing.Size(237, 10); this.mFlowLayoutPanel.TabIndex = 1; this.mFlowLayoutPanel.WrapContents = false; // @@ -81,7 +81,7 @@ this.Controls.Add(this.mLabel); this.Margin = new System.Windows.Forms.Padding(0, 0, 0, 3); this.Name = "SectionStrip"; - this.Size = new System.Drawing.Size(241, 80); + this.Size = new System.Drawing.Size(241, 32); this.Click += new System.EventHandler(this.SectionStrip_Click); this.ResumeLayout(false); this.PerformLayout(); Modified: trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-07-31 10:46:58 UTC (rev 691) +++ trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-07-31 11:53:38 UTC (rev 692) @@ -86,7 +86,7 @@ /// <returns>True.</returns> public bool preVisit(ICoreNode node) { - if (node.getParent() != null && Project.GetMediaForChannel((CoreNode)node, Project.TextChannel) != null) + if (Project.GetNodeType((CoreNode)node) == NodeType.SectionNode) { SectionStrip strip = new SectionStrip(); strip.Label = Project.GetTextMedia((CoreNode)node).getText(); @@ -94,7 +94,17 @@ strip.Node = (CoreNode)node; mNodeMap[(CoreNode)node] = strip; mFlowLayoutPanel.Controls.Add(strip); + SelectedNode = strip.Node; } + else if (Project.GetNodeType((CoreNode)node) == NodeType.PhraseNode) + { + SectionStrip strip = mNodeMap[mSelectedNode]; + AudioBlock block = new AudioBlock(); + TextMedia annotation = (TextMedia)Project.GetMediaForChannel((CoreNode)node, Project.AnnotationChannel); + block.Annotation = annotation.getText(); + block.Time = (Project.GetAudioMediaAsset((CoreNode)node).LengthInMilliseconds / 1000).ToString() + "s"; + strip.AppendAudioBlock(block); + } return true; } @@ -151,6 +161,7 @@ AudioBlock block = new AudioBlock(); TextMedia annotation = (TextMedia)Project.GetMediaForChannel(e.Node, Project.AnnotationChannel); block.Annotation = annotation.getText(); + block.Time = (Project.GetAudioMediaAsset(e.Node).LengthInMilliseconds / 1000).ToString() + "s"; strip.AppendAudioBlock(block); } } Added: trunk/urakawa/application/Obi/Obi/Visitors/AssetVisitor.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Visitors/AssetVisitor.cs (rev 0) +++ trunk/urakawa/application/Obi/Obi/Visitors/AssetVisitor.cs 2006-07-31 11:53:38 UTC (rev 692) @@ -0,0 +1,46 @@ +using System; +using System.Collections; +using System.Text; + +using urakawa.core; +using urakawa.media; +using VirtualAudioBackend; + +namespace Obi.Visitors +{ + class AssetVisitor: ICoreNodeVisitor + { + #region ICoreNodeVisitor Members + + public void postVisit(ICoreNode node) + { + } + + /// <summary> + /// Recreate an asset from a sequential media object on a the audio channel of a phrase node. + /// </summary> + public bool preVisit(ICoreNode node) + { + if (Project.GetNodeType((CoreNode)node) == NodeType.PhraseNode) + { + SequenceMedia media = (SequenceMedia)Project.GetMediaForChannel((CoreNode)node, Project.AudioChannel); + ArrayList clips = new ArrayList(media.getCount()); + for (int i = 0; i < media.getCount(); ++i) + { + AudioMedia audio = (AudioMedia)media.getItem(i); + clips.Add(new AudioClip(audio.getLocation().Location, audio.getClipBegin().getAsMilliseconds(), + audio.getClipEnd().getAsMilliseconds())); + } + AudioMediaAsset asset = new AudioMediaAsset(clips); + asset.Name = ((TextMedia)Project.GetMediaForChannel((CoreNode)node, Project.AnnotationChannel)).getText(); + AssetProperty assProp = + (AssetProperty)node.getPresentation().getPropertyFactory().createProperty("AssetProperty"); + assProp.Asset = asset; + node.setProperty(assProp); + } + return true; + } + + #endregion + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-08-01 00:40:40
|
Revision: 696 Author: marisademeglio Date: 2006-07-31 16:03:29 -0700 (Mon, 31 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=696&view=rev Log Message: ----------- Added command handlers and undo functionality for move up/move down Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Events/Node/AddedSectionNodeEventArgs.cs trunk/urakawa/application/Obi/Obi/Events/Node/NodeEventArgs.cs trunk/urakawa/application/Obi/Obi/Obi.csproj trunk/urakawa/application/Obi/Obi/Project.cs trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs Modified: trunk/urakawa/application/Obi/Obi/Events/Node/AddedSectionNodeEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/AddedSectionNodeEventArgs.cs 2006-07-31 17:12:46 UTC (rev 695) +++ trunk/urakawa/application/Obi/Obi/Events/Node/AddedSectionNodeEventArgs.cs 2006-07-31 23:03:29 UTC (rev 696) @@ -7,6 +7,7 @@ namespace Obi.Events.Node { public delegate void AddedSectionNodeHandler(object sender, AddedSectionNodeEventArgs e); + public delegate void UndidMoveNodeHandler(object sender, AddedSectionNodeEventArgs e); /// <summary> /// A section node was added. Modified: trunk/urakawa/application/Obi/Obi/Events/Node/NodeEventArgs.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Events/Node/NodeEventArgs.cs 2006-07-31 17:12:46 UTC (rev 695) +++ trunk/urakawa/application/Obi/Obi/Events/Node/NodeEventArgs.cs 2006-07-31 23:03:29 UTC (rev 696) @@ -13,6 +13,7 @@ public delegate void RequestToDeleteNodeHandler(object sender, NodeEventArgs e); public delegate void RequestToMoveNodeUpHandler(object sender, NodeEventArgs e); public delegate void RequestToMoveNodeDownHandler(object sender, NodeEventArgs e); + public delegate void RequestToUndoMoveNodeHandler(object sender, NodeEventArgs e); public delegate void IncreasedNodeLevelHandler(object sender, NodeEventArgs e); public delegate void DecreasedNodeLevelHandler(object sender, NodeEventArgs e); Modified: trunk/urakawa/application/Obi/Obi/Obi.csproj =================================================================== --- trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-31 17:12:46 UTC (rev 695) +++ trunk/urakawa/application/Obi/Obi/Obi.csproj 2006-07-31 23:03:29 UTC (rev 696) @@ -72,6 +72,8 @@ <Compile Include="Commands\CommandManager.cs" /> <Compile Include="Commands\TOC\AddSection.cs" /> <Compile Include="Commands\TOC\DeleteSection.cs" /> + <Compile Include="Commands\TOC\MoveSectionDown.cs" /> + <Compile Include="Commands\TOC\MoveSectionUp.cs" /> <Compile Include="Commands\TOC\Rename.cs" /> <Compile Include="DescendantsVisitor.cs" /> <Compile Include="Dialogs\EditSimpleMetadata.cs"> Modified: trunk/urakawa/application/Obi/Obi/Project.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-31 17:12:46 UTC (rev 695) +++ trunk/urakawa/application/Obi/Obi/Project.cs 2006-07-31 23:03:29 UTC (rev 696) @@ -49,8 +49,13 @@ public event Events.Node.MovedNodeDownHandler MovedNodeDown; // a node was moved down in the presentation public event Events.Node.IncreasedNodeLevelHandler IncreasedNodeLevel; //a node's level was increased in the presentation public event Events.Node.DecreasedNodeLevelHandler DecreasedNodeLevel; //a node's level was decreased in the presentation - public event Events.Node.ImportedAssetHandler ImportedAsset; // an asset was imported into the project + public event Events.Node.UndidMoveNodeHandler UndidMoveNode; //a node was restored to its previous location + + //marisa: TESTING + private Obi.Commands.TOC.MoveSectionUp mLastMoveSectionUpCommand; + //marisa: TESTING + private Obi.Commands.TOC.MoveSectionDown mLastMoveSectionDownCommand; /// <summary> /// This flag is set to true if the project contains modifications that have not been saved. @@ -489,16 +494,36 @@ /// </summary> public void MoveNodeUp(object origin, CoreNode node) { - //a facade API function could do this for us + Commands.TOC.MoveSectionUp command = null; + + //marisa: TESTING + mLastMoveSectionUpCommand = null; + + if (origin != this) + { + CoreNode parent = (CoreNode)node.getParent(); + NodePositionVisitor visitor = new NodePositionVisitor(node); + getPresentation().getRootNode().acceptDepthFirst(visitor); + //we need to save the state of the node before it is moved + command = new Commands.TOC.MoveSectionUp + (this, node, parent, parent.indexOf(node), visitor.Position); + } + bool succeeded = ExecuteMoveNodeUp(node); + if (succeeded) { + //marisa: TESTING + mLastMoveSectionUpCommand = command; + MovedNodeUp(this, new Events.Node.NodeEventArgs(origin, node)); mUnsaved = true; StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); + if (command != null) CommandCreated(this, new Events.Project.CommandCreatedEventArgs(command)); } } + //a facade API function could do this for us private bool ExecuteMoveNodeUp(CoreNode node) { CoreNode newParent = null; @@ -543,15 +568,65 @@ MoveNodeUp(sender, e.Node); } + /// <summary> + /// reposition the node at the index under its given parent + /// </summary> + /// <param name="node"></param> + /// <param name="parent"></param> + /// <param name="index"></param> + /// <param name="position"></param> + public void UndoMoveNode(CoreNode node, CoreNode parent, int index, int position) + { + if (node.getParent() != null) node.detach(); + parent.insert(node, index); + + UndidMoveNode(this, new Events.Node.AddedSectionNodeEventArgs(this, node, index, position)); + mUnsaved = true; + StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); +} + + //marisa: TESTING + public void TestUndoMoveNode(object sender, Events.Node.NodeEventArgs e) + { + if (mLastMoveSectionUpCommand != null) + { + mLastMoveSectionUpCommand.Undo(); + mLastMoveSectionUpCommand = null; + + } + else if (mLastMoveSectionDownCommand != null) + { + mLastMoveSectionDownCommand.Undo(); + } + } + public void MoveNodeDown(object origin, CoreNode node) { + Commands.TOC.MoveSectionDown command = null; + //marisa: TESTING + mLastMoveSectionDownCommand = null; + + if (origin != this) + { + CoreNode parent = (CoreNode)node.getParent(); + NodePositionVisitor visitor = new NodePositionVisitor(node); + getPresentation().getRootNode().acceptDepthFirst(visitor); + //we need to save the state of the node before it is moved + command = new Commands.TOC.MoveSectionDown + (this, node, parent, parent.indexOf(node), visitor.Position); + } + //a facade API function could do this for us bool succeeded = ExecuteMoveNodeDown(node); if (succeeded) { + //marisa: TESTING + mLastMoveSectionDownCommand = command; + MovedNodeDown(this, new Events.Node.NodeEventArgs(origin, node)); mUnsaved = true; StateChanged(this, new Events.Project.StateChangedEventArgs(Events.Project.StateChange.Modified)); + if (command != null) CommandCreated(this, new Events.Project.CommandCreatedEventArgs(command)); } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-31 17:12:46 UTC (rev 695) +++ trunk/urakawa/application/Obi/Obi/UserControls/ProjectPanel.cs 2006-07-31 23:03:29 UTC (rev 696) @@ -56,13 +56,13 @@ mTOCPanel.RequestToDeleteSection -= new Events.Node.RequestToDeleteNodeHandler(mProject.RemoveNodeRequested); mProject.DeletedNode -= new Events.Node.DeletedNodeHandler(mTOCPanel.SyncDeletedNode); - - //comment: this used to say += but I think it was a typo - //reply: yes it was. -= is the way to go. mProject.DeletedNode -= new Events.Node.DeletedNodeHandler(mStripManagerPanel.SyncDeletedNode); mStripManagerPanel.ImportPhrase -= new Events.Strip.RequestToImportAssetHandler(mProject.ImportPhraseRequested); mProject.ImportedAsset -= new Events.Node.ImportedAssetHandler(mStripManagerPanel.SyncImportedAsset); + + //marisa: TESTING only + mTOCPanel.RequestToUndoMoveNode -= new Events.Node.RequestToUndoMoveNodeHandler(mProject.TestUndoMoveNode); } // Set up the handlers for the new project if (value != null) @@ -98,6 +98,9 @@ mStripManagerPanel.ImportPhrase += new Events.Strip.RequestToImportAssetHandler(value.ImportPhraseRequested); value.ImportedAsset += new Events.Node.ImportedAssetHandler(mStripManagerPanel.SyncImportedAsset); + + //marisa: TESTING only + mTOCPanel.RequestToUndoMoveNode += new Events.Node.RequestToUndoMoveNodeHandler(value.TestUndoMoveNode); } mProject = value; mSplitContainer.Visible = mProject != null; Modified: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs 2006-07-31 17:12:46 UTC (rev 695) +++ trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.Designer.cs 2006-07-31 23:03:29 UTC (rev 696) @@ -33,15 +33,16 @@ this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.addSectionAtSameLevelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.addSubSectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.deleteSectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.testShallowDeleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.editLabelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.moveUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.moveDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.increaseLevelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.decreaseLevelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.editLabelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.deleteSectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.testShallowDeleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.testUndoMoveNodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.contextMenuStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -70,84 +71,92 @@ this.moveUpToolStripMenuItem, this.moveDownToolStripMenuItem, this.increaseLevelToolStripMenuItem, - this.decreaseLevelToolStripMenuItem}); + this.decreaseLevelToolStripMenuItem, + this.testUndoMoveNodeToolStripMenuItem}); this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(167, 236); + this.contextMenuStrip1.Size = new System.Drawing.Size(179, 258); this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); // // addSectionAtSameLevelToolStripMenuItem // this.addSectionAtSameLevelToolStripMenuItem.Name = "addSectionAtSameLevelToolStripMenuItem"; - this.addSectionAtSameLevelToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + this.addSectionAtSameLevelToolStripMenuItem.Size = new System.Drawing.Size(178, 22); this.addSectionAtSameLevelToolStripMenuItem.Text = "&Add section"; this.addSectionAtSameLevelToolStripMenuItem.Click += new System.EventHandler(this.addSectionAtSameLevelToolStripMenuItem_Click); // // addSubSectionToolStripMenuItem // this.addSubSectionToolStripMenuItem.Name = "addSubSectionToolStripMenuItem"; - this.addSubSectionToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + this.addSubSectionToolStripMenuItem.Size = new System.Drawing.Size(178, 22); this.addSubSectionToolStripMenuItem.Text = "Add &sub-section"; this.addSubSectionToolStripMenuItem.Click += new System.EventHandler(this.addSubSectionToolStripMenuItem_Click); // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(175, 6); + // + // deleteSectionToolStripMenuItem + // + this.deleteSectionToolStripMenuItem.Name = "deleteSectionToolStripMenuItem"; + this.deleteSectionToolStripMenuItem.Size = new System.Drawing.Size(178, 22); + this.deleteSectionToolStripMenuItem.Text = "&Delete section"; + this.deleteSectionToolStripMenuItem.Click += new System.EventHandler(this.deleteSectionToolStripMenuItem_Click); + // + // testShallowDeleteToolStripMenuItem + // + this.testShallowDeleteToolStripMenuItem.Name = "testShallowDeleteToolStripMenuItem"; + this.testShallowDeleteToolStripMenuItem.Size = new System.Drawing.Size(178, 22); + this.testShallowDeleteToolStripMenuItem.Text = "Test shallow delete"; + this.testShallowDeleteToolStripMenuItem.Click += new System.EventHandler(this.testShallowDeleteToolStripMenuItem_Click); + // + // editLabelToolStripMenuItem + // + this.editLabelToolStripMenuItem.Name = "editLabelToolStripMenuItem"; + this.editLabelToolStripMenuItem.Size = new System.Drawing.Size(178, 22); + this.editLabelToolStripMenuItem.Text = "Rena&me"; + this.editLabelToolStripMenuItem.Click += new System.EventHandler(this.editLabelToolStripMenuItem_Click); + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(175, 6); + // // moveUpToolStripMenuItem // this.moveUpToolStripMenuItem.Name = "moveUpToolStripMenuItem"; - this.moveUpToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + this.moveUpToolStripMenuItem.Size = new System.Drawing.Size(178, 22); this.moveUpToolStripMenuItem.Text = "Move up"; this.moveUpToolStripMenuItem.Click += new System.EventHandler(this.moveUpToolStripMenuItem_Click); // // moveDownToolStripMenuItem // this.moveDownToolStripMenuItem.Name = "moveDownToolStripMenuItem"; - this.moveDownToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + this.moveDownToolStripMenuItem.Size = new System.Drawing.Size(178, 22); this.moveDownToolStripMenuItem.Text = "Move down"; this.moveDownToolStripMenuItem.Click += new System.EventHandler(this.moveDownToolStripMenuItem_Click); // // increaseLevelToolStripMenuItem // this.increaseLevelToolStripMenuItem.Name = "increaseLevelToolStripMenuItem"; - this.increaseLevelToolStripMenuItem.Size = new System.Drawing.Size(196, 22); + this.increaseLevelToolStripMenuItem.Size = new System.Drawing.Size(178, 22); this.increaseLevelToolStripMenuItem.Text = "Increase level"; this.increaseLevelToolStripMenuItem.Click += new System.EventHandler(this.increaseLevelToolStripMenuItem_Click); // // decreaseLevelToolStripMenuItem // this.decreaseLevelToolStripMenuItem.Name = "decreaseLevelToolStripMenuItem"; - this.decreaseLevelToolStripMenuItem.Size = new System.Drawing.Size(206, 22); + this.decreaseLevelToolStripMenuItem.Size = new System.Drawing.Size(178, 22); this.decreaseLevelToolStripMenuItem.Text = "Decrease level"; this.decreaseLevelToolStripMenuItem.Click += new System.EventHandler(this.decreaseLevelToolStripMenuItem_Click); // - // editLabelToolStripMenuItem + // testUndoMoveNodeToolStripMenuItem // - this.editLabelToolStripMenuItem.Name = "editLabelToolStripMenuItem"; - this.editLabelToolStripMenuItem.Size = new System.Drawing.Size(196, 22); - this.editLabelToolStripMenuItem.Text = "Rena&me"; - this.editLabelToolStripMenuItem.Click += new System.EventHandler(this.editLabelToolStripMenuItem_Click); + this.testUndoMoveNodeToolStripMenuItem.Name = "testUndoMoveNodeToolStripMenuItem"; + this.testUndoMoveNodeToolStripMenuItem.Size = new System.Drawing.Size(178, 22); + this.testUndoMoveNodeToolStripMenuItem.Text = "Test undo move node"; + this.testUndoMoveNodeToolStripMenuItem.Click += new System.EventHandler(this.testUndoMoveNodeToolStripMenuItem_Click); // - // deleteSectionToolStripMenuItem - // - this.deleteSectionToolStripMenuItem.Name = "deleteSectionToolStripMenuItem"; - this.deleteSectionToolStripMenuItem.Size = new System.Drawing.Size(206, 22); - this.deleteSectionToolStripMenuItem.Text = "&Delete section"; - this.deleteSectionToolStripMenuItem.Click += new System.EventHandler(this.deleteSectionToolStripMenuItem_Click); - // - // testShallowDeleteToolStripMenuItem - // - this.testShallowDeleteToolStripMenuItem.Name = "testShallowDeleteToolStripMenuItem"; - this.testShallowDeleteToolStripMenuItem.Size = new System.Drawing.Size(206, 22); - this.testShallowDeleteToolStripMenuItem.Text = "Test shallow delete"; - this.testShallowDeleteToolStripMenuItem.Click += new System.EventHandler(this.testShallowDeleteToolStripMenuItem_Click); - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(193, 6); - // - // toolStripSeparator2 - // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(193, 6); - // // TOCPanel // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -175,5 +184,6 @@ private System.Windows.Forms.ToolStripMenuItem testShallowDeleteToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + private System.Windows.Forms.ToolStripMenuItem testUndoMoveNodeToolStripMenuItem; } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-31 17:12:46 UTC (rev 695) +++ trunk/urakawa/application/Obi/Obi/UserControls/TOCPanel.cs 2006-07-31 23:03:29 UTC (rev 696) @@ -26,6 +26,7 @@ public event Events.Node.RequestToMoveNodeUpHandler RequestToMoveSectionUp; public event Events.Node.RequestToRenameNodeHandler RequestToRenameSection; public event Events.Node.RequestToDeleteNodeHandler RequestToDeleteSection; + public event Events.Node.RequestToUndoMoveNodeHandler RequestToUndoMoveNode; /// <summary> /// Test whether a node is currently selected or not. @@ -705,6 +706,11 @@ } } + private void testUndoMoveNodeToolStripMenuItem_Click(object sender, EventArgs e) + { + RequestToUndoMoveNode(this, new Events.Node.NodeEventArgs(this, GetSelectedSection())); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-08-01 05:24:46
|
Revision: 704 Author: julienq Date: 2006-07-31 22:24:37 -0700 (Mon, 31 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=704&view=rev Log Message: ----------- Corrected the preference dialog initialization. Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Dialogs/Preferences.cs trunk/urakawa/application/Obi/Obi/ObiForm.cs Modified: trunk/urakawa/application/Obi/Obi/Dialogs/Preferences.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Dialogs/Preferences.cs 2006-08-01 05:14:30 UTC (rev 703) +++ trunk/urakawa/application/Obi/Obi/Dialogs/Preferences.cs 2006-08-01 05:24:37 UTC (rev 704) @@ -30,10 +30,28 @@ } } - private int mAudioChannels; // preferred number of audio channels - private int mSampleRate; // preferred sample rate - private int mBitDepth; // preferred bit depth + private string mOutputDevice; // preferred output device + private string mInputDevice; // preferred input device + private int mAudioChannels; // preferred number of audio channels + private int mSampleRate; // preferred sample rate + private int mBitDepth; // preferred bit depth + public string OutputDevice + { + get + { + return mOutputDevice; + } + } + + public string InputDevice + { + get + { + return mInputDevice; + } + } + public int AudioChannels { get @@ -58,19 +76,20 @@ } } - Settings settings = new Settings(); - ArrayList m_InDevicesList = new ArrayList(); ArrayList m_OutDevicesList = new ArrayList(); AudioRecorder ob_AudioRecorder = new AudioRecorder(); AudioPlayer ob_AudioPlayer = new AudioPlayer(); - public Preferences(string template, string dir) + /// <summary> + /// Initialize the preferences with the user settings. + /// </summary> + public Preferences(Settings settings) { InitializeComponent(); - mIdTemplate = template; + mIdTemplate = settings.IdTemplate; mTemplateBox.Text = mIdTemplate; - mDefaultDir = dir; + mDefaultDir = settings.DefaultPath; mDirectoryBox.Text = mDefaultDir; } @@ -87,10 +106,10 @@ private void button2_Click(object sender, EventArgs e) { - mIdTemplate = mTemplateBox.Text; + mIdTemplate = mTemplateBox.Text; mDefaultDir = mDirectoryBox.Text; - settings.LastInputDevice = comboInputDevice.SelectedItem.ToString(); - settings.LastOutputDevice = comboOutputDevice.SelectedItem.ToString(); + mInputDevice = comboInputDevice.SelectedItem.ToString(); + mOutputDevice = comboOutputDevice.SelectedItem.ToString(); } private void Preferences_Load(object sender, EventArgs e) Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-08-01 05:14:30 UTC (rev 703) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-08-01 05:24:37 UTC (rev 704) @@ -253,37 +253,37 @@ } /// <summary> - /// Edit the preferences, starting from the Project tab. + /// Edit the preferences, starting from the Project tab. (JQ) /// </summary> private void preferencesToolStripMenuItem_Click(object sender, EventArgs e) { - Dialogs.Preferences dialog = new Dialogs.Preferences(mSettings.IdTemplate, mSettings.DefaultPath); + Dialogs.Preferences dialog = new Dialogs.Preferences(mSettings); dialog.SelectProjectTab(); - if (dialog.ShowDialog() == DialogResult.OK) - { - if (dialog.IdTemplate.Contains("#")) mSettings.IdTemplate = dialog.IdTemplate; - if (Directory.Exists(dialog.DefaultDir)) mSettings.DefaultPath = dialog.DefaultDir; - } + if (dialog.ShowDialog() == DialogResult.OK) UpdateSettings(dialog); Ready(); } /// <summary> - /// Edit the preferences, starting from the Audio tab. + /// Edit the preferences, starting from the Audio tab. (JQ) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void audioPreferencesToolStripMenuItem_Click(object sender, EventArgs e) { - Dialogs.Preferences dialog = new Dialogs.Preferences(mSettings.IdTemplate, mSettings.DefaultPath); + Dialogs.Preferences dialog = new Dialogs.Preferences(mSettings); dialog.SelectAudioTab(); - if (dialog.ShowDialog() == DialogResult.OK) - { - if (dialog.IdTemplate.Contains("#")) mSettings.IdTemplate = dialog.IdTemplate; - if (Directory.Exists(dialog.DefaultDir)) mSettings.DefaultPath = dialog.DefaultDir; - } + if (dialog.ShowDialog() == DialogResult.OK) UpdateSettings(dialog); Ready(); } + /// <summary> + /// Update the settings after the user has made some changes in the preferrences dialog. (JQ) + /// </summary> + private void UpdateSettings(Dialogs.Preferences dialog) + { + if (dialog.IdTemplate.Contains("#")) mSettings.IdTemplate = dialog.IdTemplate; + if (Directory.Exists(dialog.DefaultDir)) mSettings.DefaultPath = dialog.DefaultDir; + } /// <summary> /// Save the settings when closing. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-08-01 05:59:43
|
Revision: 706 Author: julienq Date: 2006-07-31 22:59:22 -0700 (Mon, 31 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=706&view=rev Log Message: ----------- Play selected asset. Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Dialogs/Play.cs trunk/urakawa/application/Obi/Obi/ObiForm.cs trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.cs trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.cs trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs Modified: trunk/urakawa/application/Obi/Obi/Dialogs/Play.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Dialogs/Play.cs 2006-08-01 05:29:33 UTC (rev 705) +++ trunk/urakawa/application/Obi/Obi/Dialogs/Play.cs 2006-08-01 05:59:22 UTC (rev 706) @@ -7,13 +7,19 @@ using System.Windows.Forms; using VirtualAudioBackend; +using urakawa.core; +using urakawa.media; + namespace Obi.Dialogs { public partial class Play : Form { - public Play() + private CoreNode mNode; // the node whose asset we want to play + + public Play(CoreNode node) { InitializeComponent(); + mNode = node; } private void btnStop_Click(object sender, EventArgs e) @@ -22,8 +28,6 @@ this.Close(); } - AudioClip Clip; - AudioMediaAsset ob_AudioMedia; AudioPlayer ob_play =new AudioPlayer(); private void btnPlay_Click(object sender, EventArgs e) @@ -33,10 +37,6 @@ // if (i == 1) { - Clip = new AudioClip("c:\\atest\\a\\a1.wav"); - ArrayList al = new ArrayList(); - al.Add(Clip); - ob_AudioMedia = new AudioMediaAsset(al); VuMeter ob_VuMeter = new VuMeter(); @@ -49,7 +49,7 @@ ob_play.GetOutputDevices(); ob_play.SetDevice(this , 0); - ob_play.Play(ob_AudioMedia); + ob_play.Play(Project.GetAudioMediaAsset(mNode)); btnPlay.Text = "&Pause"; tmUpdateCurrentTime.Enabled = true; } @@ -75,8 +75,8 @@ private void Play_Load(object sender, EventArgs e) { - MessageBox.Show("Openning Play Diaglog"); - //txtDisplayAsset.Text = + MessageBox.Show("Openning Play Diaglog"); + txtDisplayAsset.Text = ((TextMedia)Project.GetMediaForChannel(mNode, Project.AnnotationChannel)).getText(); } Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-08-01 05:29:33 UTC (rev 705) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-08-01 05:59:22 UTC (rev 706) @@ -678,13 +678,5 @@ FormUpdateUndoRedoLabels(); } } - - private void btnPlay_Click(object sender, EventArgs e) - { - Play ob_PlayDialog = new Play(); - ob_PlayDialog.Show(); - } - - } } \ No newline at end of file Modified: trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.Designer.cs 2006-08-01 05:29:33 UTC (rev 705) +++ trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.Designer.cs 2006-08-01 05:59:22 UTC (rev 706) @@ -30,7 +30,6 @@ { this.mAnnotationLabel = new System.Windows.Forms.Label(); this.mTimeLabel = new System.Windows.Forms.Label(); - this.mPlayLabel = new System.Windows.Forms.LinkLabel(); this.SuspendLayout(); // // mAnnotationLabel @@ -53,28 +52,17 @@ this.mTimeLabel.TabIndex = 1; this.mTimeLabel.Text = "(time)"; // - // mPlayLabel - // - this.mPlayLabel.AutoSize = true; - this.mPlayLabel.Location = new System.Drawing.Point(3, 39); - this.mPlayLabel.Margin = new System.Windows.Forms.Padding(3); - this.mPlayLabel.Name = "mPlayLabel"; - this.mPlayLabel.Size = new System.Drawing.Size(27, 12); - this.mPlayLabel.TabIndex = 2; - this.mPlayLabel.TabStop = true; - this.mPlayLabel.Text = "Play"; - // // AudioBlock // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSize = true; this.BackColor = System.Drawing.Color.MistyRose; - this.Controls.Add(this.mPlayLabel); this.Controls.Add(this.mTimeLabel); this.Controls.Add(this.mAnnotationLabel); this.Margin = new System.Windows.Forms.Padding(0, 0, 1, 0); this.Name = "AudioBlock"; + this.Click += new System.EventHandler(this.AudioBlock_Click); this.ResumeLayout(false); this.PerformLayout(); @@ -84,6 +72,5 @@ private System.Windows.Forms.Label mAnnotationLabel; private System.Windows.Forms.Label mTimeLabel; - private System.Windows.Forms.LinkLabel mPlayLabel; } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.cs 2006-08-01 05:29:33 UTC (rev 705) +++ trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.cs 2006-08-01 05:59:22 UTC (rev 706) @@ -13,6 +13,29 @@ { public partial class AudioBlock : UserControl { + private StripManagerPanel mManager; // the manager for this block + private CoreNode mNode; // the phrase node for this block + + public StripManagerPanel Manager + { + set + { + mManager = value; + } + } + + public CoreNode Node + { + get + { + return mNode; + } + set + { + mNode = value; + } + } + public string Annotation { set @@ -33,5 +56,20 @@ { InitializeComponent(); } + + internal void MarkDeselected() + { + BackColor = Color.MistyRose; + } + + internal void MarkSelected() + { + BackColor = Color.LightPink; + } + + private void AudioBlock_Click(object sender, EventArgs e) + { + mManager.SelectedPhrase = mNode; + } } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.cs 2006-08-01 05:29:33 UTC (rev 705) +++ trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.cs 2006-08-01 05:59:22 UTC (rev 706) @@ -54,13 +54,13 @@ private void SectionStrip_Click(object sender, EventArgs e) { - if (mManager.SelectedNode == mNode) + if (mManager.SelectedSection == mNode) { StartRenaming(); } else { - mManager.SelectedNode = mNode; + mManager.SelectedSection = mNode; } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs 2006-08-01 05:29:33 UTC (rev 705) +++ trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs 2006-08-01 05:59:22 UTC (rev 706) @@ -34,8 +34,9 @@ this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.addStripToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.renameStripToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.importAssetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.playAssetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.contextMenuStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -70,10 +71,11 @@ this.addStripToolStripMenuItem, this.renameStripToolStripMenuItem, this.toolStripSeparator1, - this.importAssetToolStripMenuItem}); + this.importAssetToolStripMenuItem, + this.playAssetToolStripMenuItem}); this.contextMenuStrip1.Name = "contextMenuStrip1"; this.contextMenuStrip1.ShowImageMargin = false; - this.contextMenuStrip1.Size = new System.Drawing.Size(128, 98); + this.contextMenuStrip1.Size = new System.Drawing.Size(128, 120); // // addStripToolStripMenuItem // @@ -89,6 +91,11 @@ this.renameStripToolStripMenuItem.Text = "&Rename strip"; this.renameStripToolStripMenuItem.Click += new System.EventHandler(this.renameStripToolStripMenuItem_Click); // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(124, 6); + // // importAssetToolStripMenuItem // this.importAssetToolStripMenuItem.Name = "importAssetToolStripMenuItem"; @@ -96,10 +103,12 @@ this.importAssetToolStripMenuItem.Text = "&Import asset"; this.importAssetToolStripMenuItem.Click += new System.EventHandler(this.importAssetToolStripMenuItem_Click); // - // toolStripSeparator1 + // playAssetToolStripMenuItem // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(124, 6); + this.playAssetToolStripMenuItem.Name = "playAssetToolStripMenuItem"; + this.playAssetToolStripMenuItem.Size = new System.Drawing.Size(127, 22); + this.playAssetToolStripMenuItem.Text = "&Play asset"; + this.playAssetToolStripMenuItem.Click += new System.EventHandler(this.playAssetToolStripMenuItem_Click); // // StripManagerPanel // @@ -124,5 +133,6 @@ private System.Windows.Forms.ToolStripMenuItem renameStripToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripMenuItem importAssetToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem playAssetToolStripMenuItem; } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-08-01 05:29:33 UTC (rev 705) +++ trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-08-01 05:59:22 UTC (rev 706) @@ -16,27 +16,30 @@ /// </summary> public partial class StripManagerPanel : UserControl, ICoreNodeVisitor { - private Dictionary<CoreNode, SectionStrip> mNodeMap; // find a strip for a given node - private CoreNode mSelectedNode; // the selected node + private Dictionary<CoreNode, SectionStrip> mSectionNodeMap; // find a section strip for a given node + private CoreNode mSelectedSection; // the selected node + private Dictionary<CoreNode, AudioBlock> mPhraseNodeMap; // find an audio block for a given phrase node + private CoreNode mSelectedPhrase; // the selected audio block + public event Events.Node.RequestToAddSiblingNodeHandler AddSiblingSection; public event Events.Node.RequestToRenameNodeHandler RenameSection; public event Events.Strip.RequestToImportAssetHandler ImportPhrase; public event Events.Strip.SelectedHandler SelectedStrip; - public CoreNode SelectedNode + public CoreNode SelectedSection { get { - return mSelectedNode; + return mSelectedSection; } set { - if (mSelectedNode != null) mNodeMap[mSelectedNode].MarkDeselected(); - mSelectedNode = value; - if (mSelectedNode != null) + if (mSelectedSection != null) mSectionNodeMap[mSelectedSection].MarkDeselected(); + mSelectedSection = value; + if (mSelectedSection != null) { - mNodeMap[mSelectedNode].MarkSelected(); + mSectionNodeMap[mSelectedSection].MarkSelected(); renameStripToolStripMenuItem.Enabled = true; SelectedStrip(this, new Events.Strip.SelectedEventArgs(true)); } @@ -48,11 +51,30 @@ } } + public CoreNode SelectedPhrase + { + get + { + return mSelectedPhrase; + } + set + { + if (mSelectedPhrase != null) mPhraseNodeMap[mSelectedPhrase].MarkDeselected(); + mSelectedPhrase = value; + if (mSelectedPhrase != null) + { + mPhraseNodeMap[mSelectedPhrase].MarkSelected(); + } + } + } + public StripManagerPanel() { InitializeComponent(); - mNodeMap = new Dictionary<CoreNode, SectionStrip>(); - mSelectedNode = null; + mSectionNodeMap = new Dictionary<CoreNode, SectionStrip>(); + mSelectedSection = null; + mPhraseNodeMap = new Dictionary<CoreNode, AudioBlock>(); + mSelectedPhrase = null; } /// <summary> @@ -62,10 +84,10 @@ /// </summary> public void SynchronizeWithCoreTree(CoreNode root) { - mNodeMap.Clear(); + mSectionNodeMap.Clear(); mFlowLayoutPanel.Controls.Clear(); root.acceptDepthFirst(this); - SelectedNode = null; + SelectedSection = null; } #region Synchronization visitor @@ -92,14 +114,17 @@ strip.Label = Project.GetTextMedia((CoreNode)node).getText(); strip.Manager = this; strip.Node = (CoreNode)node; - mNodeMap[(CoreNode)node] = strip; + mSectionNodeMap[(CoreNode)node] = strip; mFlowLayoutPanel.Controls.Add(strip); - SelectedNode = strip.Node; + SelectedSection = strip.Node; } else if (Project.GetNodeType((CoreNode)node) == NodeType.PhraseNode) { - SectionStrip strip = mNodeMap[mSelectedNode]; + SectionStrip strip = mSectionNodeMap[mSelectedSection]; AudioBlock block = new AudioBlock(); + block.Manager = this; + block.Node = (CoreNode)node; + mPhraseNodeMap[(CoreNode)node] = block; TextMedia annotation = (TextMedia)Project.GetMediaForChannel((CoreNode)node, Project.AnnotationChannel); block.Annotation = annotation.getText(); block.Time = (Project.GetAudioMediaAsset((CoreNode)node).LengthInMilliseconds / 1000).ToString() + "s"; @@ -123,16 +148,16 @@ strip.Label = Project.GetTextMedia(node).getText(); strip.Manager = this; strip.Node = node; - mNodeMap[node] = strip; + mSectionNodeMap[node] = strip; mFlowLayoutPanel.Controls.Add(strip); mFlowLayoutPanel.Controls.SetChildIndex(strip, position); - SelectedNode = node; + SelectedSection = node; if (rename) strip.StartRenaming(); } internal void SyncRenamedNode(object sender, Events.Node.RenameNodeEventArgs e) { - SectionStrip strip = mNodeMap[e.Node]; + SectionStrip strip = mSectionNodeMap[e.Node]; strip.Label = e.Label; } @@ -147,7 +172,7 @@ e.Node.acceptDepthFirst(visitor); foreach (CoreNode node in visitor.Nodes) { - SectionStrip strip = mNodeMap[node]; + SectionStrip strip = mSectionNodeMap[node]; mFlowLayoutPanel.Controls.Remove(strip); } } @@ -155,10 +180,13 @@ internal void SyncImportedAsset(object sender, Events.Node.NodeEventArgs e) { - if (e.Node != null && mSelectedNode != null) + if (e.Node != null && mSelectedSection != null) { - SectionStrip strip = mNodeMap[mSelectedNode]; + SectionStrip strip = mSectionNodeMap[mSelectedSection]; AudioBlock block = new AudioBlock(); + block.Manager = this; + block.Node = e.Node; + mPhraseNodeMap[e.Node] = block; TextMedia annotation = (TextMedia)Project.GetMediaForChannel(e.Node, Project.AnnotationChannel); block.Annotation = annotation.getText(); block.Time = (Project.GetAudioMediaAsset(e.Node).LengthInMilliseconds / 1000).ToString() + "s"; @@ -168,7 +196,7 @@ internal void SyncMovedNode(object sender, Events.Node.MovedNodeEventArgs e) { - SectionStrip strip = mNodeMap[e.Node]; + SectionStrip strip = mSectionNodeMap[e.Node]; mFlowLayoutPanel.Controls.SetChildIndex(strip, e.Position); } @@ -178,30 +206,44 @@ internal void addStripToolStripMenuItem_Click(object sender, EventArgs e) { - AddSiblingSection(this, new Events.Node.NodeEventArgs(this, mSelectedNode)); + AddSiblingSection(this, new Events.Node.NodeEventArgs(this, mSelectedSection)); } internal void renameStripToolStripMenuItem_Click(object sender, EventArgs e) { - if (mSelectedNode != null) + if (mSelectedSection != null) { - mNodeMap[mSelectedNode].StartRenaming(); + mSectionNodeMap[mSelectedSection].StartRenaming(); } } internal void importAssetToolStripMenuItem_Click(object sender, EventArgs e) { - if (SelectedNode != null) + if (SelectedSection != null) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "WAVE file (*.wav)|*.wav|Any file|*.*"; if (dialog.ShowDialog() == DialogResult.OK) { - ImportPhrase(this, new Events.Strip.ImportAssetEventArgs(mSelectedNode, dialog.FileName)); + ImportPhrase(this, new Events.Strip.ImportAssetEventArgs(mSelectedSection, dialog.FileName)); } } } + /// <summary> + /// Play the currently selected audio block. (JQ) + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void playAssetToolStripMenuItem_Click(object sender, EventArgs e) + { + if (mSelectedPhrase != null) + { + Dialogs.Play dialog = new Dialogs.Play(mSelectedPhrase); + dialog.ShowDialog(); + } + } + #endregion /// <summary> @@ -216,12 +258,12 @@ private void mFlowLayoutPanel_Click(object sender, EventArgs e) { - SelectedNode = null; + SelectedSection = null; } private void mFlowLayoutPanel_Leave(object sender, EventArgs e) { - SelectedNode = null; + SelectedSection = null; } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |