Exemplo n.º 1
0
        /// <summary>
        /// Setup the "Samples" sub-menu with contents of samples directory.
        /// </summary>
        private void OpenSample_Click(object sender, RoutedEventArgs e)
        {
            var path = (string)((MenuItem)sender).Tag;

            if (_vm.IsUILocked)
            {
                _vm.QueueLoad(path);
            }
            else
            {
                var workspace = _vm.Model.HomeSpace;
                if (workspace.HasUnsavedChanges)
                {
                    if (!_vm.AskUserToSaveWorkspaceOrCancel(workspace))
                    {
                        return; // User has not saved his/her work.
                    }
                }

                if (dynSettings.Controller.DynamoModel.CanGoHome(null))
                {
                    dynSettings.Controller.DynamoModel.Home(null);
                }

                _vm.OpenCommand.Execute(path);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Setup the "Samples" sub-menu with contents of samples directory.
        /// </summary>
        private void OpenSample_Click(object sender, RoutedEventArgs e)
        {
            var path = (string)((MenuItem)sender).Tag;

            var workspace = dynamoViewModel.HomeSpace;

            if (workspace.HasUnsavedChanges)
            {
                if (!dynamoViewModel.AskUserToSaveWorkspaceOrCancel(workspace))
                {
                    return; // User has not saved his/her work.
                }
            }

            dynamoViewModel.Model.CurrentWorkspace = dynamoViewModel.HomeSpace;
            dynamoViewModel.OpenCommand.Execute(path);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Setup the "Samples" sub-menu with contents of samples directory.
        /// </summary>
        private void OpenSample_Click(object sender, RoutedEventArgs e)
        {
            var path = (string)((MenuItem)sender).Tag;

            var workspace = dynamoViewModel.Model.HomeSpace;

            if (workspace.HasUnsavedChanges)
            {
                if (!dynamoViewModel.AskUserToSaveWorkspaceOrCancel(workspace))
                {
                    return; // User has not saved his/her work.
                }
            }

            // KILLDYNSETTINGS - CanGoHome should live on the ViewModel
            if (dynamoViewModel.Model.CanGoHome(null))
            {
                dynamoViewModel.Model.Home(null);
            }

            dynamoViewModel.OpenCommand.Execute(path);
        }
Exemplo n.º 4
0
        private void DynamoView_OnDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                // Note that you can have more than one file.
                var files = (string[])e.Data.GetData(DataFormats.FileDrop);

                if (_vm.Model.HomeSpace.HasUnsavedChanges && !_vm.AskUserToSaveWorkspaceOrCancel(_vm.Model.HomeSpace))
                {
                    return;
                }

                if (_vm.OpenCommand.CanExecute(files[0]))
                {
                    _vm.OpenCommand.Execute(files[0]);
                }
            }

            e.Handled = true;
        }
Exemplo n.º 5
0
        private void StartPage_OnDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                // Note that you can have more than one file.
                var homespace = dynamoViewModel.HomeSpace;
                if (homespace.HasUnsavedChanges &&
                    !dynamoViewModel.AskUserToSaveWorkspaceOrCancel(homespace))
                {
                    return;
                }

                var files = e.Data.GetData(DataFormats.FileDrop) as string[];
                if (files != null && (files.Length > 0))
                {
                    if (dynamoViewModel.OpenCommand.CanExecute(files[0]))
                    {
                        dynamoViewModel.OpenCommand.Execute(files[0]);
                        e.Handled = true;
                    }
                }
            }
        }