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