//============================================================================= protected override void _Execute(object parameter) { MainWindow_ViewModel vm = parameter as MainWindow_ViewModel; if (vm != null) { // Create OpenFileDialog Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); // Set filter for file extension and default file extension dlg.DefaultExt = ".scad"; dlg.Filter = "SimpleCAD drawings (.scad)|*.scad"; // Display OpenFileDialog by calling ShowDialog method Nullable <bool> result = dlg.ShowDialog(); // Get the selected file name and display in a TextBox if (result == true) { // save or create FileStream fs = new FileStream(dlg.FileName, FileMode.Open); if (fs != null) { BinaryFormatter bf = new BinaryFormatter(); SimpleCAD_State state = (SimpleCAD_State)bf.Deserialize(fs); Document newDoc = vm.DocManager.Add(dlg.FileName, state); if (newDoc != null) { newDoc.IsSelected = true; } } } } }
//============================================================================= protected override void _Execute(object parameter) { MainWindow_ViewModel vm = parameter as MainWindow_ViewModel; if (vm != null) { Document curDoc = vm.DocManager.CurrentDocument; if (curDoc == null) { return; } string strFilePath = string.Empty; if (curDoc.IsItNewDocument) { strFilePath = MainWindow._GetPath(); if (string.IsNullOrEmpty(strFilePath)) { return; } } curDoc.Save(strFilePath); } }
public MainWindow() { InitializeComponent(); m_VM = new MainWindow_ViewModel(this); DataContext = m_VM; this.KeyDown += MainWindow_KeyDown; // add new document on Loaded // Why loaded? - need SimpleCAD control ActualWidth and ActualHeight for correct offset this.Loaded += MainWindow_Loaded; }
//============================================================================= protected override void _Execute(object parameter) { MainWindow_ViewModel vm = parameter as MainWindow_ViewModel; if (vm != null) { Document newDoc = vm.DocManager.Add(new NewDocument(vm.DocManager, vm.SimpleCAD_ActualWidth, vm.SimpleCAD_ActualHeight)); if (newDoc != null) { newDoc.IsSelected = true; } } }
//============================================================================= protected override void _Execute(object parameter) { MainWindow_ViewModel vm = parameter as MainWindow_ViewModel; if (vm != null && vm.DocManager != null) { Document curDoc = vm.DocManager.CurrentDocument; if (curDoc != null) { curDoc.Redo(); } } }
//============================================================================= protected override bool _CanExecute(object parameter) { bool bResult = false; MainWindow_ViewModel vm = parameter as MainWindow_ViewModel; if (vm != null && vm.DocManager != null) { Document curDoc = vm.DocManager.CurrentDocument; if (curDoc != null && curDoc.CanRedo) { bResult = true; } } return(bResult); }