Exemple #1
0
 private void button_import_file_Click(object sender, EventArgs e)
 {
     if (importFileDialog.ShowDialog() == DialogResult.OK)
     {
         button_import_file.Enabled = false;
         var files      = importFileDialog.FileNames;
         var processing = new ProcessingDialog(0, files.Length);
         new Thread(new ThreadStart(() =>
         {
             var failed = "";
             foreach (string file in files)
             {
                 var key = Path.GetFileNameWithoutExtension(file);
                 if (listView1.Items.ContainsKey(key) && MessageBox.Show("Audio name \"" + Path.GetFileNameWithoutExtension(file) + "\" already exists,continue and override it?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                 {
                     continue;
                 }
                 listView1.Items.RemoveByKey(key);
                 File.Delete(getGameConfigPath(file) + ".original");
                 if (convertNewMedia(file))
                 {
                     listView1.Items.Add(key, key, 0).SubItems.AddRange(new string[]
                     {
                         "", "100", listView1.Items.Count.ToString(), "", ""
                     });
                 }
                 else
                 {
                     failed += "\n" + file;
                 }
                 processing.update();
             }
             processing.update();
             saveTracks();
             button_import_file.Enabled = true;
             MessageBox.Show("Processed " + files.Length + " file(s)." + (failed == "" ? "" : "\n\nFollowing file(s) convert failed:" + failed), "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
         })).Start();
         processing.ShowDialog();
     }
 }
Exemple #2
0
        public void Run()
        {
            ProcessingDialog dlg = null;

            Action verify = () =>
            {
                foreach (ITableChecker checker in m_checkers)
                {
                    dlg.Message = $"Vérification de la table {AppContext.TableManager.GetTable(checker.TableID).Name}";
                    checker.Check();
                    checker.Dispose();
                }
            };

            Action <Task> onErr = t =>
            {
                dlg.ShowError(t.Exception.InnerException.Message);
                //Dispose();
                dlg.Close();
            };

            Action onSuccess = () =>
            {
                //Dispose();
                dlg.Close();
            };

            using (dlg = new ProcessingDialog())
            {
                var task = new Task(verify);
                task.OnError(onErr);
                task.OnSuccess(onSuccess);

                task.Start();
                dlg.ShowDialog();
            }
        }
Exemple #3
0
        public MainForm()
        {
            instance = this;
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;

            #region Right Click Menu

            var menu = new ContextMenu();
            menu_play = menu.MenuItems.Add("Play", (sender, e) =>
            {
                var path = getGameConfigPath(listView1.SelectedItems[0].Text, false);
                MusicPlayForm.getInstance(path + (File.Exists(path + ".modified") ? ".modified" : ".original")).Show();
                MusicPlayForm.player.Play();
            });
            menu_edit = menu.MenuItems.Add("Edit", new MenuItem[]
            {
                menu_trim = new MenuItem("Trim", (sender, e) =>
                {
                    var dialog = new TrimDialog();
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        // TODO.
                    }
                }),
                menu_volume = new MenuItem("Adjust Volume", (sender, e) =>
                {
                    var dialog = new AdjustVolumeDialog();
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        var items      = listView1.SelectedItems;
                        var processing = new ProcessingDialog(0, items.Count);
                        new Thread(new ThreadStart(() =>
                        {
                            int result = dialog.Result;
                            var failed = "";
                            foreach (ListViewItem item in items)
                            {
                                item.SubItems[2].Text = result.ToString();
                                if (!reConvertModifiedMedia(item))
                                {
                                    failed += "\n" + item.Text;
                                    item.SubItems[2].Text = "100";
                                    File.Delete(getGameConfigPath(item.Text, false) + ".modified");
                                }
                                processing.update();
                            }
                            processing.update();
                            saveTracks();
                            MessageBox.Show("Processed " + items.Count + " file(s)." + (failed == "" ? "" : "\n\nFollowing file(s) process failed:" + failed), "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        })).Start();
                        processing.ShowDialog();
                    }
                })
            });
            menu_alias = menu.MenuItems.Add("Set Alias", (sender, e) =>
            {
                listView1_MouseDoubleClick();
            });
            menu_remove = menu.MenuItems.Add("Remove", (sender, e) =>
            {
                if (!Running && listView1.SelectedItems.Count != 0)
                {
                    foreach (ListViewItem item in listView1.SelectedItems)
                    {
                        listView1.Items.Remove(item);
                        var path = getGameConfigPath(item.Text, false);
                        File.Delete(path + ".original");
                        File.Delete(path + ".modified");
                    }
                    for (int i = 0; i < listView1.Items.Count; i++)
                    {
                        listView1.Items[i].SubItems[3].Text = (i + 1).ToString();
                    }
                    saveTracks();
                }
            });
            menu.Popup += (sender, e) =>
            {
                if (listView1.SelectedItems.Count == 0)
                {
                    menu_play.Visible = menu_alias.Visible = menu_edit.Visible = menu_remove.Visible = false;
                }
                else
                {
                    menu_edit.Visible = menu_remove.Visible = true;
                    menu_play.Visible = menu_alias.Visible = menu_trim.Visible = listView1.SelectedItems.Count == 1;
                }
            };
            listView1.ContextMenu = menu;

            #endregion
        }