Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 3
0
 public dynEditWindow()
 {
     InitializeComponent();
     //this.Owner = dynSettings.Bench;
     this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
     this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
     this.editText.Focus();
 }
Exemplo n.º 4
0
        public PackageManagerDownloadView()
        {
            //this.Owner = dynSettings.Bench;
            this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            InitializeComponent();
        }
Exemplo n.º 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();
        }
Exemplo n.º 8
0
        public PublishPackageView(PublishPackageViewModel packageViewModel)
        {
            this.DataContext = packageViewModel;
            packageViewModel.PublishSuccess += PackageViewModelOnPublishSuccess;

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

            InitializeComponent();
        }
Exemplo n.º 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());
            }
        }
Exemplo n.º 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;
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
                }
            };
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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));
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
                }
            };
        }
Exemplo n.º 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();
                    }
                };
            }
        }