private void LaunchClientDoc(string docType) { try { ClientForm myForm = new ClientForm(); myForm.ShowDialog(); XLMain.Client selectedClient = myForm.selectedClient; if (selectedClient != null) { string crmId = selectedClient.crmID; XLDocument.openTemplate(docType); XLDocument.UpdateParameter("CRMid", crmId); XLDocument.UpdateParameter("DocType", docType); //this appears to work in 3.5 notwithstanding the reference to Globals xlTaskPane1 = new XLTaskPane(); CustomxlTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(xlTaskPane1, "XLant Document Handler", Globals.ThisAddIn.Application.ActiveWindow); CustomxlTaskPane.Visible = true; CustomxlTaskPane.Width = 350; } } catch (Exception e) { MessageBox.Show("Unable to launch document"); XLtools.LogException("LaunchClientDoc", docType + " - " + e.ToString()); } }
public static string GetFileID() { try { XLDocument.UpdateCurrentDoc(); string fileID = ""; //Check whether the parameter has already been set fileID = ReadParameter("FileID"); fileID = currentDoc.Name; if (fileID.IndexOf("-") > -1) { int len = fileID.IndexOf("-"); //get the index of the version identifier fileID = fileID.Substring(0, len); //ignore everything after and including the - if (String.IsNullOrEmpty(fileID) || !int.TryParse(fileID, out int i)) { throw new ArgumentException("Document doesn't appear to be in VC"); } UpdateParameter("FileID", fileID); //add the parameter for next time. return(fileID); } else { return(null); } } catch (Exception e) { MessageBox.Show("Unable to discover file ID"); XLtools.LogException("GetFileID", e.ToString()); return(null); } }
public static void AddStatusBox() { try { XLDocument.UpdateCurrentDoc(); Microsoft.Office.Interop.Word.Shape textBox; //Check whether the bookmark already exists and only if it doesn't add it if (!currentDoc.Bookmarks.Exists("Status")) { textBox = currentDoc.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 400, 50, 100, 50); textBox.Line.Visible = MsoTriState.msoFalse; textBox.Name = "MLStatus"; textBox.TextFrame.TextRange.Text = "Status"; textBox.TextFrame.TextRange.Font.Hidden = 1; textBox.TextFrame.TextRange.Font.Italic = 1; textBox.TextFrame.TextRange.Font.Name = "Calibri"; textBox.TextFrame.TextRange.Font.Size = 16; textBox.TextFrame.TextRange.Bookmarks.Add("Status"); } } catch (Exception e) { MessageBox.Show("Unable to add the status box"); XLtools.LogException("AddStatusBox", e.ToString()); } }
public static void EndDocument() { try { XLDocument.UpdateCurrentDoc(); //close panel if open if (XLantWordRibbon.xlTaskPane1 != null) { XLantWordRibbon.xlTaskPane1.Visible = false; XLantWordRibbon.xlTaskPane1.Dispose(); //remove the task pane Globals.ThisAddIn.CustomTaskPanes.Remove(XLantWordRibbon.CustomxlTaskPane); } string str = currentDoc.FullName; //close document ((_Document)currentDoc).Close(SaveChanges: WdSaveOptions.wdDoNotSaveChanges); //no longer necessary to delete file if it is a VC doc as it does it itself //File.Delete(str); } catch (Exception e) { MessageBox.Show("Unable to close document and exit"); XLtools.LogException("EndDocument", e.ToString()); } }
private void StaffAddressBtn_Click(object sender, RibbonControlEventArgs e) { try { StaffForm myForm = new StaffForm(); myForm.ShowDialog(); XLMain.Staff contact = myForm.selectedContact; string str = ""; if (contact.addresses[0].addressBlock != null) { if (contact.salutations.Count > 0) { str += contact.salutations[0].addressee + Environment.NewLine; } str += contact.addresses[0].addressBlock; XLDocument.InsertText(str); //insert the status text box; //XLDocument.AddStatusBox(); //XLDocument.ChangeStatus("Draft"); } else { MessageBox.Show(contact.name + " does not have an address in the system."); } } catch (Exception ex) { MessageBox.Show("Unable to get staff address"); XLtools.LogException("StaffAddressBtn", ex.ToString()); } }
private void InsolAddressBtn_Click(object sender, RibbonControlEventArgs e) { try { ClientForm myClientForm = new ClientForm(); myClientForm.ShowDialog(); XLMain.Client client = myClientForm.selectedClient; IPSContForm myForm = new IPSContForm(client); myForm.ShowDialog(); XLInsol.Contact selectContact = myForm.selectedContact; if (selectContact != null) { string str = selectContact.name + Environment.NewLine; str += selectContact.addressBlock; XLDocument.InsertText(str); //XLDocument.AddStatusBox(); //XLDocument.ChangeStatus("Draft"); } else { MessageBox.Show("No contact selected."); } } catch (Exception ex) { MessageBox.Show("Unable to get insolvency address"); XLtools.LogException("InsolAddressBtn", ex.ToString()); } }
public static Header MapHeaderFooter(string office, string footer) { try { Header selectedHeader = new Header(); //query the setting files and try to find a match XElement selectedMap = (from map in settingsDoc.Descendants("Map") where (string)map.Attribute("Office") == office && (string)map.Attribute("Footer") == footer select map).FirstOrDefault(); if (selectedMap != null) { //find the header with that description XElement foundHeader = (from heading in settingsDoc.Descendants("Heading") where (string)heading.Attribute("Description").Value == selectedMap.Attribute("Header").Value select heading).FirstOrDefault(); //then build the object selectedHeader = new Header(foundHeader); } else { MessageBox.Show("Unable to Map " + office + ":" + footer + ". Please review mappings or make another selection."); } return(selectedHeader); } catch (Exception e) { MessageBox.Show("Unable to map header"); XLtools.LogException("MapHeaderFooter", e.ToString()); return(null); } }
public static void UpdateBookmark(string bName, string bValue, int bold = 2, string styleName = "") { try { XLDocument.UpdateCurrentDoc(); if (currentDoc.Bookmarks.Exists(bName)) { Range bRange = currentDoc.Bookmarks.get_Item(bName).Range; bRange.Text = bValue; //apply style first so that the bold can override if necessary if (styleName != "") { bRange.set_Style(currentDoc.Styles[styleName]); } //bold is not specified make no changes so it stickes with the style in the document if (bold < 2) { bRange.Bold = bold; } currentDoc.Bookmarks.Add(bName, bRange); } } catch (Exception e) { MessageBox.Show("Unable to update bookmark"); XLtools.LogException("UpdateBookmark", e.ToString()); } }
private static void WhenCallingString(XLMain.Staff wcStaff) { try { if (wcStaff == null) { XLDocument.UpdateBookmark("Whencalling", ""); XLDocument.UpdateBookmark("Calling", ""); XLDocument.UpdateBookmark("WcEmail", ""); XLDocument.UpdateBookmark("WcEmailAddress", ""); } else { XLDocument.UpdateBookmark("Whencalling", "When calling please ask for: ", 1); XLDocument.UpdateBookmark("Calling", wcStaff.name); if (wcStaff.emails != null) { XLDocument.UpdateBookmark("WcEmail", "e-mail: ", 1); XLDocument.UpdateBookmark("WcEmailAddress", wcStaff.emails[0].email); } else { XLDocument.UpdateBookmark("WcEmail", ""); XLDocument.UpdateBookmark("WcEmailAddress", ""); } } } catch (Exception ex) { MessageBox.Show("Unable to build when calling for"); XLtools.LogException("WhenCallingString", ex.ToString()); } }
private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { try { if (XLantWordRibbon.CustomxlTaskPane != null) { XLantWordRibbon.CustomxlTaskPane.Dispose(); } if (XLantWordRibbon.sigPane != null) { XLantWordRibbon.sigPane.Dispose(); } if (XLantWordRibbon.xlTaskPane1 != null) { XLantWordRibbon.xlTaskPane1.Dispose(); } Globals.Ribbons.XLantWordRibbon.Dispose(); //Microsoft.Office.Interop.Word.Application word = Globals.ThisAddIn.Application; //System.Runtime.InteropServices.Marshal.FinalReleaseComObject(word); //word = null; //GC.Collect(); //GC.WaitForPendingFinalizers(); } catch (Exception ex) { XLtools.LogException("Shutdown", ex.ToString()); } }
public VCForm(XLMain.Staff writer, XLMain.Client client, string docPath, string desc = "", string status = "Draft") { InitializeComponent(); this.CenterToParent(); XLMain.Staff user = XLMain.Staff.StaffFromUser(Environment.UserName); DescTB.Text = desc; //populate the sender List <XLMain.Staff> users = XLtools.StaffList(user, client, true); ToBeActionDDL.DataSource = users; ToBeActionDDL.DisplayMember = "name"; ToBeActionDDL.ValueMember = "crmID"; if (writer != null) { ToBeActionDDL.SelectedItem = writer; } if (client.department != "INS") { FileSectionDDL.Visible = false; FileSectionlbl.Visible = false; } else { FileSectionDDL.Visible = true; FileSectionlbl.Visible = true; } }
private void IndexBtn_Click(object sender, RibbonControlEventArgs e) { try { XLDocument.currentDoc.Save(); //populate description string desc = XLDocument.ReadParameter("DocType"); desc += " to "; desc += XLDocument.ReadBookmark("Addressee"); string str = XLDocument.ReadParameter("CRMid"); XLMain.Client client = new XLMain.Client(); if (str != "") { client = XLMain.Client.FetchClient(str); } else { ClientForm cForm = new ClientForm(); cForm.ShowDialog(); client = cForm.selectedClient; } XLMain.Staff writer = new XLMain.Staff(); string writerID = XLDocument.ReadParameter("Sender"); if (writerID == "") { writer = XLMain.Staff.StaffFromUser(Environment.UserName); } else { writer = XLMain.Staff.StaffFromUser(XLDocument.ReadParameter("Sender")); } VCForm myForm = new VCForm(writer, client, XLDocument.currentDoc.FullName, desc, XLDocument.ReadParameter("VCStatus")); myForm.ShowDialog(); //collect result from form XLVirtualCabinet.BondResult outcome = myForm.outcome; if (outcome.ExitCode == 0) { XLDocument.EndDocument(); xlTaskPane1.Dispose(); } else { MessageBox.Show("Unable to index document, please index manually. Error code: " + outcome.ExitCode.ToString() + "-" + outcome.StandardOutput.ToString()); } //close the dialog in any event. } catch (Exception ex) { MessageBox.Show("Error calling the VC integration. Error code: " + ex.ToString()); XLtools.LogException("IndexBtn", ex.ToString()); } }
private void PrintBtn_Click(object sender, EventArgs e) { try { object oMissing = System.Reflection.Missing.Value; Document currentDoc = Globals.ThisAddIn.Application.ActiveDocument; //Get options from user //Set the printer to the selection in the ddl string printer = (string)PrinterDDL.SelectedItem; string paper = ((string)PaperDDL.SelectedItem).ToLower(); //set printer trays based on input and obtain id from XML if (paper == "headed & continuation") { if (currentDoc.Sections.Count > 1) { //currentDoc.PageSetup.SectionStart = WdSectionStart.wdSectionNewPage; foreach (Section s in currentDoc.Sections) { int i = s.Index; currentDoc.Sections[i].PageSetup.FirstPageTray = GetTray(printer, "headed"); currentDoc.Sections[i].PageSetup.OtherPagesTray = GetTray(printer, "continuation"); } } else { currentDoc.PageSetup.FirstPageTray = GetTray(printer, "headed"); currentDoc.PageSetup.OtherPagesTray = GetTray(printer, "continuation"); } } else { currentDoc.PageSetup.FirstPageTray = GetTray(printer, paper); currentDoc.PageSetup.OtherPagesTray = GetTray(printer, paper); } //Globals.ThisAddIn.Application.ActivePrinter = printer; object basic = Globals.ThisAddIn.Application.WordBasic; object[] oWordDialogParams = { printer, true }; string[] argNames = { "Printer", "DoNotSetAsSysDefault" }; basic.GetType().InvokeMember("FilePrintSetup", BindingFlags.InvokeMethod, null, basic, oWordDialogParams, null, null, argNames); PrintDocument printDoc = new PrintDocument(); //Print the document currentDoc.PrintOut(true, false, WdPrintOutRange.wdPrintAllDocument, oMissing, oMissing, oMissing, oMissing, "1", oMissing, WdPrintOutPages.wdPrintAllPages, oMissing, true, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing); this.Close(); } catch (Exception ex) { MessageBox.Show("Unable to allocate printer trays, please use the advanced button"); XLtools.LogException("QuickPrint", ex.ToString()); } }
private void RevertBtn_Click(object sender, EventArgs e) { try { //Deal with salutations if (client.salutations != null) { SalDDL.DataSource = client.salutations; SalDDL.DisplayMember = "Salutation"; SalDDL.ValueMember = "Addressee"; sal = (XLMain.Salutation)SalDDL.SelectedItem; if (sal != null) { AddresseeTB.Text = sal.addressee; SalutationTb.Text = sal.salutation; } } //Deal with addresses if (docType == "Letter") { if (client.addresses != null) { allAddresses = client.addresses; addressesDDL.DataSource = allAddresses; addressesDDL.DisplayMember = "address1"; addressesDDL.ValueMember = "addressBlock"; add = (XLMain.Address)addressesDDL.SelectedItem; if (add != null) { addTB.Text = add.addressBlock; } } } else if (docType == "Fax") { XLMain.Number fax = XLMain.Number.GetNumber(client.crmID, "Fax"); if (fax != null) { FaxTB.Text = fax.number; } } RevertBtn.Visible = false; XLDocument.UpdateBookmark("Salutation", SalutationTb.Text); XLDocument.UpdateBookmark("Addressee", AddresseeTB.Text); XLDocument.UpdateBookmark("Addressee2", AddresseeTB.Text); XLDocument.UpdateBookmark("Address", addTB.Text); XLDocument.UpdateBookmark("Fax", FaxTB.Text); } catch (Exception ex) { MessageBox.Show("Unable to revert"); XLtools.LogException("RevertBtn", ex.ToString()); } }
public static void InsertText(string text) { try { Microsoft.Office.Interop.Word.Range CurrRange = CurrentRange(); CurrRange.Text = text; } catch (Exception e) { MessageBox.Show("Unable to insert text"); XLtools.LogException("InsertText", e.ToString()); } }
private void IPSContactBtn_Click(object sender, EventArgs e) { try { IPSContForm myForm = new IPSContForm(client); myForm.ShowDialog(); XLInsol.Contact selectContact = myForm.selectedContact; if (selectContact != null) { if (docType == "Letter") { if (selectContact != null) { allAddresses = null; addressesDDL.DataSource = null; string add = selectContact.name; add += Environment.NewLine + selectContact.addressBlock; addTB.Text = add; } } else if (docType == "Fax") { if (selectContact.fax != null) { FaxTB.Text = selectContact.fax; } } SalDDL.DataSource = null; AddresseeTB.Text = ""; SalutationTb.Text = ""; RevertBtn.Visible = true; XLDocument.UpdateBookmark("Salutation", SalutationTb.Text); XLDocument.UpdateBookmark("Addressee", AddresseeTB.Text); XLDocument.UpdateBookmark("Addressee2", AddresseeTB.Text); XLDocument.UpdateBookmark("Address", addTB.Text); XLDocument.UpdateBookmark("Fax", FaxTB.Text); } else { MessageBox.Show("No address returned"); } } catch (Exception ex) { MessageBox.Show("Unable to fetch insolvency contact"); XLtools.LogException("InsolContactBtn", ex.ToString()); } }
public static void openTemplate(string type) { try { string dir = StandardLocation(); Document NewDoc = new Document(); NewDoc = OpenDoc(dir + type + ".docx", true); TempSave(); } catch (Exception e) { MessageBox.Show("Unable to open template"); XLtools.LogException("OpenTemplate", e.ToString()); } }
public static string CreatePdf(string fileString = "") { try { //use tempsave to create a pdf file and return location. fileString = TempSave(".pdf", fileString); return(fileString); } catch (Exception e) { MessageBox.Show("Unable to create a pdf document"); XLtools.LogException("CreatePDf", e.ToString()); return(null); } }
private void UpdateBookmarks(string docType) { try { //Build reference string ourRef = OurRef(client, sender, user); if (docType == "Letter") { XLDocument.UpdateBookmark("Address", addTB.Text); XLDocument.UpdateBookmark("Salutation", SalutationTb.Text); XLDocument.UpdateBookmark("Subject", SubjectTB.Text); XLDocument.UpdateBookmark("Date", DateTB.Value.Date.ToString("d MMMM yyyy")); XLDocument.UpdateBookmark("Date2", DateTB.Value.Date.ToString("d MMMM yyyy")); XLDocument.UpdateBookmark("Addressee", AddresseeTB.Text); XLDocument.UpdateBookmark("Addressee2", AddresseeTB.Text); DeploySignature(client, sender, AddresseeTB.Text); XLDocument.UpdateBookmark("OurRef", ourRef, 0); } else if (docType == "Fax") { XLDocument.UpdateBookmark("Subject", SubjectTB.Text); XLDocument.UpdateBookmark("Client", client.name); XLDocument.UpdateBookmark("Date", DateTB.Value.Date.ToString("d MMMM yyyy")); XLDocument.UpdateBookmark("Date2", DateTB.Value.Date.ToString("d MMMM yyyy")); XLDocument.UpdateBookmark("Addressee", AddresseeTB.Text); XLDocument.UpdateBookmark("Addressee2", AddresseeTB.Text); DeploySignature(client, sender, AddresseeTB.Text); XLDocument.UpdateBookmark("Sender2", sender.name); XLDocument.UpdateBookmark("Fax", FaxTB.Text); XLDocument.UpdateBookmark("OurRef", ourRef, 0); } else if (docType == "FileNote") { XLDocument.UpdateBookmark("Subject", SubjectTB.Text, 1); XLDocument.UpdateBookmark("Date", DateTB.Value.Date.ToString("d MMMM yyyy")); XLDocument.UpdateBookmark("Date2", DateTB.Value.Date.ToString("d MMMM yyyy")); XLDocument.UpdateBookmark("Sender", sender.name, 1); XLDocument.UpdateBookmark("ClientStr", XLDocument.ReadParameter("ClientStr")); XLDocument.UpdateBookmark("OurRef", ourRef, 1); } } catch (Exception ex) { MessageBox.Show("Unable to update bookmarks"); XLtools.LogException("TaskPane-UpdateBookmarks", ex.ToString()); } }
public static bool AddSignature(string username) { try { //Add the actual signature string dir = StandardLocation(); Microsoft.Office.Interop.Word.Range CurrRange = CurrentRange(); CurrRange.InlineShapes.AddPicture(dir + username + ".gif"); return(true); } catch (Exception e) { MessageBox.Show("Unable to find signature"); XLtools.LogException("AddSignature", e.ToString()); return(false); } }
private void SenderDDL_SelectedIndexChanged(object sender, EventArgs e) { try { //Collect the changed record XLMain.EntityCouplet tempSend = (XLMain.EntityCouplet)SenderDDL.SelectedItem; //Convert the entity couplet to a full blown user now we know which one we want if (tempSend.crmID != "") { XLMain.Staff send = XLMain.Staff.FetchStaff(tempSend.crmID); DeploySignature(client, send, AddresseeTB.Text); XLDocument.UpdateParameter("Sender", send.username); //Build reference string ourRef = OurRef(client, send, user); XLDocument.UpdateBookmark("OurRef", ourRef, 0); } else { XLMain.Staff send = new XLMain.Staff(); send.crmID = ""; send.name = tempSend.name; send.initials = ""; DeploySignature(client, send, AddresseeTB.Text); XLDocument.UpdateParameter("Sender", ""); //Build reference string ourRef = OurRef(client, send, user); XLDocument.UpdateBookmark("OurRef", ourRef, 0); //For Milsted Langdon remove for and on behalf if (tempSend.name == "Milsted Langdon LLP") { if (FAOBCheck.Checked) { FAOBCheck.Checked = false; } } } } catch (Exception ex) { MessageBox.Show("Unable to change sender"); XLtools.LogException("TaskPane-SenderDDL", ex.ToString()); } }
public static void AddStyles() { try { XLDocument.UpdateCurrentDoc(); string path = StandardLocation() + "Letter.dotx"; Document sTemplate = OpenDoc(path, true, false, false); currentDoc.set_AttachedTemplate((object)sTemplate); sTemplate.Close(SaveChanges: false); currentDoc.UpdateStyles(); } catch (Exception e) { MessageBox.Show("Unable to add styles" + e.ToString()); XLtools.LogException("AddStyles", e.ToString()); } }
private void ClientAddressBtn_Click(object sender, RibbonControlEventArgs e) { try { ClientForm myForm = new ClientForm(); myForm.ShowDialog(); XLMain.Client client = myForm.selectedClient; //Add the name and address at the cursor location string str = ""; if (client.addresses.Count > 0) { if (client.salutations.Count > 0) { str += client.salutations[0].addressee + Environment.NewLine; if (client.name != client.salutations[0].addressee) { str += client.name + Environment.NewLine; } } else { str += client.name + Environment.NewLine; } str += client.addresses[0].addressBlock; XLDocument.InsertText(str); //Add any parameters we can for later indexing string fileStore = XLVirtualCabinet.FileStore(client.office, client.department); XLDocument.UpdateParameter("CRMid", client.crmID); XLDocument.UpdateParameter("Cabinet", fileStore); XLDocument.UpdateParameter("ClientStr", client.clientcode + " - " + client.name); //insert the status text box; //XLDocument.AddStatusBox(); //XLDocument.ChangeStatus("Draft"); } else { MessageBox.Show(client.name + " does not have an address in the system."); } } catch (Exception ex) { MessageBox.Show("Unable to client address"); XLtools.LogException("ClientAddressBtn", ex.ToString()); } }
private static string OurRef(XLMain.Client client, XLMain.Staff sender, XLMain.Staff user) { try { string ourRef = ""; ourRef = client.clientcode; if (client.partner != null) { ourRef += @"/" + client.partner.initials.ToUpper(); } if (client.manager != null) { ourRef += @"/" + client.manager.initials.ToUpper(); } if (sender.crmID == "") { if (sender.name != client.partner.name) { if (sender.name != client.manager.name) { ourRef += @"/" + sender.initials.ToUpper(); } } } if (user.name != client.partner.name) { if (user.name != client.manager.name) { if (user.name != sender.name) { ourRef += @"/" + user.initials.ToLower(); } } } return(ourRef); } catch (Exception ex) { MessageBox.Show("Unable to build reference"); XLtools.LogException("OurRef", ex.ToString()); return(null); } }
public static void IndexPDFCopy(string filestring, string origFileID) { try { //get the info of the original file XLVirtualCabinet.FileInfo fileInfo = XLVirtualCabinet.FileIndex(origFileID); XLVirtualCabinet.BondResult result = XLVirtualCabinet.IndexDocument(filestring, fileInfo); if (result.ExitCode != 0) { MessageBox.Show("Unable to index pdf, please index manually. Error code: " + result.ExitCode.ToString() + "-" + result.StandardOutput.ToString()); } } catch (Exception e) { MessageBox.Show("Unable to index pdf document" + filestring); XLtools.LogException("IndexPDFCopy", e.ToString()); } }
public static string ReadBookmark(string bName) { try { XLDocument.UpdateCurrentDoc(); string bText = ""; if (currentDoc.Bookmarks.Exists(bName)) { Range bRange = currentDoc.Bookmarks.get_Item(bName).Range; bText = bRange.Text; } return(bText); } catch (Exception e) { MessageBox.Show("Unable to read bookmark"); XLtools.LogException("ReadBookmark", e.ToString()); return(null); } }
//########################The following declarations and methods are different in .NET 3.5######################// private void XLantWordRibbon_Load(object sender, RibbonUIEventArgs e) { try { Microsoft.Office.Interop.Word.View currentView = Globals.ThisAddIn.Application.ActiveWindow.View; if (currentView.ShowHiddenText) { ShowHiddenBtn.Checked = true; } else { ShowHiddenBtn.Checked = false; } } catch (Exception ex) { XLtools.LogException("No document loaded", ex.Message); } }
public static string ReadParameter(string pName) { try { XLDocument.UpdateCurrentDoc(); DocumentProperties properties = (DocumentProperties)currentDoc.CustomDocumentProperties; foreach (DocumentProperty prop in properties) { if (prop.Name == pName) { return(prop.Value.ToString()); } } return(null); } catch (Exception e) { MessageBox.Show("Unable to read parameter"); XLtools.LogException("ReadParameter", e.ToString()); return(null); } }
public static List <Header> GetHeaders() { try { List <Header> headings = new List <Header>(); IEnumerable <XElement> xHeadings = settingsDoc.Descendants("Headings"); foreach (XElement xHeading in xHeadings.Descendants("Heading")) { Header header = new Header(xHeading); headings.Add(header); } return(headings); } catch (Exception e) { MessageBox.Show("Unable to load settings file: " + e.ToString()); XLtools.LogException("GetHeader", e.ToString()); return(null); } }
public static List <ListItem> GetList(string type) { try { List <ListItem> items = new List <ListItem>(); //query the setting files and try to find a match IEnumerable <XElement> xItems = (from item in settingsDoc.Descendants(type) select item); foreach (XElement xItem in xItems) { items.Add(new ListItem(xItem.ElementValueNull(), xItem.AttributeValueNull("DbTag"))); } return(items); } catch (Exception e) { MessageBox.Show("Unable to obtain list of type: " + type); XLtools.LogException("GetList", e.ToString()); return(null); } }