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. |