public bool LoadProfile(string filename) { SerializeState serializeState = null; try { serializeState = SerializeState.LoadFromFile(filename); } catch (FileNotFoundException) { MessageBox.Show(string.Format("Unable to find file: \"{0}\"", filename), "Error loading profile", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (InvalidOperationException) { MessageBox.Show(string.Format("An error was encountered while loading profile: \"{0}\"", filename), "Error loading profile", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (serializeState == null) { return(false); } m_ordiTreeView.SerializeInRDIs(serializeState.ORDIs); CalculateMAandLMs(); m_prdiTreeView.SerializeInRDIs(serializeState.PRDIs); m_urdiTreeView.SerializeInRDIs(serializeState.URDIs); m_trdiTreeView.SerializeInRDIs(serializeState.TRDIs); m_zrdiTreeView.SerializeInRDIs(serializeState.ZRDIs); ResetZoneHighlighters(); SerializeInLogViewStates(serializeState); InvalidateGraphControl(); RefreshItemInfoPanel(); return(true); }
void PopulateProfileMenu() { FileInfo exeFileInfo = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location); foreach (FileInfo fi in exeFileInfo.Directory.GetFiles("*.xml")) { // GetFiles wildcard matching has a peculiar behaviour for 3 letter extensions that ends up including .xml~ files if (fi.Extension == ".xml") { try { // check that it's a valid profile xml if (SerializeState.LoadFromFile(fi.FullName) != null) { AddProfileMenuItem(fi); } } catch (Exception) { } } } }