private void MenuItem_Open_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog() == DialogResult.OK) { IImportPlugin importer = Host.ImportPlugins[openFileDialog.FilterIndex - 1]; Host.OpenEdit(importer, openFileDialog.FileName); } else { return; } }
private void ListExtensionRules_SelectedIndexChanged(object sender, EventArgs e) { if (listExtensionRules.SelectedIndices.Count > 0) { SelectedRule = listExtensionRules.Items[listExtensionRules.SelectedIndices[0]].Tag as ExtensionRule; textExtension.Text = SelectedRule.Extension; IsSelected = true; IImportPlugin plugin = Host.ImportPlugins.Find(i => i.Guid == SelectedRule.ImporterGuid); if (plugin != null) { comboImpoetPlugins.SelectedItem = plugin; } } else { textExtension.Text = null; } }
public void OpenEdit(History history) { if (history == null) { throw new ArgumentNullException(nameof(history)); } IImportPlugin importer = GetPlugin(history.ImporterGuid) as IImportPlugin; if (importer == null) { if (MessageBox.Show(string.Format(Properties.Resources.Msg_ImporterNotFoundQuestion, history.FullName), Properties.Resources.Open, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { OpenEdit(history.FullName, false); } return; } OpenEdit(importer, history.FullName); }
public void OpenEdit(IImportPlugin importer, string fileName) { if (!File.Exists(fileName)) { MessageBox.Show(string.Format(Properties.Resources.Msg_FileDoesNotExist, fileName), Properties.Resources.Open, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } try { ObjectEdit edit = new ObjectEdit(importer, fileName); if (_SingletonMode) { ((MainForm)MainForm).ActivateEdit(edit); } InsertHistory(new History(edit.FileName, edit.Importer.Guid, edit.Importer.Image?.GetThumbnail(16, 16), DateTime.Now)); } catch (Exception e) { MessageBox.Show(e.Message, Properties.Resources.Open, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public ObjectEdit(IImportPlugin importer, string fileName) { Importer = importer ?? throw new ArgumentNullException(nameof(importer)); FileName = fileName ?? throw new ArgumentNullException(nameof(fileName)); Import(FileStatus.Opened); }