示例#1
0
        private void ToolStripMenuItemClone_Click(object sender, EventArgs e)
        {
            Profile profile = Profiles.Find(x => x.Id == (int)listViewProfile.SelectedItems[0].Tag);

            Profile clonedProfile = profile.Clone();

            clonedProfile.Name = GenerateEnumeratedName(clonedProfile.Name);
            List <Options> clonedOptions = new List <Options>();

            foreach (Options option in DBAccess.ListProfileOptions(profile))
            {
                Options clonedOption = option.Clone();
                clonedOption.Profile = clonedProfile;
                clonedOptions.Add(clonedOption);
            }

            clonedProfile.ListViewIndex = listViewProfile.Items.Count;
            DBAccess.AddProfile(clonedProfile);
            Profiles.Add(clonedProfile);

            foreach (Options clonedOption in clonedOptions)
            {
                DBAccess.AddOption(clonedOption);
            }

            ListViewItem item = new ListViewItem();

            EditListViewItem(clonedProfile, item);
            listViewProfile.Items.Add(item);
            //ResizeForm();
        }
示例#2
0
        //private void LabelMoveOptionUp_Click(object sender, EventArgs args)
        //{
        //    try
        //    {
        //        if (listViewOptions.SelectedItems[0].Index == 0) return;

        //        ListViewItem selectedItem = listViewOptions.SelectedItems[0];
        //        ListViewItem previousItem = listViewOptions.Items[selectedItem.Index - 1];
        //        int selectedItemIndex = selectedItem.Index;
        //        int previousItemIndex = previousItem.Index;

        //        Option selectedOption = null;
        //        Option previousOption = null;

        //        try
        //        {
        //            selectedOption = Options.Find(x => x.Id == (int)selectedItem.Tag);
        //            selectedOption.ListViewIndex = previousItemIndex;
        //            DBAccess.UpdateOptionListViewIndex(selectedOption);

        //            previousOption = Options.Find(x => x.Id == (int)previousItem.Tag);
        //            previousOption.ListViewIndex = selectedItemIndex;
        //            DBAccess.UpdateOptionListViewIndex(previousOption);

        //        }
        //        catch (Exception)
        //        {
        //            try
        //            {
        //                selectedOption.ListViewIndex = selectedItemIndex;
        //                previousOption.ListViewIndex = previousItemIndex;
        //                DBAccess.UpdateOptionListViewIndex(selectedOption);
        //                DBAccess.UpdateOptionListViewIndex(previousOption);
        //            }
        //            catch (Exception) { }
        //            throw;
        //        }

        //        ListViewItem selectedItemClone = (ListViewItem)selectedItem.Clone();
        //        ListViewItem previousItemClone = (ListViewItem)previousItem.Clone();

        //        listViewOptions.Items[selectedItemIndex] = previousItemClone;
        //        listViewOptions.Items[previousItemIndex] = selectedItemClone;

        //        listViewOptions.Items[previousItemIndex].Selected = true;
        //    }
        //    catch (ArgumentOutOfRangeException) { }
        //    catch (Exception e) {
        //        MessageBox.Show(e.Message);
        //    }
        //}

        //private void LabelMoveOptionDown_Click(object sender, EventArgs args)
        //{
        //    try
        //    {
        //        if (listViewOptions.SelectedItems[0].Index == listViewOptions.Items.Count - 1) return;

        //        ListViewItem selectedItem = listViewOptions.SelectedItems[0];
        //        ListViewItem nextItem = listViewOptions.Items[selectedItem.Index + 1];
        //        int selectedItemIndex = selectedItem.Index;
        //        int nextItemIndex = nextItem.Index;

        //        Option selectedOption = null;
        //        Option nextOption = null;

        //        try
        //        {
        //            selectedOption = Options.Find(x => x.Id == int.Parse(selectedItem.Tag.ToString()));
        //            selectedOption.ListViewIndex = nextItemIndex;
        //            DBAccess.UpdateOptionListViewIndex(selectedOption);

        //            nextOption = Options.Find(x => x.Id == int.Parse(nextItem.Tag.ToString()));
        //            nextOption.ListViewIndex = selectedItemIndex;
        //            DBAccess.UpdateOptionListViewIndex(nextOption);
        //        }
        //        catch (Exception)
        //        {
        //            try
        //            {
        //                selectedOption.ListViewIndex = selectedItemIndex;
        //                nextOption.ListViewIndex = nextItemIndex;
        //                DBAccess.UpdateOptionListViewIndex(selectedOption);
        //                DBAccess.UpdateOptionListViewIndex(nextOption);
        //            }
        //            }
        //            catch (Exception) {}
        //            throw;
        //        }

        //        ListViewItem selectedItemClone = (ListViewItem)selectedItem.Clone();
        //        ListViewItem nextItemClone = (ListViewItem)nextItem.Clone();

        //        listViewOptions.Items[selectedItemIndex] = nextItemClone;
        //        listViewOptions.Items[nextItemIndex] = selectedItemClone;

        //        listViewOptions.Items[nextItemIndex].Selected = true;
        //    }
        //    catch (ArgumentOutOfRangeException) {}
        //    catch (Exception e)
        //    {
        //        MessageBox.Show(e.Message);
        //    }
        //}

        private void CloneOptionToolStripMenuItem_Click(object sender, EventArgs args)
        {
            try
            {
                Options selectedOption = Options.Find(o => o.Id == (int)listViewOptions.SelectedItems[0].Tag);

                Options clonedOption = selectedOption.Clone();
                clonedOption.ListViewIndex = listViewOptions.Items.Count;
                DBAccess.AddOption(clonedOption);
                Options.Add(clonedOption);
                Program.UpdateLastTimeModified(Profile);
                ListViewItem item = new ListViewItem();
                EditListViewItem(clonedOption, item);
                listViewOptions.Items.Add(item);
                //ResizeForm();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
示例#3
0
        private void SubmitChanges()
        {
            try
            {
                Options editedOption = new Options();
                SaveFieldsToObject(editedOption);
                if (!InputsAreValid(editedOption))
                {
                    return;
                }

                if (FormAction == FormAction.CREATE)
                {
                    editedOption.Profile       = OptionsMenu.Profile;
                    editedOption.ListViewIndex = OptionsMenu.listViewOptions.Items.Count;
                    DBAccess.AddOption(editedOption);
                    OptionsMenu.Options.Add(editedOption);
                    Program.UpdateLastTimeModified(editedOption.Profile);
                    ListViewItem item = new ListViewItem();
                    OptionsMenu.EditListViewItem(editedOption, item);
                    OptionsMenu.listViewOptions.Items.Add(item);
                    //OptionsMenu.ResizeForm();
                }
                else
                {
                    if (
                        !(
                            Option.SourcePath == editedOption.SourcePath &&
                            Option.DestinyPath == editedOption.DestinyPath &&
                            Option.FileNameConflictMethod == editedOption.FileNameConflictMethod &&
                            Option.SpecifiedFileNamesOrExtensionsMode == editedOption.SpecifiedFileNamesOrExtensionsMode &&
                            Option.IncludeSubFolders == editedOption.IncludeSubFolders &&
                            Option.KeepOriginFiles == editedOption.KeepOriginFiles &&
                            Option.CleanDestinyDirectory == editedOption.CleanDestinyDirectory &&
                            Option.DeleteUncommonFiles == editedOption.DeleteUncommonFiles &&
                            Option.AllowIgnoreFileExt == editedOption.AllowIgnoreFileExt &&
                            ExtensionsAreTheSame(Option.SpecifiedFileNamesAndExtensions, editedOption.SpecifiedFileNamesAndExtensions) &&
                            Option.ReenumerateRenamedFiles == editedOption.ReenumerateRenamedFiles &&
                            Option.MaxKeptRenamedFileCount == editedOption.MaxKeptRenamedFileCount
                            )
                        )
                    {
                        Option.SourcePath                         = editedOption.SourcePath;
                        Option.DestinyPath                        = editedOption.DestinyPath;
                        Option.FileNameConflictMethod             = editedOption.FileNameConflictMethod;
                        Option.SpecifiedFileNamesOrExtensionsMode = editedOption.SpecifiedFileNamesOrExtensionsMode;
                        Option.IncludeSubFolders                  = editedOption.IncludeSubFolders;
                        Option.KeepOriginFiles                    = editedOption.KeepOriginFiles;
                        Option.CleanDestinyDirectory              = editedOption.CleanDestinyDirectory;
                        Option.DeleteUncommonFiles                = editedOption.DeleteUncommonFiles;
                        Option.AllowIgnoreFileExt                 = editedOption.AllowIgnoreFileExt;
                        Option.SpecifiedFileNamesAndExtensions    = editedOption.SpecifiedFileNamesAndExtensions;
                        Option.ReenumerateRenamedFiles            = editedOption.ReenumerateRenamedFiles;
                        Option.MaxKeptRenamedFileCount            = editedOption.MaxKeptRenamedFileCount;

                        DBAccess.UpdateOption(Option);
                        Program.UpdateLastTimeModified(Option.Profile);
                        OptionsMenu.EditListViewItem(Option);
                    }
                }

                DialogResult = DialogResult.Cancel;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }