Ejemplo n.º 1
0
        public void EditCollection(CollectionEditArgs e)
        {
            if (e.Action == CollectionEdit.Rename || e.Action == CollectionEdit.Add)
            {
                bool isRenameform = e.Action == CollectionEdit.Rename;

                var newCollectionName = _collectionAddRenameForm
                                        .GetCollectionName(IsCollectionNameValid, e.OrginalName, isRenameform);

                if (newCollectionName == "")
                {
                    return;
                }
                if (e.Action == CollectionEdit.Rename)
                {
                    e = CollectionEditArgs.RenameCollection(e.OrginalName, newCollectionName);
                }
                else
                {
                    e = CollectionEditArgs.AddCollections(new Collections()
                    {
                        new Collection(_mapCacher)
                        {
                            Name = newCollectionName
                        }
                    });
                }
            }

            _collectionEditor.EditCollection(e);
        }
Ejemplo n.º 2
0
        private void _view_RightClick(object sender, Gui.Misc.StringEventArgs e)
        {
            var selectedCollections = _model.SelectedCollections;
            CollectionEditArgs args;

            switch (e.Value)
            {
            case "Delete":
                if (selectedCollections == null)
                {
                    return;
                }
                args = CollectionEditArgs.RemoveCollections(selectedCollections);
                break;

            case "Merge":
                if (selectedCollections == null)
                {
                    return;
                }
                args = CollectionEditArgs.MergeCollections(selectedCollections, selectedCollections[0].Name);
                break;

            case "Intersect":
                if (selectedCollections == null)
                {
                    return;
                }
                args = CollectionEditArgs.IntersectCollections(selectedCollections, selectedCollections[0].Name);
                break;

            case "Create":
                args = CollectionEditArgs.AddCollections(null);
                break;

            case "Rename":
                if (_view.SelectedCollection == null)
                {
                    return;
                }
                args = CollectionEditArgs.RenameCollection(_view.SelectedCollection, null);
                break;

            case "Duplicate":
                if (_view.SelectedCollection == null)
                {
                    return;
                }

                args = CollectionEditArgs.DuplicateCollection(_view.SelectedCollection);
                break;

            default:
                return;
            }

            _model.EmitCollectionEditing(args);
        }
        public void EditCollection(CollectionEditArgs e)
        {
            if (e.Action == CollectionEdit.Rename || e.Action == CollectionEdit.Add)
            {
                bool isRenameform = e.Action == CollectionEdit.Rename;

                var newCollectionName = _collectionAddRenameForm
                                        .GetCollectionName(IsCollectionNameValid, e.OrginalName, isRenameform);

                if (newCollectionName == "")
                {
                    return;
                }
                switch (e.Action)
                {
                case CollectionEdit.Rename:
                    e = CollectionEditArgs.RenameCollection(e.OrginalName, newCollectionName);
                    break;

                case CollectionEdit.Add:
                    e = CollectionEditArgs.AddCollections(new Collections()
                    {
                        new Collection(_mapCacher)
                        {
                            Name = newCollectionName
                        }
                    });
                    break;
                }
            }

            if (e.Action == CollectionEdit.Duplicate)
            {
                var newCollection = new Collection(_mapCacher)
                {
                    Name = GetValidCollectionName(e.OrginalName)
                };

                _collectionEditor.EditCollection(
                    CollectionEditArgs.AddCollections(new Collections()
                {
                    newCollection
                })
                    );

                var beatmaps = new Beatmaps();
                beatmaps.AddRange(e.Collections[0].AllBeatmaps());

                e = CollectionEditArgs.AddBeatmaps(newCollection.Name, beatmaps);
            }

            _collectionEditor.EditCollection(e);
        }
        private void _view_RightClick(object sender, Gui.Misc.StringEventArgs e)
        {
            var selectedCollections = _model.SelectedCollections;
            CollectionEditArgs args;

            switch (e.Value)
            {
            case "Delete":
                if (selectedCollections == null)
                {
                    return;
                }
                args = CollectionEditArgs.RemoveCollections(selectedCollections);
                break;

            case "Merge":
                if (selectedCollections == null)
                {
                    return;
                }
                args = CollectionEditArgs.MergeCollections(selectedCollections, selectedCollections[0].Name);
                break;

            case "Intersect":
                if (selectedCollections == null)
                {
                    return;
                }
                args = CollectionEditArgs.IntersectCollections(selectedCollections, selectedCollections[0].Name);
                break;

            case "Inverse":
                if (selectedCollections == null)
                {
                    return;
                }
                args = CollectionEditArgs.InverseCollections(selectedCollections, selectedCollections[0].Name);
                break;

            case "Difference":
                if (selectedCollections == null)
                {
                    return;
                }
                args = CollectionEditArgs.DifferenceCollections(selectedCollections, selectedCollections[0].Name);
                break;

            case "Create":
                args = CollectionEditArgs.AddCollections(null);
                break;

            case "Rename":
                if (_view.SelectedCollection == null)
                {
                    return;
                }
                args = CollectionEditArgs.RenameCollection(_view.SelectedCollection, null);
                break;

            case "Duplicate":
                if (_view.SelectedCollection == null)
                {
                    return;
                }

                args = CollectionEditArgs.DuplicateCollection(_view.SelectedCollection);
                break;

            case "Export":
                if (selectedCollections == null)
                {
                    return;
                }

                args = CollectionEditArgsExtension.ExportBeatmaps(selectedCollections);
                break;

            case "Copy":
                if (selectedCollections == null)
                {
                    return;
                }
                var tempFolder = Path.Combine(Path.GetTempPath(), "CMcollections");
                if (Directory.Exists(tempFolder))
                {
                    Directory.Delete(tempFolder, true);
                }

                Directory.CreateDirectory(tempFolder);
                var fileName     = Helpers.StripInvalidFileNameCharacters(selectedCollections[0].Name, "_");
                var tempLocation = Path.Combine(tempFolder, $"{fileName}.osdb");
                Initalizer.OsuFileIo.CollectionLoader.SaveOsdbCollection(selectedCollections, tempLocation);
                Clipboard.SetFileDropList(new StringCollection {
                    tempLocation
                });
                return;

            default:
                return;
            }

            _model.EmitCollectionEditing(args);
        }