コード例 #1
0
ファイル: OpenCommand.cs プロジェクト: ozalpd/IconFitter
        public override void Execute(object parameter)
        {
            var openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = Files.GetFilter(FileType);

            if (openFileDialog.ShowDialog() != true)
            {
                return;
            }

            switch (FileType)
            {
            case FileType.ImageFile:
                ViewModel.ImageFile = new ImageFileInfo(openFileDialog.FileName);
                break;

            case FileType.ResizeWorkSet:
                var workSet = ResizeWorkSet.OpenFromFile(openFileDialog.FileName);
                ViewModel.RecentResizeSetFile = openFileDialog.FileName;
                ViewModel.ResizeWorks         = new ObservableCollection <ResizeWork>(workSet);
                break;

            default:
                break;
            }
        }
コード例 #2
0
        public override void Execute(object parameter)
        {
            var workSet = new ResizeWorkSet();

            workSet.TargetDirectory = ViewModel.TargetDirectory;
            foreach (var resize in ViewModel.ResizeWorks)
            {
                var clone = resize.Clone();
                if (string.IsNullOrEmpty(clone.TargetFileName))
                {
                    clone.TargetFileName = ViewModel.GetResizeFileName(clone);
                }

                workSet.Add(clone);
            }
            workSet.Execute(ImageFile);
        }
コード例 #3
0
        public override void Execute(object parameter)
        {
            if (string.IsNullOrEmpty(ViewModel.RecentResizeSetFile))
            {
                var openFileDialog = new SaveFileDialog()
                {
                    DefaultExt = Files.GetExtension(FileType.ResizeWorkSet),
                    Filter     = Files.GetFilter(FileType.ResizeWorkSet)
                };
                if (openFileDialog.ShowDialog() != true)
                {
                    return;
                }

                ViewModel.RecentResizeSetFile = openFileDialog.FileName;
            }

            var workSet = new ResizeWorkSet();

            workSet.AddRange(ViewModel.ResizeWorks);
            workSet.SaveToFile(ViewModel.RecentResizeSetFile);
        }