예제 #1
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Create dialog
            using (NewTagGroupDialog groupDialog = new NewTagGroupDialog())
            {
                //Show
                if (groupDialog.ShowDialog() == DialogResult.OK)
                {
                    //Create file
                    AbideTagGroupFile file = new AbideTagGroupFile()
                    {
                        TagGroup = groupDialog.SelectedGroup
                    };

                    //Get name
                    string tagName = "tag"; int tagIndex = 1;
                    while (openEditors.ContainsKey($"{tagName}{tagIndex}"))
                    {
                        tagIndex++;
                    }

                    //Create editor
                    TagGroupFileEditor editor = new TagGroupFileEditor($"{tagName}{tagIndex}.{file.TagGroup.GroupName}", file)
                    {
                        MdiParent = this
                    };
                    editor.FileNameChanged += Editor_FileNameChanged;
                    editor.FormClosed      += Editor_FormClosed;

                    //Show
                    editor.Show();
                }
            }
        }
예제 #2
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Prepare
            AbideTagGroupFile file = null;

            //Initialize
            using (OpenFileDialog openDlg = new OpenFileDialog())
            {
                //Setup
                openDlg.Filter = "All files (*.*)|*.*";
                openDlg.CustomPlaces.Add(new FileDialogCustomPlace(RegistrySettings.WorkspaceDirectory));

                //Show
                if (openDlg.ShowDialog() == DialogResult.OK)
                {
                    //Check
                    if (openEditors.ContainsKey(openDlg.FileName))
                    {
                        openEditors[openDlg.FileName].Show();
                    }
#if DEBUG
                    //Load file
                    file = new AbideTagGroupFile();
                    file.Load(openDlg.FileName);
#else
                    try
                    {
                        using (Stream stream = openDlg.OpenFile())
                        {
                            //Load file
                            file = new AbideTagGroupFile();
                            file.Load(stream);
                        }
                    }
                    catch { file = null; MessageBox.Show($"An error occured while opening {openDlg.FileName}.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); }
#endif

                    //Check
                    if (file != null)
                    {
                        //Create editor
                        TagGroupFileEditor editor = new TagGroupFileEditor(openDlg.FileName, file)
                        {
                            MdiParent = this
                        };
                        editor.FileNameChanged += Editor_FileNameChanged;
                        editor.FormClosed      += Editor_FormClosed;

                        //Show
                        editor.Show();
                    }
                }
            }
        }