public void SetupCustomUIElements(dynNodeView nodeUI) { var mi = new MenuItem { Header = "Zoom to Fit" }; mi.Click += mi_Click; nodeUI.MainContextMenu.Items.Add(mi); //add a 3D viewport to the input grid //http://helixtoolkit.codeplex.com/wikipage?title=HelixViewport3D&referringTitle=Documentation //_watchView = new WatchView(); View = new Watch3DView(GUID.ToString()) { DataContext = this, Width = _watchWidth, Height = _watchHeight }; View.View.Camera.Position = _camPosition; View.View.Camera.LookDirection = _lookDirection; var backgroundRect = new Rectangle { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, IsHitTestVisible = false }; var bc = new BrushConverter(); var strokeBrush = (Brush)bc.ConvertFrom("#313131"); backgroundRect.Stroke = strokeBrush; backgroundRect.StrokeThickness = 1; var backgroundBrush = new SolidColorBrush(Color.FromRgb(240, 240, 240)); backgroundRect.Fill = backgroundBrush; nodeUI.PresentationGrid.Children.Add(backgroundRect); nodeUI.PresentationGrid.Children.Add(View); nodeUI.PresentationGrid.Visibility = Visibility.Visible; }
private void DynamoView_Loaded(object sender, EventArgs e) { // Do an initial load of the cursor collection CursorLibrary.GetCursor(CursorSet.ArcSelect); //Backing up IsFirstRun to determine whether to show Gallery var isFirstRun = dynamoViewModel.Model.PreferenceSettings.IsFirstRun; // If first run, Collect Info Prompt will appear UsageReportingManager.Instance.CheckIsFirstRun(this, dynamoViewModel.BrandingResourceProvider); WorkspaceTabs.SelectedIndex = 0; dynamoViewModel = (DataContext as DynamoViewModel); dynamoViewModel.Model.RequestLayoutUpdate += vm_RequestLayoutUpdate; dynamoViewModel.RequestViewOperation += DynamoViewModelRequestViewOperation; dynamoViewModel.PostUiActivationCommand.Execute(null); _timer.Stop(); dynamoViewModel.Model.Logger.Log(String.Format(Wpf.Properties.Resources.MessageLoadingTime, _timer.Elapsed, dynamoViewModel.BrandingResourceProvider.ProductName)); InitializeLogin(); InitializeShortcutBar(); InitializeStartPage(isFirstRun); #if !__NO_SAMPLES_MENU LoadSamplesMenu(); #endif #region Search initialization var search = new SearchView( dynamoViewModel.SearchViewModel, dynamoViewModel); sidebarGrid.Children.Add(search); dynamoViewModel.SearchViewModel.Visible = true; #endregion #region Package manager dynamoViewModel.RequestPackagePublishDialog += DynamoViewModelRequestRequestPackageManagerPublish; dynamoViewModel.RequestManagePackagesDialog += DynamoViewModelRequestShowInstalledPackages; dynamoViewModel.RequestPackageManagerSearchDialog += DynamoViewModelRequestShowPackageManagerSearch; dynamoViewModel.RequestPackagePathsDialog += DynamoViewModelRequestPackagePaths; #endregion #region Node view injection // scan for node view overrides #endregion //FUNCTION NAME PROMPT dynamoViewModel.Model.RequestsFunctionNamePrompt += DynamoViewModelRequestsFunctionNamePrompt; //Preset Name Prompt dynamoViewModel.Model.RequestPresetsNamePrompt += DynamoViewModelRequestPresetNamePrompt; dynamoViewModel.RequestPresetsWarningPrompt += DynamoViewModelRequestPresetWarningPrompt; dynamoViewModel.RequestClose += DynamoViewModelRequestClose; dynamoViewModel.RequestSaveImage += DynamoViewModelRequestSaveImage; dynamoViewModel.SidebarClosed += DynamoViewModelSidebarClosed; dynamoViewModel.Model.RequestsCrashPrompt += Controller_RequestsCrashPrompt; dynamoViewModel.Model.RequestTaskDialog += Controller_RequestTaskDialog; DynamoSelection.Instance.Selection.CollectionChanged += Selection_CollectionChanged; dynamoViewModel.RequestUserSaveWorkflow += DynamoViewModelRequestUserSaveWorkflow; dynamoViewModel.Model.ClipBoard.CollectionChanged += ClipBoard_CollectionChanged; //ABOUT WINDOW dynamoViewModel.RequestAboutWindow += DynamoViewModelRequestAboutWindow; //SHOW or HIDE GALLERY dynamoViewModel.RequestShowHideGallery += DynamoViewModelRequestShowHideGallery; LoadNodeViewCustomizations(); SubscribeNodeViewCustomizationEvents(); // Kick start the automation run, if possible. dynamoViewModel.BeginCommandPlayback(this); var loadedParams = new ViewLoadedParams(this, dynamoViewModel); foreach (var ext in viewExtensionManager.ViewExtensions) { try { ext.Loaded(loadedParams); } catch (Exception exc) { Log(ext.Name + ": " + exc.Message); } } BackgroundPreview = new Watch3DView {Name = BackgroundPreviewName}; background_grid.Children.Add(BackgroundPreview); BackgroundPreview.DataContext = dynamoViewModel.BackgroundPreviewViewModel; BackgroundPreview.Margin = new System.Windows.Thickness(0,20,0,0); var vizBinding = new Binding { Source = dynamoViewModel.BackgroundPreviewViewModel, Path = new PropertyPath("Active"), Mode = BindingMode.TwoWay, Converter = new BooleanToVisibilityConverter() }; BackgroundPreview.SetBinding(VisibilityProperty, vizBinding); }
public override void SetupCustomUIElements(object ui) { var nodeUI = ui as dynNodeView; MenuItem mi = new MenuItem(); mi.Header = "Zoom to Fit"; mi.Click += new RoutedEventHandler(mi_Click); nodeUI.MainContextMenu.Items.Add(mi); //take out the left and right margins and make this so it's not so wide //NodeUI.inputGrid.Margin = new Thickness(10, 10, 10, 10); //add a 3D viewport to the input grid //http://helixtoolkit.codeplex.com/wikipage?title=HelixViewport3D&referringTitle=Documentation //_watchView = new WatchView(); _watchView = new Watch3DView(GUID.ToString()); _watchView.DataContext = this; _watchView.Width = _watchWidth; _watchView.Height = _watchHeight; _watchView.View.Camera.Position = _camPosition; _watchView.View.Camera.LookDirection = _lookDirection; System.Windows.Shapes.Rectangle backgroundRect = new System.Windows.Shapes.Rectangle(); backgroundRect.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; backgroundRect.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; backgroundRect.IsHitTestVisible = false; var bc = new BrushConverter(); var strokeBrush = (Brush)bc.ConvertFrom("#313131"); backgroundRect.Stroke = strokeBrush; backgroundRect.StrokeThickness = 1; var backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(240, 240, 240)); backgroundRect.Fill = backgroundBrush; nodeUI.grid.Children.Add(backgroundRect); nodeUI.grid.Children.Add(_watchView); backgroundRect.SetValue(Grid.RowProperty, 2); backgroundRect.SetValue(Grid.ColumnSpanProperty, 3); _watchView.SetValue(Grid.RowProperty, 2); _watchView.SetValue(Grid.ColumnSpanProperty, 3); _watchView.Margin = new Thickness(5, 0, 5, 5); backgroundRect.Margin = new Thickness(5, 0, 5, 5); CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering); }