private void mnuOpenConnection_Click(object sender, EventArgs e) { this.ofdConnection.Filter = MimeTypesHelper.GetFilenameFilter(true, false, false, false, false, false); if (this.ofdConnection.ShowDialog() == DialogResult.OK) { try { IGraph cs = new Graph(); cs.LoadFromFile(this.ofdConnection.FileName); IConnectionsGraph connections = new ConnectionsGraph(cs, this.ofdConnection.FileName); OpenConnectionForm openConnections = new OpenConnectionForm(connections); openConnections.MdiParent = this; if (openConnections.ShowDialog() == DialogResult.OK) { Connection connection = openConnections.Connection; ShowStoreManagerForm(connection); } } catch (RdfParseException) { MessageBox.Show(Resources.OpenConnection_InvalidFile_Text, Resources.OpenConnection_Error_Title, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(string.Format(Resources.OpenConnection_Error_Text, ex.Message), Resources.OpenConnection_Error_Title, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void mnuSaveConnection_Click(object sender, EventArgs e) { if (this.ActiveMdiChild != null) { if (this.ActiveMdiChild is StoreManagerForm) { try { Connection connection = ((StoreManagerForm)this.ActiveMdiChild).Connection; this.sfdConnection.Filter = MimeTypesHelper.GetFilenameFilter(true, false, false, false, false, false); if (this.sfdConnection.ShowDialog() == DialogResult.OK) { //Append to existing configuration file or overwrite? IGraph cs = new Graph(); if (File.Exists(this.sfdConnection.FileName)) { DialogResult result = MessageBox.Show(Resources.SaveConnection_Append_Text, Resources.SaveConnection_Append_Title, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (result) { case DialogResult.Yes: // Load in existing connections cs.LoadFromFile(this.sfdConnection.FileName); break; case DialogResult.No: File.Delete(this.sfdConnection.FileName); break; default: return; } } // Open the connections file and add to it which automatically causes it to be saved IConnectionsGraph connections = new ConnectionsGraph(cs, this.sfdConnection.FileName); connections.Add(connection); } } catch (Exception ex) { Program.HandleInternalError(Resources.SaveConnection_Error, ex); } } else { this.mnuSaveConnection.Enabled = false; } } else { this.mnuSaveConnection.Enabled = false; } }