示例#1
0
        //=============================================================================
        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;
                        }
                    }
                }
            }
        }
示例#2
0
        //=============================================================================
        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);
            }
        }
示例#3
0
        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;
        }
示例#4
0
        //=============================================================================
        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;
                }
            }
        }
示例#5
0
        //=============================================================================
        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();
                }
            }
        }
示例#6
0
        //=============================================================================
        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);
        }