コード例 #1
0
ファイル: Controller.cs プロジェクト: andreigec/Folder-View
        public static bool Errorcontinue(String error)
        {
            var options = new List <string> {
                "Yes", "No"
            };
            var MMB = new ANDREICSLIB.NewControls.MultipleMessageBox("Continue?",
                                                                     "Error:\n" + error + "\nDo you wish to continue?", options);

            MMB.ShowDialog();
            return(MMB.Result.Equals("Yes"));
        }
コード例 #2
0
        public static void DropInFiles(string[] files, ListView fileList)
        {
            var acceptall = false;
            var nochanges = false;
            const string YTA = "Yes To All";
            const string nostr = "No";
            const string noallstr = "No To All";
            const string yesstr = "Yes";
            const string cancelstr = "Cancel";

            var l = new List<string>();
            l.Add(YTA);
            l.Add(yesstr);
            l.Add(nostr);
            l.Add(noallstr);
            l.Add(cancelstr);

            foreach (var s in files)
            {
                var LVI = initLVI(fileList);
                LVI.Text = fileList.Items.Count.ToString();
                LVI.Name = LVI.Text;
                LVI.SubItems.Add(s);

                Mp3File mf = null;

                var retrycount = 0;
                var retrymax = 10;
                retry:

                try
                {
                    mf = new Mp3File(s);
                }
                catch (Exception exp)
                {
                    retrycount++;
                    if (retrycount >= retrymax)
                    {
                        MessageBox.Show("Error opening file:" + exp.ToString());

                        var DR = MessageBox.Show("Do you want to continue?", "option", MessageBoxButtons.YesNo);
                        if (DR == DialogResult.No)
                            return;

                        continue;
                    }

                    //for a certain period, retry
                    Thread.Sleep(100);
                    goto retry;
                }

                LVI.Tag = mf;
                var sas = mf.Audio;
                sas.ScanWholeFile();

                //clean files on entry
                var newData = new changes.TagHandlerUpdate(mf);

                if (nochanges == false)
                {
                    Music_File_Info_Editor.changes.cleanMP3(newData);

                    var changes = Music_File_Info_Editor.changes.areThereDifferences(mf, newData);
                    var makechanges = true;
                    if (changes && acceptall == false)
                    {
                        var tt = "The file:" + mf.FileName +
                                    " has a title/album/artist with blank characters at the start or end, or has multiple white space. Do you wish to fix these?";
                        var MMB = new MultipleMessageBox("option", tt, l);
                        MMB.ShowDialog();

                        if (MMB.IsSet == false)
                            return;

                        switch (MMB.Result)
                        {
                            case cancelstr:
                                return;

                            case nostr:
                                makechanges = false;
                                break;

                            case YTA:
                                acceptall = true;
                                break;

                            case noallstr:
                                makechanges = false;
                                nochanges = true;
                                break;
                        }
                    }

                    if (makechanges)
                    {
                        if (Music_File_Info_Editor.changes.makeChangesAndContinue(newData, mf) == false)
                            return;
                    }
                }

                //only add if the name isnt there already
                var add = true;
                foreach (ListViewItem tt in fileList.Items)
                {
                    var s1 = tt.SubItems[ListViewExtras.GetColumnNumber(fileList, "Path")].Text;

                    if (s1.Equals(mf.FileName))
                    {
                        add = false;
                        break;
                    }
                }

                if (add)
                    fileList.Items.Add(LVI);
            }

            RefreshInfo(fileList);
            ListViewExtras.AutoResize(fileList);
        }
コード例 #3
0
        public static void EditIngredientCategory()
        {
            const string cr = "Create";
            const string ren = "Rename";
            const string del = "Delete";
            const string canc = "Cancel";
            //get options type

            var ls = new List<string>();
            ls.Add(cr);
            ls.Add(ren);
            ls.Add(del);
            ls.Add(canc);

            var mmb = new MultipleMessageBox("Edit Category", "Choose Mode", ls);
            mmb.ShowDialog();

            if (mmb.IsSet == false || mmb.Result == canc)
                return;

            var cats = Data.IngredientCategories.Select(s2 => s2.ToSelectItem()).ToList();

            if (mmb.Result.Equals(cr))
            {
                var gsb = new GetStringBox();
                var res = gsb.ShowDialog("Enter Category Name to create:", "Edit Category");
                if (string.IsNullOrWhiteSpace(res))
                    return;
                if (Data.IngredientCategories.Any(s => s.Name == res))
                {
                    MessageBox.Show("Error, a category with that name already exists");
                    return;
                }

                Data.IngredientCategories.Add(new IngredientCategory(res));
            }

            else if (mmb.Result.Equals(ren))
            {
                var res = SelectItemFromListBox.ShowDialog("Select category to rename", "Rename Category", cats, false,
                    1);
                if (res == null)
                    return;

                var rename = new GetStringBox();
                var res2 = rename.ShowDialog("Enter new category name", "Rename Category");

                if (string.IsNullOrWhiteSpace(res2))
                    return;

                if (Data.IngredientCategories.Any(s => s.Name == res2))
                {
                    MessageBox.Show("Error, a category with that name already exists");
                    return;
                }

                try
                {
                    var cat = Data.IngredientCategories.First(s => s.Name == res.First());
                    cat.Name = res2;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error occured:" + ex);
                    return;
                }
            }

            else if (mmb.Result.Equals(del))
            {
                var res = SelectItemFromListBox.ShowDialog("Select category to delete", "Delete Category", cats, true, 1);
                if (res == null)
                    return;

                foreach (var cat in res)
                {
                    var cat1 = Data.IngredientCategories.First(s => s.Name == cat);
                    Data.RemoveIngredientCategory(cat1);
                }
            }

            UpdateFormFromData(true);
        }
コード例 #4
0
ファイル: Controller.cs プロジェクト: andreigec/Folder-View
 public static bool Errorcontinue(String error)
 {
     var options = new List<string> { "Yes", "No" };
     var MMB = new ANDREICSLIB.NewControls.MultipleMessageBox("Continue?",
                                      "Error:\n" + error + "\nDo you wish to continue?", options);
     MMB.ShowDialog();
     return MMB.Result.Equals("Yes");
 }