From b84bf353392a126e219a381602e9c54ef752efd3 Mon Sep 17 00:00:00 2001 From: Kathy Date: Tue, 3 Nov 2009 16:33:46 +0000 Subject: [PATCH] --- .../Volian.Controls.Library/DisplayLibDocs.cs | 64 +++++++++++-------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/PROMS/Volian.Controls.Library/DisplayLibDocs.cs b/PROMS/Volian.Controls.Library/DisplayLibDocs.cs index 5dfb1286..363a8269 100644 --- a/PROMS/Volian.Controls.Library/DisplayLibDocs.cs +++ b/PROMS/Volian.Controls.Library/DisplayLibDocs.cs @@ -63,38 +63,43 @@ namespace Volian.Controls.Library private void listBoxLibDocs_Click(object sender, EventArgs e) { if (listBoxLibDocs.SelectedIndex == _SelectedLibDoc) return; + UpdateUsageList(); + } + + private void UpdateUsageList() + { groupPanelLibDocs.Style.BackColor = Color.Orange; - _SelectedLibDoc = listBoxLibDocs.SelectedIndex; - listBoxUsages.Items.Clear(); - tbComment.Clear(); - tbName.Clear(); - btnSave.Enabled = false; - btnCancel.Enabled = false; - _InitializingLibDocList = true; // need this so textchanged code doesn't turn save/cancel buttons on. - tbName.Text = LibDocList[_SelectedLibDoc].LibTitle; + _SelectedLibDoc = listBoxLibDocs.SelectedIndex; + listBoxUsages.Items.Clear(); + tbComment.Clear(); + tbName.Clear(); + btnSave.Enabled = false; + btnCancel.Enabled = false; + _InitializingLibDocList = true; // need this so textchanged code doesn't turn save/cancel buttons on. + tbName.Text = LibDocList[_SelectedLibDoc].LibTitle; - DocumentConfig dc = new DocumentConfig(LibDocList[_SelectedLibDoc]); - tbComment.Text = dc.LibDoc_Comment; - _InitializingLibDocList = false; + DocumentConfig dc = new DocumentConfig(LibDocList[_SelectedLibDoc]); + tbComment.Text = dc.LibDoc_Comment; + _InitializingLibDocList = false; - // If there are no usages, then enable delete & open button (open for docs with usages occurs - // from usage list), otherwise disable buttons & list usages - DocumentInfo dicnt = LibDocList[_SelectedLibDoc]; - ItemInfoList iil = dicnt.LibraryDocumentUsageList; - groupPanelUsages.Style.BackColor = dicnt.LibraryDocumentUsageList==null||dicnt.LibraryDocumentUsageList.Count==0 ? this.saveGroupPanelUsages : Color.LightGreen; - if (iil == null) - { - btnDelLibDoc.Enabled = true; - btnOpenLibDoc.Enabled = true; - return; - } - // Put the usages in the usage list for the selected library document. - btnDelLibDoc.Enabled = false; - btnOpenLibDoc.Enabled = false; + // If there are no usages, then enable delete & open button (open for docs with usages occurs + // from usage list), otherwise disable buttons & list usages + DocumentInfo dicnt = LibDocList[_SelectedLibDoc]; + ItemInfoList iil = dicnt.LibraryDocumentUsageList; + groupPanelUsages.Style.BackColor = dicnt.LibraryDocumentUsageList == null || dicnt.LibraryDocumentUsageList.Count == 0 ? this.saveGroupPanelUsages : Color.LightGreen; + if (iil == null) + { + btnDelLibDoc.Enabled = true; + btnOpenLibDoc.Enabled = true; + return; + } + // Put the usages in the usage list for the selected library document. + btnDelLibDoc.Enabled = false; + btnOpenLibDoc.Enabled = false; foreach (ItemInfo ii in dicnt.LibraryDocumentUsageList) - { - listBoxUsages.Items.Add(ii.MyProcedure.ToString() + " - " + ii.MyContent.Number + " " + ii.MyContent.Text); - } + { + listBoxUsages.Items.Add(ii.MyProcedure.ToString() + " - " + ii.MyContent.Number + " " + ii.MyContent.Text); + } } private void btnDelLibDoc_Click(object sender, EventArgs e) { @@ -130,7 +135,10 @@ namespace Volian.Controls.Library if (chg == true) { doc.Save(); + int cursel = _SelectedLibDoc; LibDocListFillIn(_DisplayTabControl); + listBoxLibDocs.SelectedIndex = cursel; + UpdateUsageList(); } } private void btnCancel_Click(object sender, EventArgs e)