using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; using VEPROMS.CSLA.Library; //using Csla; using DevComponents; using DevComponents.DotNetBar; using DevComponents.DotNetBar.Rendering; using VEPROMS.Properties; using Volian.Controls.Library; using DescriptiveEnum; [assembly: log4net.Config.XmlConfigurator(Watch = true)] namespace VEPROMS { enum PropPgStyle { Button = 1, Tab = 2, Grid = 3 }; public partial class frmVEPROMS : DevComponents.DotNetBar.Office2007RibbonForm { #region Log4Net private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); #endregion #region PropertiesVariables private bool _panelExpandedChanging = false; Color _CommentTitleBckColor; DocVersionInfo _SelectedDVI = null; StepTabPanel _SelectedStepTabPanel=null; public StepTabPanel SelectedStepTabPanel { get { return _SelectedStepTabPanel; } set { _SelectedStepTabPanel = value; if (value == null) // DSO Tab Panel { if (tc.SelectedDisplayTabItem != null && tc.SelectedDisplayTabItem.MyItemInfo != null) // 2nd part is for unassociated libdocs SelectedDVI = tc.SelectedDisplayTabItem.MyItemInfo.MyActiveParent.ActiveParent as DocVersionInfo; else SelectedDVI = null; } else // Step Tab Panel SelectedDVI = value.MyStepPanel.MyProcedureItemInfo.MyProcedure.MyActiveParent as DocVersionInfo; } } public DocVersionInfo SelectedDVI { get { return _SelectedDVI; } set { if (_SelectedDVI != value) { _SelectedDVI = value; _SelectedROFst = null; } InitiateSearch(false); } } // TODO: Should the following be an info // For the initial release, we are assuming there will be only one rofst fro a docversion. Changes // will be needed here if more than 1. private ROFstInfo _SelectedROFst; public ROFstInfo SelectedROFst { get { if(_SelectedROFst == null && SelectedDVI != null) _SelectedROFst = SelectedDVI.DocVersionAssociations[0].MyROFst; return _SelectedROFst; } set { _SelectedROFst = value; } } #endregion public frmVEPROMS() { #if (DEBUG) //use local data (for development/debug mode) if (Environment.MachineName == "RMARK-PC") VEPROMS.CSLA.Library.Database.ConnectionName = "VEPROMS_RMARK_DEBUG"; else VEPROMS.CSLA.Library.Database.ConnectionName = "VEPROMS_LOCAL"; #else // use server data (default) // - except for the volian laptop and Rich's Demo version where we need to use local data if (Environment.MachineName == "RMARK-PC") VEPROMS.CSLA.Library.Database.ConnectionName = "VEPROMS_RMARK_DEMO"; else if (Environment.MachineName == "DELL-D430") VEPROMS.CSLA.Library.Database.ConnectionName = "VEPROMS_LOCAL"; else VEPROMS.CSLA.Library.Database.ConnectionName = "VEPROMS"; #endif InitializeComponent(); // set the color of the ribbon RibbonPredefinedColorSchemes.ChangeOffice2007ColorTable((eOffice2007ColorScheme)Settings.Default.SystemColor); // LATER: get the user setting to control what is displayed for each tree node // The logic is in the ToString() functions in FolderExt.cs and DocVersionExt.cs //the GetFolder(1) function will read in the frist node (using ToString() to assign node text) // Get the saved Tree Node Diplay settings //if (Settings.Default["UseNameOnTreeNode"]) //{ //} //if (Settings.Default["UseTitleOnTreeNode"]) //{ //} VETreeNode tn = VETreeNode.GetFolder(1); tv.Nodes.Add(tn); tv.NodeOpenProperty += new vlnTreeViewPropertyEvent(tv_NodeOpenProperty); tv.NodeSelect += new Volian.Controls.Library.vlnTreeViewEvent(tv_NodeSelect); _CommentTitleBckColor = epAnnotations.TitleStyle.BackColor1.Color; if (!btnAnnoDetailsPushPin.Checked) epAnnotations.Expanded = false; infoPanel.Expanded = false; toolsPanel.Expanded = false; ribbonControl1.ExpandedChanged +=new EventHandler(ribbonControl1_ExpandedChanged); } private void frmVEPROMS_FormClosing(object sender, FormClosingEventArgs e) { // Save the location and size of the VE-PROMS appication for this user if (this.WindowState == FormWindowState.Normal) { Settings.Default.Location = this.Location; Settings.Default.Size = this.Size; } Settings.Default.WindowState = this.WindowState; SaveMRU(); //Settings.Default.Save(); } private void frmVEPROMS_Load(object sender, EventArgs e) { // get the saved location and size of the VE-PROMS appication for this user if (Settings.Default["Location"] != null) this.Location = Settings.Default.Location; if (Settings.Default["Size"] != null) this.Size = Settings.Default.Size; if (Settings.Default["WindowState"] != null) this.WindowState = Settings.Default.WindowState; _MyMRIList = MostRecentItemList.GetMRILst((System.Collections.Specialized.StringCollection)(Properties.Settings.Default["MRIList"])); SetupMRU(); displaySearch1.SetupAnnotationSearch(ctrlAnnotationDetails, tc); ctrlAnnotationDetails.SetupAnnotations(displaySearch1); SetupButtons(); displayBookMarks.MyDisplayTabControl = tc; // allows bookmark selection to bring up steps/docs } private void SetupButtons() { #if (DEBUG) #else //labelItem1.Visible = btnItemInfo.Visible = false; btnItemInfo.Visible = false; #endif } #region MRU private MostRecentItemList _MyMRIList; private void SetupMRU() { icRecentDocs.SubItems.Clear(); if (_MyMRIList.Count > 0) { LabelItem lblItem = new LabelItem(); lblItem.Text = "Recent Documents:"; icRecentDocs.SubItems.Add(lblItem); //icRecentDocs.SubItems.Add(); for (int i = 0; i < _MyMRIList.Count; i++) { MostRecentItem mri = _MyMRIList[i]; ButtonItem btnItem = new ButtonItem(); string menuTitle = mri.MenuTitle.Replace("\u2011", "-"); if (i < 9) btnItem.Text = string.Format("&{0}. {1}", i + 1, menuTitle); else btnItem.Text = string.Format(" {1}", i + 1, menuTitle); btnItem.Tag = mri.ItemID; btnItem.Tooltip = mri.ToolTip; btnItem.Click += new EventHandler(btnItem_Click); icRecentDocs.SubItems.Add(btnItem); } } } void btnItem_Click(object sender, EventArgs e) { ButtonItem btnItem = (ButtonItem)sender; MostRecentItem mri = _MyMRIList.Add((int)(btnItem.Tag)); //SaveMRU(); SetupMRU(); if (mri != null) tc.OpenItem(mri.MyItemInfo); #if (DEBUG) // display a property page contianing the Tab Cotrol information //f = new frmPropGrid(tc); //f.Show(); #endif } private void SaveMRU() { Properties.Settings.Default.MRIList = _MyMRIList.ToSettings(); Properties.Settings.Default.Save(); } #endregion #region Tree View /// /// Get the selected tree node's properties /// /// VETreeNode void SetupNodes(VETreeNode node) { if (_MyMRIList.Add(node.VEObject) != null) SetupMRU(); #region Sample Display Table Code // display an exiting table in that rtf grid thing //if ((_LastStepInfo.MyContent.Type == 20007) || (_LastStepInfo.MyContent.Type == 20009)) //{ // //MessageBox.Show("Source Grid"); // //frmTable newtable1 = new frmTable(_LastStepInfo.MyContent.Text); // //newtable1.ShowDialog(); // //MessageBox.Show("IGrid"); // //frmIGrid newtable2 = new frmIGrid(_LastStepInfo.MyContent.Text); // //newtable2.ShowDialog(); // //MessageBox.Show("GridView"); //standard Visual Studio Control // //frmGridView newtable3 = new frmGridView(_LastStepInfo.MyContent.Text); // //newtable3.ShowDialog(); // MessageBox.Show("FlexCell"); // frmFlexCell newtable4 = new frmFlexCell(_LastStepInfo.MyContent.Text); // newtable4.ShowDialog(); //} #endregion ItemInfo ii = node.VEObject as ItemInfo; if (ii != null) tc.OpenItem(ii); SetCaption(node); } // The following code is used to setup the user interface depending on what // is selected on the tree view (see vlnTreeView.cs) private void tv_NodeSelect(object sender, Volian.Controls.Library.vlnTreeEventArgs args) { SetupNodes((VETreeNode)args.Node); } private void SetCaption(VETreeNode tn) { StringBuilder caption = new StringBuilder(); string sep = string.Empty; while (tn != null) { if (tn.VEObject.GetType() == typeof(FolderInfo) || tn.VEObject.GetType() == typeof(DocVersionInfo)) { caption.Append(sep + tn.Text); sep = " - "; } tn = (VETreeNode)tn.Parent; } this.Text = caption.ToString(); } /// /// When the treeview is clicked - a timer is set /// This is done because the focus is returned to the treeview after the click event /// This approach did not work and was replaced with the code below. /// The problem was that each time the treeview was clicked, the last selected node /// was opened again, or the edit window was repositioned. /// If the item was deleted and another treenode expanded, the click to expand the /// node would cause the deleted node to be selected. /// /// /// //private void tv_Click(object sender, EventArgs e) //{ //tv.Enabled = false; //tmrTreeView.Enabled = true; //} /// /// This opens nodes if the mouse is within the bounds of a node. /// By using the timer, the focus can be passed to the edit window. /// /// /// void tv_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button != MouseButtons.Right) { Point newPoint = new Point(e.X, e.Y); VETreeNode tn = tv.GetNodeAt(newPoint) as VETreeNode; // Check to make sure that a node has been selected and // that the mouse is within the bounds of the node. if (tn != null && tn.Bounds.Left < newPoint.X) { tv.SelectedNode = tn; tv.Enabled = false; tmrTreeView.Enabled = true; } } } /// /// This event is fired from the timer after the treeview click event completes /// /// /// private void tmrTreeView_Tick(object sender, EventArgs e) { tmrTreeView.Enabled = false; // Timer has now fired VETreeNode tn = tv.SelectedNode as VETreeNode; if (tn != null) SetupNodes(tn); tv.Enabled = true; } private void tv_BeforeExpand(object sender, TreeViewCancelEventArgs e) { VETreeNode tn = ((VETreeNode)e.Node); tn.LoadingChildernDone += new VETreeNodeEvent(tn_LoadingChildernDone); tn.LoadingChildernMax += new VETreeNodeEvent(tn_LoadingChildernMax); tn.LoadingChildernValue += new VETreeNodeEvent(tn_LoadingChildernValue); tn.LoadingChildrenSQL += new VETreeNodeEvent(tn_LoadingChildrenSQL); tn.LoadChildren(true); } #region Property Page and Grid DialogResult tv_NodeOpenProperty(object sender, vlnTreePropertyEventArgs args) { this.Cursor = Cursors.WaitCursor; DialogResult dr = DialogResult.Cancel; if ((int)Settings.Default["PropPageStyle"] == (int)PropPgStyle.Grid) { frmPropGrid propGrid = new frmPropGrid(args.ConfigObject, args.Title); dr = propGrid.ShowDialog(); } else { if (args.FolderConfig != null) { frmFolderProperties frmfld = new frmFolderProperties(args.FolderConfig); dr = frmfld.ShowDialog(); } else if (args.DocVersionConfig != null) { frmVersionsProperties frmver = new frmVersionsProperties(args.DocVersionConfig); dr = frmver.ShowDialog(); } else if (args.ProcedureConfig != null) { frmProcedureProperties frmproc = new frmProcedureProperties(args.ProcedureConfig); dr = frmproc.ShowDialog(); } else if (args.SectionConfig != null) { //// If this is a word document, close any edit sessions... //ItemInfo ii = null; //using (Section tmp = args.SectionConfig.MySection) //{ // ii = ItemInfo.Get(tmp.ItemID); // if (!ii.IsStepSection) tc.CloseWordItem(ii); //} frmSectionProperties frmsec = new frmSectionProperties(args.SectionConfig); dr = frmsec.ShowDialog(); if (dr == DialogResult.OK && displayLibDocs.LibDocList != null) { displayLibDocs.LibDocListFillIn(tc); } } } this.Cursor = Cursors.Default; return dr; } #endregion #endregion #region ColorStuff /// /// Get a System.Drawing.Color from an Argb or color name /// /// Color Name or "[(alpha,)red,green,blue]" /// private static Color cGetColor(string strColor) { // This was copied from frmFolderProperties.CS Color rtnColor; if (strColor == null || strColor.Equals("")) rtnColor = Color.White; else { if (strColor[0] == '[') { string[] parts = strColor.Substring(1, strColor.Length - 2).Split(",".ToCharArray()); int parts_cnt = 0; foreach (string s in parts) { parts[parts_cnt] = parts[parts_cnt].TrimStart(' '); // remove preceeding blanks parts_cnt++; } if (parts_cnt == 3) rtnColor = Color.FromArgb(Int32.Parse(parts[0]), Int32.Parse(parts[1]), Int32.Parse(parts[2])); else rtnColor = Color.FromArgb(Int32.Parse(parts[0].Substring(2)), Int32.Parse(parts[1].Substring(2)), Int32.Parse(parts[2].Substring(2)), Int32.Parse(parts[3].Substring(2))); } else rtnColor = Color.FromName(strColor); } return rtnColor; } //private void SetupEditorColors(DisplayPanel vlnCSLAPanel1, TabPage pg) //{ // // setup color // if (_LastFolderInfo == null) // { // // user didn't select a FolderInfo type of node. // // walk up the tree to find the first FolderInfo node type // VETreeNode tn = (VETreeNode)(tv.SelectedNode); // while (tn != null && tn.VEObject.GetType() != typeof(FolderInfo)) // tn = (VETreeNode)tn.Parent; // _LastFolderInfo = (FolderInfo)(tn.VEObject); // _LastFolder = _LastFolderInfo.Get(); // } // if ((_LastFolderInfo.FolderConfig.Color_editbackground != null) && !(_LastFolderInfo.FolderConfig.Color_editbackground.Equals(""))) // { // vlnCSLAPanel1.ActiveColor = cGetColor(_LastFolderInfo.FolderConfig.Color_editbackground); // } // if ((_LastFolderInfo.FolderConfig.Default_BkColor != null) && !(_LastFolderInfo.FolderConfig.Default_BkColor.Equals(""))) // { // vlnCSLAPanel1.InactiveColor = _LastFolderInfo.FolderConfig.Default_BkColor; // vlnCSLAPanel1.TabColor = vlnCSLAPanel1.InactiveColor; // vlnCSLAPanel1.PanelColor = vlnCSLAPanel1.InactiveColor; // pg.BackColor = vlnCSLAPanel1.InactiveColor; // } //} #endregion #region Table Insert Sample Code // TODO: for tables //private void btnInsTable_Click(object sender, EventArgs e) //{ // Point loc = btnInsTable.DisplayRectangle.Location; // loc.X += 300; // int top = this.Top + (btnInsTable.Size.Height * 2); // TablePickerDlg(sender, e, loc, top); //} //private void TablePickerDlg(object sender, EventArgs e, Point loc, int top) //{ // Accentra.Controls.TablePicker tp = new Accentra.Controls.TablePicker(); // tp.Location = loc; // tp.Top += top; // tp.Show(); // while (tp.Visible) // { // Application.DoEvents(); // System.Threading.Thread.Sleep(0); // } // // This was used to display a dialog containing a table grid // // using a product called Source Grid - was for demo purposes only // // // //if (!tp.Cancel) // //{ // // frmTable newtable = new frmTable(tp.SelectedRows, tp.SelectedColumns); // // newtable.Show(); // //} //} #endregion #region Progress Bar /// /// Used for the status bar in the lower left corner of the main screen /// /// /// void tn_LoadingChildrenSQL(object sender, VETreeNodeEventArgs args) { ProgBarText = "Loading SQL"; } /// /// Used for the status bar in the lower left corner of the main screen /// /// /// void tn_LoadingChildernValue(object sender, VETreeNodeEventArgs args) { ProgBarValue = args.Value; } /// /// Used for the status bar in the lower left corner of the main screen /// /// /// void tn_LoadingChildernMax(object sender, VETreeNodeEventArgs args) { ProgBarMax = args.Value; ProgBarText = "Loading..."; } /// /// Used for the status bar in the lower left corner of the main screen /// /// /// void tn_LoadingChildernDone(object sender, VETreeNodeEventArgs args) { #if (DEBUG) ProgBarText = args.Info + " Seconds"; #else ProgBarText = ""; #endif } public int ProgBarMax { get { return bottomProgBar.Maximum; } set { bottomProgBar.Maximum = value; } } public int ProgBarValue { get { return bottomProgBar.Value; } set { bottomProgBar.Value = value; } } public string ProgBarText { get { return bottomProgBar.Text; } set { bottomProgBar.TextVisible = true; bottomProgBar.Text = value; } } #endregion #region Find/Replace and Search /// /// Find/Replace button on the ribbon /// Display the Find/Replace dialog /// /// /// //private void btnFindRplDlg_Click_1(object sender, EventArgs e) //{ // FindReplace frmFindRepl = new FindReplace(); // frmFindRepl.Show(); //} /// /// Global Search button on the ribbon /// Opens the Information Pannel and selects the Results tab /// /// /// //private void btnGlbSrch_Click(object sender, EventArgs e) //{ // toolsPanel.Expanded = true; // toolsTabs.SelectedTab = toolstabResults; //} #endregion #region Similar Steps /// /// Similar Steps button on the ribbon /// Opens the Information Pannel and selects the Results tab /// /// /// private void btnSimStps_Click(object sender, EventArgs e) { //infoPanel.Expanded = true; //infoTabs.SelectedTab = toolstabResults; //btnSimStpsRslt.Checked = true; } #endregion #region Help/About /// /// About button on the ribbon /// Display the About dialog /// /// /// private void btnAbout_Click(object sender, EventArgs e) { AboutVEPROMS about = new AboutVEPROMS(); about.ShowDialog(); } /// /// Volian Web button on the ribbon /// display the Volian web site on a pop up form /// /// /// private void btnVlnWeb_Click(object sender, EventArgs e) { VlnWeb veWWW = new VlnWeb(); veWWW.Show(); } #endregion #region Ribbon /// /// This Opens the treeView or opens the selected item in the TreeView /// /// /// private void btnOpen_Click(object sender, EventArgs e) { if (!epProcedures.Expanded) // If panel not expanded - expand it. { epProcedures.Expanded = true; if(tv.Nodes.Count > 0 && tv.SelectedNode==null) tv.SelectedNode = tv.Nodes[0]; tv.Focus(); } else { // TODO: DeleteMe //VETreeNode tn = (VETreeNode)(tv.SelectedNode); tv.OpenNode(); } } private void btnNew_Click(object sender, EventArgs e) { if (!epProcedures.Expanded) return; VETreeNode vtn = tv.SelectedNode as VETreeNode; if (vtn == null) return; // nothing was selected. if (btnNew.SubItems.Count > 0) return; // submenu will be displayed vtn.Expand(); // Determine type of 'new' based on tree node's object type. The // only options here are those that would not have created, based on // containers, a submenu (see the office2007buttonstartbutton1_click code) FolderInfo fi = vtn.VEObject as FolderInfo; if (fi != null) { tv.tv_NodeNew(vlnTreeView.MenuSelections.Folder); return; } DocVersionInfo dvi = vtn.VEObject as DocVersionInfo; if (dvi != null) { tv.tv_NodeNew(vlnTreeView.MenuSelections.Procedure); return; } // All other types are handled with sub-menus. } /// /// Options button on the dialog that appears when the V icon is clicked (top left of application window) /// note that the "V icon" is also called the Office 2007 Start Button /// /// /// private void btnOptions_Click(object sender, EventArgs e) { frmSysOptions VeSysOpts = new frmSysOptions(); VeSysOpts.ShowDialog(); } /// /// Exit button on the dialog that appears when the V icon is clicked (top left of application window) /// note that the "V icon" is also called the Office 2007 Start Button /// /// /// private void btnExit_Click(object sender, EventArgs e) { this.Close(); } #endregion #region InfoTabRO private void infotabRO_Click(object sender, EventArgs e) { infoPanel.Expanded = true; infoTabs.SelectedTab = infotabRO; //if (dtp == null) return; displayRO.Mydvi = SelectedDVI; displayRO.MyROFST = SelectedROFst; displayRO.MyRTB = (SelectedStepTabPanel == null) ? null : SelectedStepTabPanel.MyStepPanel.SelectedStepItem.MyStepRTB; displayRO.TabControl = tc; displayRO.ProgressBar = bottomProgBar; } #endregion #region InfoTabTransition private void infotabTransition_Click(object sender, EventArgs e) { if (tc == null || tc.SelectedDisplayTabItem == null) return; if (SelectedStepTabPanel == null) return; displayTransition.MyRTB = SelectedStepTabPanel.MyStepPanel.SelectedStepItem.MyStepRTB; displayTransition.CurTrans = null; } #endregion #region InfoTabLibDocs private void tabItemLibDocs_Click(object sender, EventArgs e) { displayLibDocs.LibDocListFillIn(tc); } private void tv_SectionShouldClose(object sender, vlnTreeSectionInfoEventArgs args) { if (!args.MySectionInfo.IsStepSection) tc.CloseWordItem(args.MySectionInfo); } #endregion #region InfoTabTags private void infotabTags_Click(object sender, EventArgs e) { infoPanel.Expanded = true; infoTabs.SelectedTab = infotabTags; displayTags.MyRTB = (SelectedStepTabPanel == null) ? null : SelectedStepTabPanel.MyStepPanel.SelectedStepItem.MyStepRTB; } #endregion #region InfoTabBookMarks private void infotabBookMarks_Click(object sender, EventArgs e) { infoPanel.Expanded = true; infoTabs.SelectedTab = infotabTags; displayTags.MyRTB = (SelectedStepTabPanel == null) ? null : SelectedStepTabPanel.MyStepPanel.SelectedStepItem.MyStepRTB; } #endregion #region PanelSupport private void tc_PanelTabDisplay(object sender, StepPanelTabDisplayEventArgs args) { if (args.PanelTabName == "Bookmarks") { toolsPanel.Expanded = true; toolsTabs.SelectedTab = toolsTabBookMarks; if (_CurrentItem != null) displayBookMarks.AddBookMark(_CurrentItem); } else if (args.PanelTabName == "Global Search") { toolsPanel.Expanded = true; toolsTabs.SelectedTab = toolstabResults; } else if (args.PanelTabName == "LibDocs") { toolsPanel.Expanded = true; toolsTabs.SelectedTab = tabItemLibDocs; } else if (args.PanelTabName == "Annots") { epAnnotations.Expanded = true; } else if (args.PanelTabName == "Change Step Type") { infoPanel.Expanded = true; infoTabs.SelectedTab = infotabTags; displayTags.HighlightChangeStep(); } } private void tc_StepPanelModeChange(object sender, StepRTBModeChangeEventArgs args) { this.lblEditView.Text = args.ViewMode == E_ViewMode.Edit ? "Edit" : "View"; } private ItemInfo _CurrentItem = null; private void tc_ItemSelectedChanged(object sender, ItemSelectedChangedEventArgs args) { lblEditView.Text = " "; if (args == null) { _CurrentItem = null; ctrlAnnotationDetails.CurrentAnnotation = null; ctrlAnnotationDetails.Annotations = null; infotabRO.Visible = infotabTransition.Visible = infotabTags.Visible = false; // When infotabTags is set to InVisible, the matching panel also needs to be set to invisible infotabControlPanelTags.Visible = false; SelectedStepTabPanel = null; } else { if (_CurrentItem != args.MyItemInfo) _CurrentItem = args.MyItemInfo; //vlnStackTrace.ShowStack("enter tc_ItemSelectedChanged {0}", _CurrentItem); if (args.MyStepItem == null) { infotabTransition.Visible = false; infotabRO.Visible = true; displayRO.MyRTB = null; infotabTags.Visible = true; displayBookMarks.MyRTB = null; //vlnStackTrace.ShowStack("enter tc_ItemSelectedChanged {0}", _CurrentItem); } else { if (args.MyStepItem.MyItemInfo.IsSection || args.MyStepItem.MyItemInfo.IsProcedure) { infotabRO.Visible = infotabTransition.Visible = false; infotabTags.Visible = true; } else infotabRO.Visible = infotabTransition.Visible = infotabTags.Visible = true; //vlnStackTrace.ShowStack("enter tc_ItemSelectedChanged {0}", _CurrentItem); // When infotabTags is set to Visible, the matching panel also needs to be set to visible // the other panels will appear as they are selected by the user. infotabControlPanelTags.Visible = true; // When infotabTags is set to Visible, it is given focus. The next line returns focus to the StepRTB args.MyStepItem.MyStepRTB.Focus(); displayTransition.MyRTB = args.MyStepItem.MyStepRTB; displayRO.MyRTB = args.MyStepItem.MyStepRTB; displayTags.MyRTB = args.MyStepItem.MyStepRTB; displayBookMarks.MyRTB = args.MyStepItem.MyStepRTB; displayRO.ProgressBar = bottomProgBar; lblEditView.Text = args.MyStepItem.MyStepRTB.ViewRTB ? "View" : "Edit"; } if(tc.SelectedDisplayTabItem != null) SelectedStepTabPanel = ((DisplayTabItem)tc.SelectedDisplayTabItem).MyStepTabPanel; } ctrlAnnotationDetails.UpdateAnnotationGrid(_CurrentItem); AnnotationPanelView(); } #endregion #region Annotations /// /// Display or hide the Annotation Details panel /// private void AnnotationPanelView() { if (ctrlAnnotationDetails.Annotations != null && ctrlAnnotationDetails.Annotations.Count != 0) { if (Settings.Default.AutoPopUpAnnotations) //cbAnnotationPopup.Checked epAnnotations.Expanded = true; else epAnnotations.TitleStyle.BackColor1.Color = Color.Yellow; } else { if (!btnAnnoDetailsPushPin.Checked) epAnnotations.Expanded = false; epAnnotations.TitleStyle.BackColor1.Color = _CommentTitleBckColor; ctrlAnnotationDetails.AnnotationText = null; } } #endregion #region LinkSupport private void tc_LinkActiveChanged(object sender, StepPanelLinkEventArgs args) { // determine if any infotabs are visisble, and if it is the Transition, // change the curitem for the transition to the current item. if (infoPanel.Expanded == true && infoTabs.SelectedTab == infotabTransition) { displayTransition.CurTrans = null; } } private void tc_LinkModifyTran(object sender, StepPanelLinkEventArgs args) { infoPanel.Expanded = true; infoTabs.SelectedTab = infotabTransition; if (SelectedStepTabPanel == null) return; displayTransition.MyRTB = SelectedStepTabPanel.MyStepPanel.SelectedStepItem.MyStepRTB; displayTransition.CurTrans = args.MyLinkText.MyTransitionInfo; } private void tc_LinkModifyRO(object sender, StepPanelLinkEventArgs args) { infoPanel.Expanded = true; infoTabs.SelectedTab = infotabRO; if (SelectedStepTabPanel == null) return; displayRO.MyROFST = SelectedROFst; displayRO.MyRTB = SelectedStepTabPanel.MyStepPanel.SelectedStepItem.MyStepRTB; displayRO.CurROLink = args.MyLinkText.MyRoUsageInfo; displayRO.Mydvi = SelectedDVI; displayRO.ProgressBar = bottomProgBar; displayRO.TabControl = tc; } #endregion #region VButton private void office2007StartButton1_Click(object sender, EventArgs e) { // If the V-Button is clicked, check to see what tree node is s selected // to set up the New submenus. The New submenus are dependent on the type of // object selected, i.e. folder, docversion, etc. // reset in case previous selection changed items. btnNew.SubItems.Clear(); btnNew.Enabled = true; VETreeNode vtn = tv.SelectedNode as VETreeNode; if (vtn == null) return; vtn.Expand(); // Folders can have either folders & docversions, but // not a mix. FolderInfo fi = vtn.VEObject as FolderInfo; if (fi != null) { if (fi.FolderDocVersionCount > 0) { btnNew.Enabled = false; return; } // if at top, 'VE-PROMS', folder and childfolders below this only // option is to create a new (sub)folder, i.e. no submenu items. if (fi.ChildFolderCount > 0 && fi.MyParent==null) return; //if (fi.ChildFolderCount == 0) // submenu folders/docversion //{ if (fi.MyParent != null) { ButtonItem fldbbtn = new ButtonItem("fldbtn", "Folder Before"); ButtonItem fldabtn = new ButtonItem("fldabtn", "Folder After"); btnNew.SubItems.Add(fldbbtn); btnNew.SubItems.Add(fldabtn); fldbbtn.Click += new EventHandler(fldbbtn_Click); fldabtn.Click += new EventHandler(fldabtn_Click); } ButtonItem fldbtn = new ButtonItem("fldbtn", "Folder"); btnNew.SubItems.Add(fldbtn); fldbtn.Click += new EventHandler(fldbtn_Click); if (fi.ChildFolderCount == 0) { ButtonItem dvbtn = new ButtonItem("dvbtn", "Document Version"); btnNew.SubItems.Add(dvbtn); dvbtn.Click += new EventHandler(dvbtn_Click); } return; //} } // DocVersions can only have procedures, so no sub-menu DocVersionInfo dvi = vtn.VEObject as DocVersionInfo; if (dvi != null) return; // Procedures can have a section added or a new procedure before // or after. ProcedureInfo pi = vtn.VEObject as ProcedureInfo; if (pi != null) { ButtonItem pbbtn = new ButtonItem("pfbtn", "Procedure Before"); ButtonItem pabtn = new ButtonItem("pabtn", "Procedure After"); ButtonItem sctbtn = new ButtonItem("sctbtn", "Section"); btnNew.SubItems.Add(pbbtn); btnNew.SubItems.Add(pabtn); btnNew.SubItems.Add(sctbtn); pbbtn.Click += new EventHandler(pbbtn_Click); pabtn.Click += new EventHandler(pabtn_Click); sctbtn.Click += new EventHandler(sctbtn_Click); return; } // Sections can have sections before, after, new subsections & if is // a step section, can have steps SectionInfo si = vtn.VEObject as SectionInfo; if (si != null) { ButtonItem sbbtn = new ButtonItem("sbbtn", "Section Before"); ButtonItem sabtn = new ButtonItem("sabtn", "Section After"); ButtonItem subbtn = new ButtonItem("subbtn", "SubSection"); btnNew.SubItems.Add(sbbtn); btnNew.SubItems.Add(sabtn); btnNew.SubItems.Add(subbtn); sbbtn.Click += new EventHandler(sbbtn_Click); sabtn.Click += new EventHandler(sabtn_Click); subbtn.Click += new EventHandler(subbtn_Click); if (si.IsStepSection) { ButtonItem stpbtn = new ButtonItem("stpbtn", "New Step"); btnNew.SubItems.Add(stpbtn); stpbtn.Click += new EventHandler(stpbtn_Click); } return; } // Steps can have steps before or after only. StepInfo stpi = vtn.VEObject as StepInfo; if (stpi != null) { ButtonItem stpbbtn = new ButtonItem("stpbbtn", "New Step Before"); ButtonItem stpabtn = new ButtonItem("stpabtn", "New Step After"); btnNew.SubItems.Add(stpbbtn); btnNew.SubItems.Add(stpabtn); stpbbtn.Click += new EventHandler(stpbbtn_Click); stpabtn.Click += new EventHandler(stpabtn_Click); return; } } void fldabtn_Click(object sender, EventArgs e) { tv.tv_NodeNew(vlnTreeView.MenuSelections.FolderAfter); } void fldbbtn_Click(object sender, EventArgs e) { tv.tv_NodeNew(vlnTreeView.MenuSelections.FolderBefore); } void stpabtn_Click(object sender, EventArgs e) { tv.tv_NodeNew(vlnTreeView.MenuSelections.StepAfter); } void stpbbtn_Click(object sender, EventArgs e) { tv.tv_NodeNew(vlnTreeView.MenuSelections.StepBefore); } void subbtn_Click(object sender, EventArgs e) { tv.tv_NodeNew(vlnTreeView.MenuSelections.Section); } void sabtn_Click(object sender, EventArgs e) { tv.tv_NodeNew(vlnTreeView.MenuSelections.SectionAfter); } void sbbtn_Click(object sender, EventArgs e) { tv.tv_NodeNew(vlnTreeView.MenuSelections.SectionBefore); } void stpbtn_Click(object sender, EventArgs e) { tv.tv_NodeNew(vlnTreeView.MenuSelections.Step); } void sctbtn_Click(object sender, EventArgs e) { tv.tv_NodeNew(vlnTreeView.MenuSelections.Section); } void pabtn_Click(object sender, EventArgs e) { tv.tv_NodeNew(vlnTreeView.MenuSelections.ProcedureAfter); } void pbbtn_Click(object sender, EventArgs e) { tv.tv_NodeNew(vlnTreeView.MenuSelections.ProcedureBefore); } void dvbtn_Click(object sender, EventArgs e) { tv.tv_NodeNew(vlnTreeView.MenuSelections.DocVersion); } void fldbtn_Click(object sender, EventArgs e) { tv.tv_NodeNew(vlnTreeView.MenuSelections.Folder); } private void btnSave_Click(object sender, EventArgs e) { } #endregion #region PanelEvents private void infoPanel_Click(object sender, EventArgs e) { displayTags.MyRTB = (SelectedStepTabPanel == null) ? null : SelectedStepTabPanel.MyStepPanel.SelectedStepItem.MyStepRTB; } //private void tv_SectionShouldClose(object sender, vlnTreeSectionInfoEventArgs args) //{ // if (!args.MySectionInfo.IsStepSection) tc.CloseWordItem(args.MySectionInfo); //} private void infotabResults_Click(object sender, EventArgs e) { toolsPanel.Expanded = true; InitiateSearch(true); } private void InitiateSearch(bool searchFocus) { if (toolsPanel.Expanded) { if (displaySearch1.Mydocversion == null)//!displaySearch1.OpenDocFromSearch) { if (SelectedDVI != null) { displaySearch1.Mydocversion = SelectedDVI; displaySearch1.advTreeStepTypesFillIn(); } displaySearch1.advTreeProcSetsFillIn(searchFocus); } } } private void ribbonControl1_ExpandedChanged(object sender, EventArgs e) { Console.WriteLine("Size {0}",ribbonControl1.Expanded); // TODO: Need to send message to all StepTabPanels and tell them to minimize their ribbons. tc.RibbonExpanded = ribbonControl1.Expanded; } private void btnItemInfo_Click(object sender, EventArgs e) { frmPropGrid pg = new frmPropGrid(tc.SelectedDisplayTabItem.SelectedItemInfo, tc.SelectedDisplayTabItem.SelectedItemInfo.Path); pg.Show(); } private void epAnnotations_Resize(object sender, EventArgs e) { if (epAnnotations.Expanded && !_panelExpandedChanging) { // if the height of the panel is smaller than the titleheight+20 //(due to the user dragging the splitter down), then un-expand the // panel and set the height to the titleheight+75 if (epAnnotations.Size.Height < epAnnotations.TitleHeight + 20) { Size sz = new Size(epAnnotations.Size.Width, epAnnotations.TitleHeight + 75); epAnnotations.Size = sz; epAnnotations.Expanded = false; } } } private void resizeVerticalExpandedPanel(object sender, EventArgs e) { ExpandablePanel ep = (ExpandablePanel)sender; if (ep.Expanded && !_panelExpandedChanging) { // if the width of the panel is smaller than the titleheight+20 //(due to the user dragging the splitter over), then un-expand the // panel and set the width to the titleheight+50 if (ep.Size.Width < ep.TitleHeight + 10) { Size sz = new Size(ep.TitleHeight + 50, ep.Size.Height); ep.Size = sz; ep.Expanded = false; } } } private void expandPanelExpandedChanging(object sender, ExpandedChangeEventArgs e) { _panelExpandedChanging = true; } private void toolsPanel_ExpandedChanged(object sender, ExpandedChangeEventArgs e) { _panelExpandedChanging = false; expandableSplitter4.Enabled = toolsPanel.Expanded; if (toolsPanel.Expanded) InitiateSearch(true); } private void epAnnotations_ExpandedChanged(object sender, ExpandedChangeEventArgs e) { _panelExpandedChanging = false; expandableSplitter2.Enabled = epAnnotations.Expanded; } private void epProcedures_ExpandedChanged(object sender, ExpandedChangeEventArgs e) { _panelExpandedChanging = false; expandableSplitter1.Enabled = epProcedures.Expanded; } private void infoPanel_ExpandedChanged(object sender, ExpandedChangeEventArgs e) { _panelExpandedChanging = false; expandableSplitter3.Enabled = infoPanel.Expanded; } #endregion //protected override void WndProc(ref Message m) //{ // base.WndProc(ref m); //} } }