示例#1
0
        public static HelixWatch3DViewModel Start(Watch3DViewModelStartupParams parameters)
        {
            var vm = new HelixWatch3DViewModel(parameters);

            vm.OnStartup();
            return(vm);
        }
        /// <summary>
        /// Attempt to create a HelixWatch3DViewModel. If one cannot be created,
        /// fall back to creating a DefaultWatch3DViewModel and log the exception.
        /// </summary>
        /// <param name="model">The NodeModel to associate with the returned view model.</param>
        /// <param name="parameters">A Watch3DViewModelStartupParams object.</param>
        /// <param name="logger">A logger to be used to log the exception.</param>
        /// <returns></returns>
        public static DefaultWatch3DViewModel TryCreateHelixWatch3DViewModel(NodeModel model, Watch3DViewModelStartupParams parameters, DynamoLogger logger)
        {
            try
            {
                var vm = new HelixWatch3DViewModel(model, parameters);
                return(vm);
            }
            catch (Exception ex)
            {
                logger.Log(Resources.BackgroundPreviewCreationFailureMessage, LogLevel.Console);
                logger.Log(ex.Message, LogLevel.File);

                var vm = new DefaultWatch3DViewModel(model, parameters)
                {
                    Active         = false,
                    CanBeActivated = false
                };
                return(vm);
            }
        }
示例#3
0
        private void ViewLoadedHandler(object sender, RoutedEventArgs e)
        {
            ViewModel = DataContext as HelixWatch3DViewModel;

            if (ViewModel == null) return;

            CompositionTarget.Rendering += CompositionTargetRenderingHandler;

            RegisterButtonHandlers();

            RegisterViewEventHandlers();

            ViewModel.RequestAttachToScene += ViewModelRequestAttachToSceneHandler;
            ViewModel.RequestCreateModels += RequestCreateModelsHandler;
            ViewModel.RequestRemoveModels += RequestRemoveModelsHandler;
            ViewModel.RequestViewRefresh += RequestViewRefreshHandler;
            ViewModel.RequestClickRay += GetClickRay;
            ViewModel.RequestCameraPosition += GetCameraPosition;
            ViewModel.RequestZoomToFit += ViewModel_RequestZoomToFit;

            ViewModel.UpdateUpstream();
            ViewModel.OnWatchExecution();
        }
示例#4
0
        private void ViewLoadedHandler(object sender, RoutedEventArgs e)
        {
            viewModel = DataContext as HelixWatch3DViewModel;

            CompositionTarget.Rendering += CompositionTargetRenderingHandler;

            RegisterButtonHandlers();

            if (viewModel == null)
            {
                return;
            }

            viewModel.RequestAttachToScene += ViewModelRequestAttachToSceneHandler;
            viewModel.RequestCreateModels += RequestCreateModelsHandler;
            viewModel.RequestViewRefresh += RequestViewRefreshHandler;
        }
 public static HelixWatch3DViewModel Start(Watch3DViewModelStartupParams parameters)
 {
     var vm = new HelixWatch3DViewModel(parameters);
     vm.OnStartup();
     return vm;
 }