예제 #1
0
파일: PortView.cs 프로젝트: Hengle/XGraph
        /// <summary>
        /// Method called when the control content changed.
        /// </summary>
        /// <param name="pOldContent">The previous content.</param>
        /// <param name="pNewContent">The new content.</param>
        protected override void OnContentChanged(object pOldContent, object pNewContent)
        {
            base.OnContentChanged(pOldContent, pNewContent);

            BindingOperations.ClearAllBindings(this);

            // The content is the view model.
            PortViewModel lNewContent = pNewContent as PortViewModel;

            if (lNewContent != null)
            {
                // Stting the content data template.
                this.ContentTemplate = lNewContent.DataTemplate;

                // Binding the direction.
                Binding lDirectionBinding = new Binding("Direction")
                {
                    Source = lNewContent, Mode = BindingMode.TwoWay
                };
                this.SetBinding(PortView.DirectionProperty, lDirectionBinding);

                // Binding the tooltip.
                Binding lTooltipBinding = new Binding("ToolTip")
                {
                    Source = lNewContent, Mode = BindingMode.TwoWay
                };
                this.SetBinding(PortView.ToolTipProperty, lTooltipBinding);
            }
        }
예제 #2
0
        private void Animate(ContentControl currentContentPresenter, ContentControl nextContentPresenter)
        {
            var currentExitTransition  = ExitTransitionFactory?.Invoke(currentContentPresenter) ?? ExitTransition.Clone();
            var currentEnterTransition = EnterTransitionFactory?.Invoke(nextContentPresenter) ?? EnterTransition.Clone();

            var exitingContentPresenter  = currentContentPresenter;
            var enteringContentPresenter = nextContentPresenter;

            if (exitingContentPresenter != null)
            {
                void onExitTransitionCompleted(object sender, EventArgs e)
                {
                    var storyboard = sender as Storyboard;

                    if (storyboard != null)
                    {
                        storyboard.Completed -= onExitTransitionCompleted;
                    }

                    if (currentExitTransition != null)
                    {
                        currentExitTransition.Completed -= onExitTransitionCompleted;
                    }

                    BindingOperations.ClearAllBindings(exitingContentPresenter);
                    _transitionContainer.Children.Remove(exitingContentPresenter);
                }

                currentExitTransition.Completed += onExitTransitionCompleted;
                currentExitTransition.Begin(exitingContentPresenter);
            }

            currentEnterTransition.Begin(enteringContentPresenter);
        }
예제 #3
0
        private void BuildButtonZoomIn(Button button)
        {
            if (button == null)
            {
                return;
            }

            button.Click += (o, e) =>
            {
                if (gMapControl != null)
                {
                    gMapControl.Zoom = Math.Min(gMapControl.Zoom + 1.0, gMapControl.MaxZoom);
                }
            };
            button.Unloaded += (o, e) =>
            {
                var btn = o as Button;
                if (btn == null)
                {
                    return;
                }

                BindingOperations.ClearAllBindings(btn);
            };
        }
예제 #4
0
 void rilasciaTuttiBindings()
 {
     BindingOperations.ClearAllBindings(rotateTfx);
     BindingOperations.ClearAllBindings(scaleTfx);
     BindingOperations.ClearAllBindings(translateTfx);
     // IL flip non ha proprietà bindate
 }
예제 #5
0
        /// <summary>
        /// The comparison for the class
        /// </summary>
        /// <param name="x">The object value 1</param>
        /// <param name="y">The object value 2</param>
        /// <returns>Returns a number taht determines the order to sort</returns>
        public int Compare(object x, object y)
        {
            if (passFullObjectForComparison)
            {
                return(CompareOverride(x, y));
            }

            //get the actual values of the property to compare
            BindingOperations.ClearAllBindings(this);

            Binding bindForX = new Binding(SortPropertyName);

            bindForX.Source = x;
            BindingOperations.SetBinding(this, ValueForXProperty, bindForX);

            Binding bindForY = new Binding(SortPropertyName);

            bindForY.Source = y;
            BindingOperations.SetBinding(this, ValueForYProperty, bindForY);

            object valueX = this.GetValue(ValueForXProperty);
            object valueY = this.GetValue(ValueForYProperty);

            return(CompareOverride(valueX, valueY));
        }
        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);

            (cmBCurrentConnection.SelectedItem as ConnectionData)?.Save();

            BindingOperations.ClearAllBindings(cmBCurrentConnection);
            BindingOperations.ClearAllBindings(cmBFilter);
            BindingOperations.ClearAllBindings(cmBFolder);
            BindingOperations.ClearAllBindings(lstVwFolders);

            cmBFilter.Items.DetachFromSourceCollection();
            cmBCurrentConnection.Items.DetachFromSourceCollection();
            cmBFolder.Items.DetachFromSourceCollection();
            lstVwFolders.Items.DetachFromSourceCollection();

            cmBFilter.DataContext            = null;
            cmBCurrentConnection.DataContext = null;
            cmBFolder.DataContext            = null;

            cmBFilter.ItemsSource            = null;
            cmBCurrentConnection.ItemsSource = null;
            cmBFolder.ItemsSource            = null;
            lstVwFolders.ItemsSource         = null;
        }
예제 #7
0
        private void UpdateCustomGrippers()
        {
            if (_CustomGripperCompanion != null)
            {
                _CustomGripperCompanion.OnClearCustomElements(_CustomGrippers, _ForegroundElements);
                _CustomGripperCompanion = null;
            }

            foreach (var gripper in _CustomGrippers)
            {
                BindingOperations.ClearAllBindings(gripper);
            }
            _CustomGrippers.Clear();
            foreach (var foregroundElement in _ForegroundElements)
            {
                RemoveForgroundElement(foregroundElement);
            }
            _ForegroundElements.Clear();

            if (SelectedCompanions.Count == 1)
            {
                _CustomGripperCompanion = SelectedCompanions[0];

                _CustomGripperCompanion.OnCreateCustomElements(_CustomGrippers, _ForegroundElements);
                foreach (var foregroundElement in _ForegroundElements)
                {
                    AddForgroundElement(foregroundElement);
                }
            }
        }
예제 #8
0
        private void MappedTypePropertyChanged()
        {
            OnPropertyChanged(nameof(MappedType));

            //set relevant value control binding
            BindingOperations.ClearAllBindings(xVariablesComboBox);
            BindingOperations.ClearAllBindings(xOptionalValuesComboBox);
            BindingOperations.ClearAllBindings(xDSExpressionTxtbox);
            if (MappedType == eDataType.Variable.ToString())
            {
                BindingHandler.ObjFieldBinding(xVariablesComboBox, ComboBox.SelectedValueProperty, this, nameof(MappedValue));
            }
            else if (MappedType == eDataType.GlobalVariable.ToString())
            {
                BindingHandler.ObjFieldBinding(xOptionalValuesComboBox, ComboBox.SelectedValueProperty, this, nameof(MappedValueGUID));
            }
            else if (MappedType == eDataType.OutputVariable.ToString())
            {
                BindingHandler.ObjFieldBinding(xOptionalValuesComboBox, ComboBox.SelectedValueProperty, this, nameof(MappedValueGUID));
            }
            else if (MappedType == eDataType.ApplicationModelParameter.ToString())
            {
                BindingHandler.ObjFieldBinding(xOptionalValuesComboBox, ComboBox.SelectedValueProperty, this, nameof(MappedValueGUID));
            }
            else if (MappedType == eDataType.DataSource.ToString())
            {
                BindingHandler.ObjFieldBinding(xDSExpressionTxtbox, TextBox.TextProperty, this, nameof(MappedValue));
            }

            SetValueControlsData();

            SetValueControlsView();
        }
예제 #9
0
        void RichBlocks_UnLoaded(object sender, RoutedEventArgs e)
        {
            vPanel.Children.Clear();

            CommandBindings.Clear();
            BindingOperations.ClearAllBindings(this);
        }
예제 #10
0
        /// <summary>
        /// When overridden in a derived class, is invoked whenever
        /// application code or internal processes call ApplyTemplate
        /// </summary>
        public override void OnApplyTemplate()
        {
            if (this.textBoxTemplated != null)
            {
                this.textBoxTemplated.PreviewKeyDown   -= this.OnTextBoxTemplatedKeyDown;
                this.textBoxTemplated.SelectionChanged -= this.OnTextBoxTemplatedSelectionChanged;
                this.textBoxTemplated.LostFocus        -= this.OnTextBoxTemplatedLostFocus;
                this.textBoxTemplated.GotKeyboardFocus -= this.OnTextBoxTemplatedGotKeyboardFocus;
                this.textBoxTemplated.TextChanged      -= this.OnTextBoxTemplatedTextChanged;
                BindingOperations.ClearAllBindings(this.textBoxTemplated);
            }
            this.textBoxTemplated = this.GetTemplateChild("PART_TextBox") as System.Windows.Controls.TextBox;


            // Check template
            if (!this.IsTemplateValid())
            {
                Debug.WriteLine("Template for TextBox control is invalid");
                return;
            }

            this.textBoxTemplated.Text = this.Text;
            this.textBoxTemplated.Select(this.textBox.SelectionStart, this.textBox.SelectionLength);

            // Bindings
            BindingOperations.ClearAllBindings(this.textBox);

            this.ForwardBindings(this, this.textBoxTemplated);

            this.textBoxTemplated.PreviewKeyDown   += this.OnTextBoxTemplatedKeyDown;
            this.textBoxTemplated.SelectionChanged += this.OnTextBoxTemplatedSelectionChanged;
            this.textBoxTemplated.LostFocus        += this.OnTextBoxTemplatedLostFocus;
            this.textBoxTemplated.GotKeyboardFocus += this.OnTextBoxTemplatedGotKeyboardFocus;
            this.textBoxTemplated.TextChanged      += this.OnTextBoxTemplatedTextChanged;
        }
예제 #11
0
        private void ResetContentViews()
        {
            if (smallContentGrid.Children.Count <= 0)
            {
                return;
            }

            var smallContentView = smallContentGrid.Children[0] as PreviewCompactView;

            BindingOperations.ClearAllBindings(smallContentView);

            // No view to reset, return now.
            if (largeContentGrid.Children.Count <= 0)
            {
                return;
            }

            var watchTree       = largeContentGrid.Children[0] as WatchTree;
            var rootDataContext = watchTree.DataContext as WatchViewModel;

            // Unbind the view from data context, then clear the data context.
            BindingOperations.ClearAllBindings(watchTree.treeView1);
            BindingOperations.ClearAllBindings(watchTree.ListLevelsDisplay);
            rootDataContext.Children.Clear();
        }
예제 #12
0
 private void ClearBindings(object elem)
 {
     if ((elem as DependencyObject) != null)
     {
         BindingOperations.ClearAllBindings(elem as DependencyObject);
     }
 }
예제 #13
0
        void SetRadioGroupBindings(SerialView Serial, NavigatingCancelEventArgs e)
        {
            BindingOperations.ClearAllBindings((e.Content as SerialInfoPage).rbStopWatching);
            BindingOperations.ClearAllBindings((e.Content as SerialInfoPage).rbWatched);
            BindingOperations.ClearAllBindings((e.Content as SerialInfoPage).rbWatching);

            Binding bind = new Binding();

            bind.Source = Serial;
            bind.Path   = new PropertyPath("Watching");
            bind.Mode   = BindingMode.TwoWay;
            (e.Content as SerialInfoPage).rbWatching.SetBinding(RadioButton.IsCheckedProperty, bind);

            Binding bind2 = new Binding();

            bind2.Source = Serial;
            bind2.Path   = new PropertyPath("Watched");
            bind2.Mode   = BindingMode.TwoWay;
            (e.Content as SerialInfoPage).rbWatched.SetBinding(RadioButton.IsCheckedProperty, bind2);

            Binding bind3 = new Binding();

            bind3.Source = Serial;
            bind3.Path   = new PropertyPath("DontWatch");
            bind3.Mode   = BindingMode.TwoWay;
            (e.Content as SerialInfoPage).rbStopWatching.SetBinding(RadioButton.IsCheckedProperty, bind3);
        }
예제 #14
0
 private void ClearBindings(DependencyObject obj)
 {
     if (obj == null)
     {
         return;
     }
     BindingOperations.ClearAllBindings(obj);
     if (obj is Panel)
     {
         foreach (UIElement element in ((Panel)obj).Children)
         {
             ClearBindings(element);
         }
     }
     else if (obj is ItemsControl)
     {
         foreach (UIElement element in ((ItemsControl)obj).Items)
         {
             ClearBindings(element);
         }
     }
     else if (obj is ContentControl)
     {
         ClearBindings(((ContentControl)obj).Content as DependencyObject);
     }
 }
예제 #15
0
        public override object Clone()
        {
            ShellDrillDownMenuItem clone = new ShellDrillDownMenuItem
            {
                Caption      = this.Caption,
                Id           = this.Id,
                IsBackItem   = this.IsBackItem,
                IsEnabled    = this.IsEnabled,
                IsFolder     = this.IsFolder,
                IsReadOnly   = this.IsReadOnly,
                AssemblyFile = this.AssemblyFile,
                IsAuthorized = this.IsAuthorized,
                Operation    = this.Operation,
                Parameters   = this.Parameters,
                EventTopic   = this.EventTopic,
            };


            BindingOperations.ClearAllBindings(clone);

            ObservableCollection <DrillDownMenuItem> children = new ObservableCollection <DrillDownMenuItem>();

            foreach (DrillDownMenuItem child in this.Children)
            {
                DrillDownMenuItem childClone = child.Clone() as DrillDownMenuItem;
                childClone.Parent = clone;
                children.Add(childClone);
            }

            clone.Children = children;

            return(clone);
        }
        public void OnDisposeGUIBot()
        {
            //looking at MainWindowViewModel.BindBotControls
            this.DataContext = null;
            GridSettings.Children.Clear();
            //GridSettings.Children[0] = null;
            BindingOperations.ClearAllBindings(BotSate);



            BindingOperations.ClearAllBindings(this);
            BindingOperations.ClearAllBindings(this.EllipseEnabled);
            this.EllipseEnabled.DataContext = null;
            BindingOperations.ClearAllBindings(this.TextEnabled);
            this.TextEnabled.DataContext = null;
            BindingOperations.ClearAllBindings(this.MonitorPos);
            BindingOperations.ClearAllBindings(this.Orders);

            if (this.GUIBot != null)
            {
                this.GUIBot.MonitorPos.CollectionChanged -= this.OnMonitorPosCollectionChanged;
                this.GUIBot.Orders.CollectionChanged     -= this.OnMonitorOrdersCollectionChanged;
                this.GUIBot.DisposeGUIBotEvent           -= OnDisposeGUIBot;
                this.GUIBot = null;
            }

            BindingOperations.ClearAllBindings(this.ButtonPosLog);
            BindingOperations.ClearAllBindings(this.ButtonDisableBot);
            BindingOperations.ClearAllBindings(this.ButtonEnableBot);
            BindingOperations.ClearAllBindings(this.ButtonUnloadBot);
        }
예제 #17
0
        protected override void OnElementChanged(ElementChangedEventArgs <GIFView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
            }
            if (e.NewElement != null)
            {
                if (Control == null)
                {
                    var control = new NativeGIFView();
                    SetNativeControl(control);
                }
                else
                {
                    BindingOperations.ClearAllBindings(Control);
                }

                var binding1 = new Binding()
                {
                    Source = e.NewElement, Path = new PropertyPath(nameof(GIFView.Source))
                };
                var binding2 = new Binding()
                {
                    Source = e.NewElement, Path = new PropertyPath(nameof(GIFView.Stretch)), Converter = new StretchConverter()
                };
                BindingOperations.SetBinding(Control, NativeGIFView.SourceProperty, binding1);
                BindingOperations.SetBinding(Control, NativeGIFView.StretchProperty, binding2);
            }
        }
예제 #18
0
        private static Control ProvideHyperLinkControl(Binding binding, PropertyInfo propertyInfo, object viewModel)
        {
            var control = new ContentControl();


            var text      = (string)propertyInfo.GetValue(viewModel, null);
            var ln        = new Run(text);
            var hyperlink = new Hyperlink(ln);

            hyperlink.SetBinding(Hyperlink.NavigateUriProperty, binding);



            hyperlink.RequestNavigate += (o, e) =>
            {
                Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
                e.Handled = true;
            };
            hyperlink.Unloaded += (o, e) =>
            {
                var hl = o as Hyperlink;
                if (hl == null)
                {
                    return;
                }

                BindingOperations.ClearAllBindings(hl);
            };

            control.SetValue(ContentControl.ContentProperty, hyperlink);
            return(control);
        }
예제 #19
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            watchTree = new WatchTree();

            nodeUI.grid.Children.Add(watchTree);
            watchTree.SetValue(Grid.RowProperty, 2);
            watchTree.SetValue(Grid.ColumnSpanProperty, 3);
            watchTree.Margin = new Thickness(5, 0, 5, 5);

            if (Root == null)
            {
                Root = new WatchNode();
            }
            watchTree.DataContext = Root;

            this.RequestBindingUnhook += new EventHandler(delegate
            {
                BindingOperations.ClearAllBindings(watchTree.treeView1);
            });

            this.RequestBindingRehook += new EventHandler(delegate
            {
                var sourceBinding = new Binding("Children")
                {
                    Mode   = BindingMode.TwoWay,
                    Source = Root,
                };
                watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty, sourceBinding);
            });
        }
예제 #20
0
 public void Dispose()
 {
     this.textEditorSettings.PropertyChanged -= TextEditorSettings_PropertyChanged;
     Clear();
     BindingOperations.ClearAllBindings(TextEditor);
     textMarkerService.Dispose();
 }
예제 #21
0
 public static void ClearAllBindings(this DependencyObject dependencyObject)
 {
     foreach (var element in dependencyObject.AllVisualChildren())
     {
         BindingOperations.ClearAllBindings(element);
     }
 }
예제 #22
0
        ///<summary> Магическая чистка, которая позволяет GC почти сразу затирать BitmapImage из неуправляемой памяти. </summary>
        private void ForceLinkDestroy()
        {
            var albList = CatEng?.CatRoot?.AlbumsList;

            if (albList != null)
            {
                foreach (var alb in albList)
                {
                    if (alb?.vp != null)
                    {
                        BindingOperations.ClearAllBindings(alb.vp.CoverArt);
                        alb.vp.DataContext     = null;
                        alb.vp.CoverArt.Source = null;
                        alb.vp.BG.Source       = null;
                        alb.vp = null;
                    }
                    alb.StopLoadEntCoversThread();
                    alb.CoverImage = null;

                    foreach (var ent in alb.EntryList)
                    {
                        if (ent?.vp != null)
                        {
                            BindingOperations.ClearAllBindings(ent.vp.CoverArt);
                            ent.vp.DataContext     = null;
                            ent.vp.CoverArt.Source = null;
                            ent.vp.BG.Source       = null;
                            ent.vp = null;
                        }
                        ent.CoverImage = null;
                    }
                }
            }
        }
예제 #23
0
        public void ClearBindings()
        {
            ParentList.UcListViewEvent                 -= ParentList_UcListViewEvent;
            ParentList.List.SelectionChanged           -= ParentList_SelectionChanged;
            ((RepositoryItemBase)Item).PropertyChanged -= Item_PropertyChanged;

            BindingOperations.ClearAllBindings(xItemIcon);
            foreach (ImageMakerControl notification in xItemNotificationsPnl.Children)
            {
                BindingOperations.ClearAllBindings(notification);
            }
            BindingOperations.ClearAllBindings(xItemStatusImage);
            BindingOperations.ClearAllBindings(xListItemGrid);
            foreach (ucButton operation in xItemOperationsPnl.Children)
            {
                BindingOperations.ClearAllBindings(operation);
            }
            foreach (MenuItem extraOperation in xItemExtraOperationsMenu.Items)
            {
                BindingOperations.ClearAllBindings(extraOperation);
            }
            foreach (ucButton executionOperation in xItemExecutionOperationsPnl.Children)
            {
                BindingOperations.ClearAllBindings(executionOperation);
            }

            this.ClearControlsBindings();
        }
예제 #24
0
 public static void ClearControlsBindings(this DependencyObject dependencyObject)
 {
     foreach (DependencyObject element in dependencyObject.EnumerateVisualDescendents())
     {
         BindingOperations.ClearAllBindings(element);
     }
 }
예제 #25
0
        private void TransitionControl_Unloaded(object sender, RoutedEventArgs e)
        {
            Unloaded -= TransitionControl_Unloaded;

            _transitionContainer?.Children.Clear();

            BindingOperations.ClearAllBindings(this);
        }
 public void Dispose()
 {
     UnregisterEventHandlers();
     //for some reason the menuItem was not being gc'd in tests without manually removing it
     viewLoadedParams.dynamoMenu.Items.Remove(notificationsMenuItem.MenuItem);
     BindingOperations.ClearAllBindings(notificationsMenuItem.CountLabel);
     notificationsMenuItem = null;
 }
예제 #27
0
        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            #region Solution
            //BindingOperations.ClearAllBindings(this.tbZiel);
            #endregion

            BindingOperations.ClearAllBindings(this.tbZiel);
        }
예제 #28
0
        private void UserControl_Unloaded(object sender, RoutedEventArgs e)
        {
            BindingOperations.ClearAllBindings(this);
            BindingOperations.ClearAllBindings(num);
            BindingOperations.ClearAllBindings(incr);

            incr.PostiveAndNegativeChanged -= Incr_PostiveAndNegativeChanged;
        }
예제 #29
0
        private void OnUnloaded(object sender, RoutedEventArgs e)
        {
            Unloaded -= OnUnloaded;

            BindingOperations.ClearAllBindings(this);

            _plot.Plot.Clear();
        }
예제 #30
0
 private void ResetButton()
 {
     foreach (ToolButton item in buttonlist)
     {
         BindingOperations.ClearAllBindings(item);
         item.Background = Brushes.Transparent;
         item.C          = null;
     }
 }