Exemple #1
0
        public ImagesToVideoDialog(Window owner, IEnumerable <MediaItemM> items, OnSuccess onSuccess)
        {
            InitializeComponent();

            _items = items.ToArray();
            var firstMi  = _items.First();
            var fileName = IOExtensions.GetNewFileName(firstMi.Folder.FullPath, firstMi.FileName + ".mp4");

            Owner           = owner;
            _inputListPath  = Path.GetTempPath() + "PictureManagerImagesToVideo.list";
            _outputFilePath = IOExtensions.PathCombine(firstMi.Folder.FullPath, fileName);
            _outputFileName = fileName;
            _outputFolder   = firstMi.Folder;
            _onSuccess      = onSuccess;
        }
        private async void Rename()
        {
            var inputDialog = new InputDialog {
                Owner    = App.WMain,
                IconName = "IconNotification",
                Title    = "Rename",
                Question = "Add a new name.",
                Answer   = Path.GetFileNameWithoutExtension(Model.Current.FileName)
            };

            inputDialog.BtnDialogOk.Click += delegate {
                var newFileName = inputDialog.TxtAnswer.Text + Path.GetExtension(Model.Current.FileName);

                if (Path.GetInvalidFileNameChars().Any(x => newFileName.IndexOf(x) != -1))
                {
                    inputDialog.ShowErrorMessage("New file name contains invalid character!");
                    return;
                }

                if (File.Exists(IOExtensions.PathCombine(Model.Current.Folder.FullPath, newFileName)))
                {
                    inputDialog.ShowErrorMessage("New file name already exists!");
                    return;
                }

                inputDialog.DialogResult = true;
            };

            inputDialog.TxtAnswer.SelectAll();

            if (!(inputDialog.ShowDialog() ?? true))
            {
                return;
            }

            try {
                Model.Rename(Model.Current, inputDialog.TxtAnswer.Text + Path.GetExtension(Model.Current.FileName));
                _core.ThumbnailsGridsM.Current?.FilteredItemsSetInPlace(Model.Current);
                await _coreVM.ThumbnailsGridsVM.ThumbsGridReloadItems();

                _coreVM.StatusPanelVM.CurrentMediaItemM = Model.Current;
            }
            catch (Exception ex) {
                _core.LogError(ex);
            }
        }