private void CurrentLanguageChanged(object sender, CurrentLanguageChangedEventArgs e)
 {
     if (xamlTargetObject != null && xamlDependencyProperty != null)
     {
         BindingOperations.GetMultiBindingExpression(xamlTargetObject, xamlDependencyProperty)?.UpdateTarget();
     }
 }
        private void RefreshMenuBinding()
        {
            MultiBindingExpression b = BindingOperations.GetMultiBindingExpression(_docContextMenu,
                                                                                   ContextMenu.ItemsSourceProperty);

            b.UpdateTarget();
        }
        private void Update()
        {
            if (!string.IsNullOrEmpty(BindingPropertyName) && Value != null && AssociatedObject != null)
            {
                DependencyProperty dependencyProperty = DependencyPropertyDescriptor.FromName(BindingPropertyName, AssociatedObject.GetType(), AssociatedObject.GetType())?.DependencyProperty;

                if (dependencyProperty != null)
                {
                    Binding binding = BindingOperations.GetBinding(AssociatedObject, dependencyProperty);

                    if (binding.Converter != null)
                    {
                        try
                        {
                            if (ConverterPropertyName.Contains(".") || ConverterPropertyName.Contains("["))
                            {
                                expressionEvaluator.Variables["converter"] = binding.Converter;
                                expressionEvaluator.Variables["value"]     = Value;

                                expressionEvaluator.Evaluate($"converter.{ConverterPropertyName} = value");
                            }
                            else
                            {
                                binding.Converter.GetType().GetProperty(ConverterPropertyName)?.SetValue(binding.Converter, Value);
                            }

                            BindingOperations.GetBindingExpression(AssociatedObject, dependencyProperty)?.UpdateTarget();
                            BindingOperations.GetMultiBindingExpression(AssociatedObject, dependencyProperty)?.UpdateTarget();
                        }
                        catch { }
                    }
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Reset the data binding after a save to clear the blue that could be there when
        /// a change is detected.
        /// </summary>
        /// <typeparam name="T">Type to search for</typeparam>
        /// <param name="parentDepObj">Parent object we want to reset the binding for their children.</param>
        public static void UpdateDataBindings <T>(DependencyObject parentDepObj) where T : DependencyObject
        {
            if (parentDepObj != null)
            {
                MultiBindingExpression multiBindingExpression;

                foreach (var control in UIHelper.FindVisualChildren <T>(parentDepObj))
                {
                    /*
                     * i was hoping this would get the style for the data grid cells. it is slow and does not work
                     */
                    /* foreach(var child in FindVisualChildren<Control>(control))
                     * {
                     * ResetDataBinding<Control>(child);
                     * }*/

                    multiBindingExpression = BindingOperations.GetMultiBindingExpression(control, Control.BackgroundProperty);
                    if (multiBindingExpression != null)
                    {
                        multiBindingExpression.UpdateTarget();
                    }

                    multiBindingExpression = BindingOperations.GetMultiBindingExpression(control, DataGridCell.StyleProperty);
                    if (multiBindingExpression != null)
                    {
                        multiBindingExpression.UpdateTarget();
                    }
                }
            }
        }
        private void Grid_Click(object sender, RoutedEventArgs e)
        {
            if (e.Source is CheckBox checkBox)
            {
                var window = ViewModel.Instance.SelectedWindow;

                var style = (WindowStylesEx)Enum.Parse(typeof(WindowStylesEx), (string)checkBox.Tag);

                if (style == WindowStylesEx.WS_EX_TOPMOST)
                {
                    window.SetTopMost(checkBox.IsChecked == true);
                }
                else
                {
                    var styles = window.StylesEx;

                    if (checkBox.IsChecked == true)
                    {
                        styles |= style;
                    }
                    else
                    {
                        styles &= ~style;
                    }

                    window.StylesEx = styles;
                }

                BindingOperations.GetMultiBindingExpression(checkBox, CheckBox.IsCheckedProperty).UpdateTarget();
            }
        }
예제 #6
0
        private void SelectHistoryItem()
        {
            //if index isn't set, set input to previously saved input
            if (this.HistoryIndex <= -1)
            {
                this.TxtInput.Text       = this.currentInput;
                this.TxtInput.CaretIndex = this.currentCaretIndex;
            }
            else                  //if index is set
                                  //set the input to the history item input
            {
                this.TxtInput.Text = this.History [this.HistoryIndex].Input;

                //move caret to the end
                this.TxtInput.CaretIndex = this.TxtInput.Text.Length;
            }

            //force each item in the display list to update its background
            for (int i = 0; i < this.HistoryListBox.Items.Count; i++)
            {
                //get the item container
                ContentPresenter cp = this.HistoryListBox.ItemContainerGenerator.ContainerFromIndex(i) as ContentPresenter;

                //make sure container exists and has children
                if (cp != null && VisualTreeHelper.GetChildrenCount(cp) > 0)
                {
                    //get the grid
                    Grid grid = VisualTreeHelper.GetChild(cp, 0) as Grid;

                    //make the grid's background binding refresh
                    BindingOperations.GetMultiBindingExpression(grid, Grid.BackgroundProperty).UpdateTarget();
                }
            }
        }
예제 #7
0
        public void UpdateStatBlock(
            StackPanel statBlock)
        {
            UpdateLayout();

            var visibilityMultiBinding =
                BindingOperations.GetMultiBindingExpression(
                    statBlock,
                    VisibilityProperty);

            if (visibilityMultiBinding == null)
            {
                return;
            }

            foreach (var binding in
                     visibilityMultiBinding.BindingExpressions)
            {
                binding
                .UpdateTarget();
            }

            visibilityMultiBinding
            .UpdateTarget();

            UpdateLayout();
        }
예제 #8
0
        private void chkIndependentProperties_Unchecked(object sender, RoutedEventArgs e)
        {
            foreach (var icon in icons)
            {
                switch (eltType)
                {
                case ShapeRepresents.Node:
                    gui.nodeIcons.BindTextDisplayProperties(icon);
                    break;

                case ShapeRepresents.Arc:
                    gui.arcIcons.BindTextDisplayProperties(icon);
                    break;

                case ShapeRepresents.HyperArc:
                    gui.hyperarcIcons.BindTextDisplayProperties(icon);
                    break;
                }
                MultiBindingExpression mbe = BindingOperations.GetMultiBindingExpression(icon,
                                                                                         IconShape.DisplayTextProperty);
                mbe.UpdateTarget();
            }
            expTextProperties.IsExpanded = false;
            expTextProperties.IsExpanded = false;
            chkShowNodeName.IsEnabled    = false;
            chkShowNodeLabels.IsEnabled  = false;
            sldDistance.IsEnabled        = false;
            sldFontSize.IsEnabled        = false;
            sldPosition.IsEnabled        = false;
        }
 private void ItemContainerGenerator_ItemsChanged(object sender, System.Windows.Controls.Primitives.ItemsChangedEventArgs e)
 {
     for (var i = 0; i < ListBox.ItemContainerGenerator.Items.Count; i++)
     {
         try
         {
             var element =
                 (FrameworkElement)ListBox.ItemContainerGenerator.ContainerFromIndex(i);
             if (element == null)
             {
                 continue;
             }
             object found;
             found = WpfTreeUtilities.FindVisualChild <StackPanel>(element).FindName("Number");
             var textBlock = found as TextBlock;
             if (textBlock == null)
             {
                 continue;
             }
             var bindingExpression = BindingOperations.GetMultiBindingExpression(textBlock, TextBlock.TextProperty);
             bindingExpression?.UpdateTarget();
         }
         catch (Exception ex)
         {
             Debug.WriteLine("Oh no " + ex);
         }
     }
 }
예제 #10
0
        protected async Task AddToFalloAlCargarMultiBindingsAsync(aVMTabBase newTab, FalloAlCargarUC UC)
        {
            MultiBinding falloMultiBinding = BindingOperations.GetMultiBindingExpression(UC, FalloAlCargarUC.VisibilityProperty).ParentMultiBinding;

            falloMultiBinding.Bindings.Add(new Binding()
            {
                Source = newTab,
                Path   = new PropertyPath("TaskCargando.IsNotCompleted"),
                Mode   = BindingMode.OneWay
            });
            SetVisibilityConverter(falloMultiBinding, "FalseCollapsed");
            falloMultiBinding.NotifyOnSourceUpdated = true;
            UC.SetBinding(FalloAlCargarUC.VisibilityProperty, falloMultiBinding);

            falloMultiBinding = BindingOperations.GetMultiBindingExpression(UC, FalloAlCargarUC.MensajeFalloProperty).ParentMultiBinding;
            falloMultiBinding.Bindings.Add(new Binding()
            {
                Source = newTab,
                Path   = new PropertyPath("TaskCargando.ErrorMessage"),
                Mode   = BindingMode.OneWay
            });
            SetVisibilityConverter(falloMultiBinding);
            falloMultiBinding.NotifyOnSourceUpdated = true;
            UC.SetBinding(FalloAlCargarUC.MensajeFalloProperty, falloMultiBinding);
        }
        private async Task UpdateControlsAsync(PropertyChangedEventArgs args)
        {
            await LicenseHeadersPackage.Instance.JoinableTaskFactory.SwitchToMainThreadAsync();

            // for unknown reasons, changes in below DependencyProperties' data source are sometimes not reflected in the UI => trigger update manually
            var context = (SolutionUpdateViewModel)DataContext;

            switch (args.PropertyName)
            {
            case nameof(context.ProcessedProjectCount):
                BindingOperations.GetMultiBindingExpression(ProjectsDoneTextBlock, TextBlock.TextProperty)?.UpdateTarget();
                BindingOperations.GetBindingExpression(ProjectsDoneProgressBar, ProgressBar.ValueProperty)?.UpdateTarget();
                break;

            case nameof(context.CurrentProject):
                BindingOperations.GetBindingExpression(CurrentProjectTextBlock, TextBlock.TextProperty)?.UpdateTarget();
                break;

            case nameof(context.ProjectCount):
                BindingOperations.GetBindingExpression(ProjectsDoneProgressBar, ProgressBar.MaximumProperty)?.UpdateTarget();
                break;

            case nameof(context.ProcessedFilesCountCurrentProject):
                BindingOperations.GetMultiBindingExpression(FilesDoneTextBlock, TextBlock.TextProperty)?.UpdateTarget();
                BindingOperations.GetBindingExpression(FilesDoneProgressBar, ProgressBar.ValueProperty)?.UpdateTarget();
                break;

            case nameof(context.FileCountCurrentProject):
                BindingOperations.GetBindingExpression(FilesDoneTextBlock, TextBlock.TextProperty)?.UpdateTarget();
                break;
            }
        }
예제 #12
0
        protected override void OnRender(DrawingContext dc)
        {
            if (Selected || (StrokeOpacity >= opacityCutoff))
            {
                var geometry = new PathGeometry();
                geometry.Figures.Add(arcShape.arcBody);
                if (arcShape.directed)
                {
                    geometry.Figures.Add(arcShape.toArrowHead);
                }
                if (arcShape.doublyDirected)
                {
                    geometry.Figures.Add(arcShape.fromArrowHead);
                }
                Pen pen;
                if (Selected)
                {
                    pen = new Pen
                    {
                        Brush     = selectedBrush,
                        Thickness = SelectedStrokeThickness,
                        DashStyle = selectedDashStyle
                    }
                }
                ;
                else
                {
                    var brush = defaultBrush.Clone();
                    brush.Opacity = StrokeOpacity;
                    pen           = new Pen
                    {
                        Brush     = brush,
                        Thickness = DefaultStrokeThickness,
                        DashStyle = defaultDashStyle
                    };
                }
                dc.DrawGeometry(selectedBrush, pen, geometry);
            }
            if ((ShowName || ShowLabels) && (DisplayText != null))
            {
                var mbe = BindingOperations.GetMultiBindingExpression(this, TextPointProperty);
                if (mbe != null)
                {
                    mbe.UpdateTarget();
                }
                dc.PushTransform(new MatrixTransform(1, 0, 0, -1, TextPoint.X, TextPoint.Y));
                dc.DrawText(DisplayText, new Point());
                dc.Pop();
            }
            Panel.SetZIndex(this, int.MaxValue);
            var RadPoint = new Vector(
                Math.Min(Math.Abs(arcShape.FromLocation.Value.OffsetX - TextPoint.X),
                         Math.Abs(arcShape.ToLocation.Value.OffsetX - TextPoint.X)),
                Math.Min(Math.Abs(arcShape.FromLocation.Value.OffsetY - TextPoint.Y),
                         Math.Abs(arcShape.ToLocation.Value.OffsetY - TextPoint.Y)));

            Radius = RadPoint.Length;
        }
예제 #13
0
        private void Button_Click_UpdateSourceDownlink(object sender, RoutedEventArgs e)
        {
            MultiBindingExpression mbex = BindingOperations.GetMultiBindingExpression(SpinEdit_DirectChannel, SpinEdit.TextProperty);

            if (mbex != null)
            {
                mbex.UpdateSource();
            }
        }
예제 #14
0
        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            gui.HyperArcNameChanged(firstHyperArc, txtName.Text);
            var binding
                = BindingOperations.GetMultiBindingExpression(hyperArcIcon, IconShape.DisplayTextProperty);

            binding.UpdateTarget();
            Update();
        }
예제 #15
0
        private static void InternalPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (!((vMixControlTextField)d).IsLive)
            {
                return;
            }
            if (e.Property.Name == "Text")
            {
                try
                {
                    var exp = BindingOperations.GetMultiBindingExpression(d, TextProperty);
                    if (exp != null && exp.Status == BindingStatus.Active)
                    {
                        DelayedUpdate.Enqueue(new Triple <DependencyObject, DependencyProperty, DateTime>()
                        {
                            A = d, B = e.Property, C = DateTime.Now
                        });
                        //DelayedUpdateTimer.Start();
                        //exp.UpdateTarget();
                        //exp.UpdateSource();

                        /*foreach (var item in exp.BindingExpressions.OfType<BindingExpression>())
                         * {
                         *  if (item.DataItem is InputBase && (item.DataItem as InputBase).Type == "TXT" && (item.DataItem as InputText).Text == (string)e.OldValue)
                         *      (item.DataItem as InputText).Text = (string)e.NewValue;
                         *  if (item.DataItem is InputBase && (item.DataItem as InputBase).Type == "IMG" && (item.DataItem as InputImage).Image == (string)e.OldValue)
                         *      (item.DataItem as InputImage).Image = (string)e.NewValue;
                         *
                         * }*/
                    }
                    //BindingOperations.SetBinding(d, TextProperty, bnd);
                }
                catch (Exception) { }
                //(d as vMixControlTextField).Update();
                ///TODO: Non defined behavior, rewrite

                /*var obj = (vMixControlTextField)d;
                 * if (obj._updating) return;
                 * var text = e.NewValue as string;
                 * if (obj.Paths != null && obj.State != null)
                 *  foreach (var item in obj.Paths)
                 *  {
                 *      var input = (Input)obj.GetValueByPath(obj.State, string.Format("Inputs[{0}]", item.A));
                 *      if (input != null)
                 *      {
                 *          var val = input.Elements.Where(x => (x is InputBase) && (x as InputBase).Name == item.B).FirstOrDefault();
                 *          if (val != null)
                 *          {
                 *              var prop = val.GetType().GetProperty(((vMixControlTextField)d).MappedProperty);
                 *              if (prop != null)
                 *                  prop.SetValue(val, text);
                 *          }
                 *      }
                 *  }*/
            }
        }
        private void Grid_Drop(object sender, System.Windows.DragEventArgs e)
        {
            ViewModel.State.Content = (e.Data.GetData(typeof(AudioListItemViewModel)) as IAudioListItemViewModel).Item.Audio;

            var expr = BindingOperations.GetMultiBindingExpression(CurrentAudioTextBlock, TextBlock.TextProperty);

            if (expr != null)
            {
                expr.UpdateTarget();
            }
        }
예제 #17
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (State != null)
            {
                var childrenCount = (TextBlock)GetTemplateChild("PART_ChildrenCount");
                var expr          = BindingOperations.GetMultiBindingExpression(childrenCount, TextBlock.TextProperty);
                expr.UpdateTarget();
            }
        }
예제 #18
0
        protected async Task RemoveBindingFromFalloalCargarAsync(aVMTabBase removedTab, FalloAlCargarUC UC)
        {
            MultiBinding falloMultiBinding = BindingOperations.GetMultiBindingExpression(UC, FalloAlCargarUC.VisibilityProperty).ParentMultiBinding;

            var bindingsToRemove = falloMultiBinding.Bindings.Where(binding => ((Binding)binding).Source == removedTab);

            foreach (BindingBase binding in bindingsToRemove)
            {
                falloMultiBinding.Bindings.Remove(binding);
            }
        }
예제 #19
0
        /// <summary>
        /// Update the text when focus is lost.
        /// </summary>
        /// <param name="e">The event arguments.</param>
        protected override void  OnLostKeyboardFocus(System.Windows.Input.KeyboardFocusChangedEventArgs e)
        {
            MultiBindingExpression bindingExpression = BindingOperations.GetMultiBindingExpression(this, EnumTextBox.TextProperty);

            base.OnLostKeyboardFocus(e);

            // For some reason, the selection isn't getting cleared when we lose keyboard focus, so we force it here.
            this.SelectionLength = 0;

            // Make sure the display looks reflects the underlying values.
            bindingExpression.UpdateTarget();
        }
예제 #20
0
        private void PackageIconImage_ImageFailed(object sender, ExceptionRoutedEventArgs e)
        {
            var image = sender as Image;

            e.Handled = true; // don't repropagate the event
            MultiBindingExpression binding = BindingOperations.GetMultiBindingExpression(image, Image.SourceProperty);

            if (binding != null && binding.BindingExpressions.All((x) => x.Status != BindingStatus.Detached))
            {
                binding.UpdateTarget();
            }
        }
예제 #21
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            Loaded -= OnLoaded;

            if (BindingOperations.GetBindingExpression(this, FormattedTextProperty) == null &&
                BindingOperations.GetMultiBindingExpression(this, FormattedTextProperty) == null)
            {
                SetBinding(FormattedTextProperty, new Binding()
                {
                    Path = new PropertyPath("Text"), Source = this
                });
            }
        }
예제 #22
0
        private void btnRangedWeaponSpec_Click(object sender, RoutedEventArgs e)
        {
            if (player.RangedWeapon == null)
            {
                return;
            }

            EditWeaponSpecWindow window = new EditWeaponSpecWindow(player, player.RangedWeaponSpec);

            window.ShowDialog(this);

            BindingOperations.GetMultiBindingExpression(txtRangedWeaponSpec, TextBlock.TextProperty).UpdateTarget();
        }
예제 #23
0
        private void Binding_TargetUpdated(object sender, DataTransferEventArgs e)
        {
            string txt = TestTextBox.Text;

            mbindingExpression =
                BindingOperations.GetMultiBindingExpression(e.TargetObject, e.Property);
            mbindingExpression.UpdateSource();

            foreach (var bind in mbindingExpression.BindingExpressions)
            {
                bind.UpdateSource();
            }
        }
예제 #24
0
        BindingExpression GetBinding()
        {
            var binding = AssociatedObject.GetBindingExpression(ListBox.ItemsSourceProperty);

            if (binding == null)
            {
                var m = BindingOperations.GetMultiBindingExpression(AssociatedObject, ItemsControl.ItemsSourceProperty);
                if (m != null && m.BindingExpressions.Count > 0)
                {
                    binding = (BindingExpression)m.BindingExpressions[0];
                }
            }
            return(binding);
        }
        void TestWindowMultiBinding(Window w)
        {
            var textBox = (TextBox)w.Content;

            var expr = BindingOperations.GetMultiBindingExpression(textBox, TextBox.TextProperty);

            Assert.IsNotNull(expr);

            var converter = expr.ParentMultiBinding.Converter as MyMultiConverter;

            Assert.IsNotNull(converter);

            Assert.AreEqual(expr.ParentMultiBinding.Bindings.Count, 2);
        }
예제 #26
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            Loaded -= OnLoaded;

            if (BindingOperations.GetBindingExpression(this, FormattedTextProperty) == null &&
                BindingOperations.GetMultiBindingExpression(this, FormattedTextProperty) == null)
            {
                SetBinding(FormattedTextProperty, new Binding {
                    Path = new PropertyPath("Text"), Source = this
                });
            }

            DataContextChanged += OnDataContextChanged;
            OnDataContextChanged(null, new DependencyPropertyChangedEventArgs());
        }
예제 #27
0
 private static void DelayedUpdateTimer_Tick(object sender, EventArgs e)
 {
     while (DelayedUpdate.Count > 0 && DelayedUpdate.Peek().C.AddSeconds(0.1) < DateTime.Now)
     {
         var t = DelayedUpdate.Dequeue();
         try
         {
             var exp = BindingOperations.GetMultiBindingExpression(t.A, t.B);
             if (exp != null && exp.Status == BindingStatus.Active && exp.BindingExpressions.Count > 0)
             {
                 exp.UpdateSource();
             }
         }
         catch (Exception) { }
     }
 }
 private void OnTick(object sender, EventArgs e)
 {
     if (!_timerStoped)
     {
         var bindingExpression = BindingOperations.GetBindingExpression(AssociatedObject, DependencyProperty);
         if (bindingExpression != null)
         {
             bindingExpression?.UpdateTarget();
         }
         else
         {
             var mbe = BindingOperations.GetMultiBindingExpression(AssociatedObject, DependencyProperty);
             mbe?.UpdateTarget();
         }
     }
 }
예제 #29
0
        void ResetDefaultClick(object sender, RoutedEventArgs e)
        {
            var tag      = (sender as Button).Tag;
            var dbParams = new List <DBParam>();

            if (tag is DBParam)
            {
                dbParams.Add(tag as DBParam);
            }
            else
            {
                dbParams.AddRange(parameters.Items.OfType <DBParam>());
            }
            dbParams.ForEach(dbParam => dbParam.ResetDefault());
            BindingOperations.GetMultiBindingExpression(parameters, DataGrid.ItemsSourceProperty).UpdateSource();
        }
예제 #30
0
        private void btnInvRangedWeapon_Click(object sender, RoutedEventArgs e)
        {
            if (player.RangedWeapon == null)
            {
                return;
            }

            EditWeaponWindow window = new EditWeaponWindow(player, player.RangedWeapon, false);

            if (window.ShowDialog(this))
            {
                player.RangedWeapon.CopyValues(window.Weapon);
                player.WeaponBonuses[player.RangedWeapon].CopyValues(window.ToHitAdjustments, window.DamageAdjustments);
                BindingOperations.GetMultiBindingExpression(txtRangedWeaponSpec, TextBlock.TextProperty).UpdateTarget();
            }
        }