예제 #1
0
        private void OnSampleFileSelected(object sender, RoutedEventArgs e)
        {
            var dp           = e.OriginalSource as DependencyObject;
            var treeViewItem = WPF.FindUpVisualTree <TreeViewItem>(dp) as TreeViewItem;

            if (sampleFileTreeView.SelectedItem != null)
            {
                treeViewItem.IsExpanded = !treeViewItem.IsExpanded;
            }

            var filePath = (sampleFileTreeView.SelectedItem as SampleFileEntry).FilePath;

            if (string.IsNullOrEmpty(filePath))
            {
                return;
            }

            if (!Path.GetExtension(filePath).Equals(".dyn"))
            {
                return;
            }

            var dvm = this.dynamoViewModel;

            if (dvm.OpenCommand.CanExecute(filePath))
            {
                dvm.OpenCommand.Execute(filePath);
            }
        }
예제 #2
0
        private void topControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (ViewModel == null)
            {
                return;
            }

            var view = WPF.FindUpVisualTree <DynamoView>(this);

            this.ViewModel.DynamoViewModel.ReturnFocusToSearch();

            view.mainGrid.Focus();

            var node = this.ViewModel.NodeModel;

            if (node.Workspace.Nodes.Contains(node))
            {
                Guid nodeGuid = this.ViewModel.NodeModel.GUID;
                this.ViewModel.DynamoViewModel.ExecuteCommand(
                    new DynCmd.SelectModelCommand(nodeGuid, Keyboard.Modifiers));
            }
            if (e.ClickCount == 2)
            {
                if (ViewModel.GotoWorkspaceCommand.CanExecute(null))
                {
                    e.Handled = true;
                    ViewModel.GotoWorkspaceCommand.Execute(null);
                }
            }
        }
예제 #3
0
 public dynEditWindow()
 {
     InitializeComponent();
     //this.Owner = dynSettings.Bench;
     this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
     this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
     this.editText.Focus();
 }
예제 #4
0
        public PackageManagerDownloadView()
        {
            //this.Owner = dynSettings.Bench;
            this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            InitializeComponent();
        }
예제 #5
0
 public NodeHelpPrompt(NodeModel node)
 {
     this.DataContext = node;
     this.Owner       = WPF.FindUpVisualTree <DynamoView>(this);
     //this.Owner = dynSettings.Bench;
     this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
     InitializeComponent();
 }
        public InstalledPackagesView()
        {
            //this.Owner = dynSettings.Bench;
            this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            this.DataContext = dynSettings.PackageLoader;
            InitializeComponent();
        }
        public PackageManagerSearchView(PackageManagerSearchViewModel pm)
        {
            //this.Owner = dynSettings.Bench;
            this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            this.DataContext = pm;
            InitializeComponent();
        }
예제 #8
0
        public PublishPackageView(PublishPackageViewModel packageViewModel)
        {
            this.DataContext = packageViewModel;
            packageViewModel.PublishSuccess += PackageViewModelOnPublishSuccess;

            this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            InitializeComponent();
        }
예제 #9
0
        void dynPort_Loaded(object sender, RoutedEventArgs e)
        {
            //Debug.WriteLine("Port loaded.");
            canvas = WPF.FindUpVisualTree <Dynamo.Controls.DragCanvas>(this);

            if (ViewModel != null)
            {
                ViewModel.UpdateCenter(CalculateCenter());
            }
        }
예제 #10
0
        public EditWindow()
        {
            InitializeComponent();

            this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            this.editText.Focus();

            // do not accept value if user closes
            this.Closing += (sender, args) => this.DialogResult = false;
        }
예제 #11
0
        private void NickNameBlock_OnMouseEnter(object sender, MouseEventArgs e)
        {
            TextBlock textBlock           = sender as TextBlock;
            string    tooltipContent      = ViewModel.NickName + '\n' + ViewModel.Description;
            UIElement containingWorkspace = WPF.FindUpVisualTree <TabControl>(this);
            Point     topLeft             = textBlock.TranslatePoint(new Point(0, 0), containingWorkspace);
            double    actualWidth         = textBlock.ActualWidth * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
            double    actualHeight        = textBlock.ActualHeight * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
            Point     botRight            = new Point(topLeft.X + actualWidth, topLeft.Y + actualHeight);

            ViewModel.ShowTooltipCommand.Execute(new InfoBubbleDataPacket(InfoBubbleViewModel.Style.NodeTooltip, topLeft,
                                                                          botRight, tooltipContent, InfoBubbleViewModel.Direction.Bottom));
        }
예제 #12
0
        private void topControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (ViewModel == null)
            {
                return;
            }

            dynSettings.ReturnFocusToSearch();
            //dynSettings.Bench.mainGrid.Focus();
            var view = WPF.FindUpVisualTree <DynamoView>(this);

            view.mainGrid.Focus();

            ViewModel.SelectCommand.Execute(null);
        }
예제 #13
0
        public SearchView()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(SearchView_Loaded);

            SearchTextBox.IsVisibleChanged += delegate
            {
                if (SearchTextBox.IsVisible)
                {
                    DynamoCommands.SearchCommand.Execute(null);
                    Keyboard.Focus(this.SearchTextBox);
                    var view = WPF.FindUpVisualTree <DynamoView>(this);
                    SearchTextBox.InputBindings.AddRange(view.InputBindings);
                }
            };
        }
예제 #14
0
        private void SetupAndShowTooltip(UIElement sender, InfoBubbleViewModel.Direction direction)
        {
            string content      = "";
            double actualWidth  = 0;
            double actualHeight = 0;

            switch (direction)
            {
            case InfoBubbleViewModel.Direction.Bottom:
                TextBlock tb = sender as TextBlock;
                content = ViewModel.Description;
                if (string.IsNullOrWhiteSpace(content))
                {
                    return;
                }

                actualWidth  = tb.ActualWidth * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
                actualHeight = tb.ActualHeight * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
                break;

            case InfoBubbleViewModel.Direction.Left:
            case InfoBubbleViewModel.Direction.Right:
                ContentPresenter nodePort = sender as ContentPresenter;
                content = (nodePort.Content as PortViewModel).ToolTipContent;
                if (string.IsNullOrWhiteSpace(content))
                {
                    return;
                }

                actualWidth  = nodePort.ActualWidth * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
                actualHeight = nodePort.ActualHeight * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
                break;
            }

            UIElement containingWorkspace = WPF.FindUpVisualTree <TabControl>(this);

            InfoBubbleDataPacket data = new InfoBubbleDataPacket();

            data.Text                = content;
            data.Style               = InfoBubbleViewModel.Style.NodeTooltip;
            data.TopLeft             = sender.TranslatePoint(new Point(0, 0), containingWorkspace);
            data.BotRight            = new Point(data.TopLeft.X + actualWidth, data.TopLeft.Y + actualHeight);
            data.ConnectingDirection = direction;

            StartDelayedTooltipFadeIn(data);
        }
예제 #15
0
        private void topControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (ViewModel == null)
            {
                return;
            }

            dynSettings.ReturnFocusToSearch();
            //dynSettings.Bench.mainGrid.Focus();
            var view = WPF.FindUpVisualTree <DynamoView>(this);

            view.mainGrid.Focus();

            Guid nodeGuid = this.ViewModel.NodeModel.GUID;

            dynSettings.Controller.DynamoViewModel.ExecuteCommand(
                new DynCmd.SelectModelCommand(nodeGuid, Keyboard.Modifiers));
        }
예제 #16
0
        public FunctionNamePrompt(IEnumerable <string> categories)
        {
            InitializeComponent();
            //this.Owner = dynSettings.Bench;
            this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            this.nameBox.Focus();

            var sortedCats = categories.ToList();

            sortedCats.Sort();

            foreach (var item in sortedCats)
            {
                this.categoryBox.Items.Add(item);
            }
        }
예제 #17
0
        void NodeLogic_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case "ArgumentLacing":
                ViewModel.SetLacingTypeCommand.RaiseCanExecuteChanged();
                break;

            case "IsUpdated":
                HandleCacheValueUpdated();
                break;

            case "RenderStyle":
            case "NodeColor":
                var view = WPF.FindUpVisualTree <DynamoView>(this);
                view.OnNodePropertyUpdated(viewModel.NodeLogic);
                break;
            }
        }
예제 #18
0
        private void OutputPort_OnMouseEnter(object sender, MouseEventArgs e)
        {
            ContentPresenter outputPort = sender as ContentPresenter;
            string           content    = (outputPort.Content as PortViewModel).ToolTipContent;

            if (string.IsNullOrWhiteSpace(content))
            {
                return;
            }

            UIElement containingWorkspace = WPF.FindUpVisualTree <TabControl>(this);
            Point     topLeft             = outputPort.TranslatePoint(new Point(0, 0), containingWorkspace);
            double    actualWidth         = outputPort.ActualWidth * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
            double    actualHeight        = outputPort.ActualHeight * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
            Point     botRight            = new Point(topLeft.X + actualWidth, topLeft.Y + actualHeight);

            ViewModel.ShowTooltipCommand.Execute(new InfoBubbleDataPacket(InfoBubbleViewModel.Style.NodeTooltip, topLeft,
                                                                          botRight, content, InfoBubbleViewModel.Direction.Left));
        }
예제 #19
0
        public SearchView()
        {
            InitializeComponent();
            Loaded += SearchView_Loaded;
            Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;

            SearchTextBox.IsVisibleChanged += delegate
            {
                if (SearchTextBox.IsVisible)
                {
                    DynamoCommands.SearchCommand.Execute(null);
                    Keyboard.Focus(this.SearchTextBox);
                    var view = WPF.FindUpVisualTree <DynamoView>(this);
                    SearchTextBox.InputBindings.AddRange(view.InputBindings);
                }
            };

            searchTimer.Tick += SearchTimerTick;
        }
예제 #20
0
        public SearchView(SearchViewModel searchViewModel, DynamoViewModel dynamoViewModel)
        {
            this.viewModel       = searchViewModel;
            this.dynamoViewModel = dynamoViewModel;

            InitializeComponent();
            Loaded += OnSearchViewLoaded;
            Dispatcher.ShutdownStarted += OnDispatcherShutdownStarted;

            SearchTextBox.IsVisibleChanged += delegate
            {
                if (SearchTextBox.IsVisible)
                {
                    this.viewModel.SearchCommand.Execute(null);
                    Keyboard.Focus(this.SearchTextBox);
                    var view = WPF.FindUpVisualTree <DynamoView>(this);
                    SearchTextBox.InputBindings.AddRange(view.InputBindings);
                }
            };
        }
예제 #21
0
        public EditWindow(bool updateSourceOnTextChange = false)
        {
            InitializeComponent();

            this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            this.editText.Focus();

            // do not accept value if user closes
            this.Closing += (sender, args) => this.DialogResult = false;

            if (false != updateSourceOnTextChange)
            {
                this.editText.TextChanged += delegate
                {
                    var expr = editText.GetBindingExpression(TextBox.TextProperty);
                    if (expr != null)
                    {
                        expr.UpdateSource();
                    }
                };
            }
        }