public MainViewModel() { #region File Dialogs _ofd = new OpenFileDialog { CheckFileExists = true, CheckPathExists = true, Multiselect = true, ValidateNames = true, Title = "Select Image Files", Filter = "Image Files|*.bmp;*.emf;*.exif;*.jpeg;*.jpg;*.png;*.tiff;*.wmf|All Files|*.*" }; _sfd = new SaveFileDialog { Title = "Destination", ValidateNames = true, AddExtension = true, DefaultExt = ".ico", Filter = "Icon|*.ico" }; _efd = new SaveFileDialog { Title = "Export to", ValidateNames = true, AddExtension = true, DefaultExt = ".png", Filter = "Portable Network Graphics|*.png|Jpeg|*.jpg|Bitmap|*.bmp|Tiff|*.tiff|Windows Metafile|*.wmf|Exif|*.exif|Graphics Interchange Format|*.gif|Icon|*.ico|Enchanced Metafile|*.emf" }; #endregion #region Commands AddCommand = new DelegateCommand(() => { if (_ofd.ShowDialog().Value) { //Task.Factory.StartNew(() => { foreach (var fileName in _ofd.FileNames) Add(fileName, 256); }//); } }); CopyCommand = new DelegateCommand(OnCopy, () => SelectedFrame != null); CutCommand = new DelegateCommand(() => { OnCopy(); IconFrames.Remove(SelectedFrame); }, () => SelectedFrame != null); DeleteCommand = new DelegateCommand(() => { var selectedItems = new FrameViewModel[SelectedFrames.Count]; SelectedFrames.CopyTo(selectedItems, 0); foreach (var item in selectedItems) IconFrames.Remove(item); }, () => SelectedFrame != null); DecreaseZoomCommand = new DelegateCommand(() => Zoom -= 0.1, () => SelectedFrame != null); ExportCommand = new DelegateCommand(() => { if (_efd.ShowDialog().Value) SelectedFrame.Bitmap.Save(_efd.FileName, _imageFormats[_efd.FilterIndex - 1]); }, () => SelectedFrame != null); FolderIconCommand = new DelegateCommand(ExtractFolderIcon); IncreaseZoomCommand = new DelegateCommand(() => Zoom += 0.1, () => SelectedFrame != null); MakeCursorCommand = new DelegateCommand(MakeCursor, () => SelectedFrame != null); OpenCommand = new DelegateCommand(OnOpen); PasteCommand = new DelegateCommand(AddFromClipboard, () => Clipboard.ContainsData("PNG") || Clipboard.ContainsImage()); SaveCommand = new DelegateCommand(Save, () => IconFrames.Count != 0); SelectAllCommand = new DelegateCommand(() => { SelectedFrames.Clear(); foreach (var frame in IconFrames) SelectedFrames.Add(frame); }, () => IconFrames.Count != 0); #endregion }
public void Add(string FilePath, int Size, bool Dispose = false) { var frame = new FrameViewModel(FilePath, Size, Dispose); IconFrames.Add(frame); if (IconFrames.Count == 1) SelectedFrame = frame; }