Exemple #1
0
 private static void CalculateCellSizes_Changed (Grid grid, DpChangedEventArgs<bool> args)
 {
     if (args.NewValue)
         grid.SizeChanged += Grid_OnSizeChanged;
     else
         grid.SizeChanged -= Grid_OnSizeChanged;
 }
Exemple #2
0
 private static void ValidationIcon_Changed(FrameworkElement control, DpChangedEventArgs <FrameworkElement> args)
 {
     if (args.OldValue != null)
     {
         control.SizeChanged       -= UpdatePopup;
         control.GotKeyboardFocus  -= UpdatePopup;
         control.LostKeyboardFocus -= UpdatePopup;
         if (control is TextBoxBase)
         {
             ((TextBox)control).TextChanged -= UpdatePopup;
         }
         control.ClearValue(Validation.ErrorTemplateProperty);
     }
     if (args.NewValue != null)
     {
         GetOrCreateTooltipPopup(control);
         control.SizeChanged       += UpdatePopup;
         control.GotKeyboardFocus  += UpdatePopup;
         control.LostKeyboardFocus += UpdatePopup;
         if (control is TextBoxBase)
         {
             ((TextBox)control).TextChanged += UpdatePopup;
         }
         control.SetValue(Validation.ErrorTemplateProperty, null);
     }
     UpdatePopup(control, EventArgs.Empty);
 }
Exemple #3
0
 private static void DialogButtons_Changed(Window window, DpChangedEventArgs <DialogButton> args)
 {
     if (args != null && GetLeftDialogButtons(window) == null) // args check to get rid of unused warning
     {
         SetLeftDialogButtons(window, new ObservableCollection <Visual>());
     }
 }
Exemple #4
0
 private static void Template_Changed(DependencyObject d, DpChangedEventArgs <bool> args)
 {
     if (args.NewValue)
     {
         BindingOperations.SetBinding(d, CaliburnMicro.Bind.ModelWithoutContextProperty, new Binding());
     }
 }
Exemple #5
0
 private static void ForceCellSizes_Changed(Grid grid, DpChangedEventArgs <bool> args)
 {
     if (args.NewValue)
     {
         Action initDummyGrid = () => {
             Grid parentGrid = (Grid)grid.Parent, dummyGrid = CreateDummyGrid(grid);
             parentGrid.Children.Add(dummyGrid);
             SetDummyGrid(grid, dummyGrid);
         };
         if (grid.IsLoaded)
         {
             initDummyGrid();
         }
         else
         {
             grid.Loaded += (o, e) => initDummyGrid();
         }
     }
     else
     {
         Grid parentGrid = (Grid)grid.Parent, dummyGrid = DestroyDummyGrid(grid);
         parentGrid.Children.Remove(dummyGrid);
         SetDummyGrid(grid, null);
     }
 }
Exemple #6
0
 private static void AttachMany_Changed(DependencyObject d, DpChangedEventArgs <string> args)
 {
     CaliburnMicro.Message.SetAttach(d, args.NewValue
                                     .Split(AttachSeparators, StringSplitOptions.RemoveEmptyEntries)
                                     .Where(a => !a.IsNullOrWhitespace())
                                     .Select(GetAttachMessageItem)
                                     .JoinString("; "));
 }
Exemple #7
0
 private static void ButtonResult_Changed(ButtonBase button, DpChangedEventArgs <DialogButton> args)
 {
     button.Click += (s, a) => {
         var win = Window.GetWindow(button);
         Contract.Assume(win != null);
         SetDialogResult(win, args.NewValue);
         win.Close();
     };
 }
 private static void SelectedItemSync_Changed (TreeView tree, DpChangedEventArgs<bool> args)
 {
     if (args.OldValue)
         tree.SelectedItemChanged -= TreeView_SelectedItemChanged;
     if (args.NewValue) {
         tree.SelectedItemChanged += TreeView_SelectedItemChanged;
         var item = GetSelectedItem(tree);
         TreeView_SelectedItemChanged(tree, new RoutedPropertyChangedEventArgs<object>(item, item));
     }
 }
 private static void SelectedItems_Changed (Selector selector, DpChangedEventArgs<IList> e)
 {
     SelectedItemsSync sync = GetSelectedItemsSync(selector);
     if (sync != null) {
         sync.ModelSelectedItems = e.NewValue;
     }
     else {
         SetSelectedItemsSync(selector, new SelectedItemsSync(selector, e.NewValue));
         selector.Unloaded += Selector_Unloaded;
     }
 }
Exemple #10
0
 private static void CalculateCellSizes_Changed(Grid grid, DpChangedEventArgs <bool> args)
 {
     if (args.NewValue)
     {
         grid.SizeChanged += Grid_OnSizeChanged;
     }
     else
     {
         grid.SizeChanged -= Grid_OnSizeChanged;
     }
 }
Exemple #11
0
 private static void SelectedItemSync_Changed(TreeView tree, DpChangedEventArgs <bool> args)
 {
     if (args.OldValue)
     {
         tree.SelectedItemChanged -= TreeView_SelectedItemChanged;
     }
     if (args.NewValue)
     {
         tree.SelectedItemChanged += TreeView_SelectedItemChanged;
         var item = GetSelectedItem(tree);
         TreeView_SelectedItemChanged(tree, new RoutedPropertyChangedEventArgs <object>(item, item));
     }
 }
Exemple #12
0
        private static void SelectedItems_Changed(Selector selector, DpChangedEventArgs <IList> e)
        {
            SelectedItemsSync sync = GetSelectedItemsSync(selector);

            if (sync != null)
            {
                sync.ModelSelectedItems = e.NewValue;
            }
            else
            {
                SetSelectedItemsSync(selector, new SelectedItemsSync(selector, e.NewValue));
                selector.Unloaded += Selector_Unloaded;
            }
        }
 private static void AnimationVisibility_Changed (ProgressBar progress, DpChangedEventArgs<Visibility> args)
 {
     RoutedEventHandler handler = null;
     handler = (s, a) => {
         var animation = progress.Template.FindName("Animation", progress) as UIElement;
         if (animation != null)
             animation.Visibility = args.NewValue;
         progress.Loaded -= handler;
     };
     if (progress.Template == null)
         progress.Loaded += handler;
     else
         handler(progress, null);
 }
Exemple #14
0
 private static void Target_Changed(Timeline timeline, DpChangedEventArgs <string> args)
 {
     string[] nameAndProp = args.NewValue.Split(new[] { '.' }, 2);
     if (nameAndProp.Length != 2)
     {
         throw new ArgumentException("Target must be a name and a property, separated by a dot.");
     }
     if (!nameAndProp[0].IsNullOrEmpty())
     {
         Storyboard.SetTargetName(timeline, nameAndProp[0]);
     }
     if (!nameAndProp[1].IsNullOrEmpty())
     {
         Storyboard.SetTargetProperty(timeline, new PropertyPath(nameAndProp[1]));
     }
 }
Exemple #15
0
 private static void Placement_Changed (Window window, DpChangedEventArgs<WINDOWPLACEMENT> args)
 {
     if (_isChangingPlace)
         return;
     WINDOWPLACEMENT place = args.NewValue;
     if (!args.NewValue.IsEmpty) {
         window.WindowStartupLocation = WindowStartupLocation.Manual;
         window.Left = place.NormalPosition.Left;
         window.Top = place.NormalPosition.Top;
         window.Width = place.NormalPosition.Width;
         window.Height = place.NormalPosition.Height;
         SetNormalPosition(window, place.NormalPosition);
         window.WindowState = place.ShowCmd == SW.MAXIMIZE ? WindowState.Maximized : WindowState.Normal;
     }
     EnsureWindowPlaceSubscribtions(window);
 }
Exemple #16
0
 private static void ForceCellSizes_Changed (Grid grid, DpChangedEventArgs<bool> args)
 {
     if (args.NewValue) {
         Action initDummyGrid = () => {
             Grid parentGrid = (Grid)grid.Parent, dummyGrid = CreateDummyGrid(grid);
             parentGrid.Children.Add(dummyGrid);
             SetDummyGrid(grid, dummyGrid);
         };
         if (grid.IsLoaded)
             initDummyGrid();
         else
             grid.Loaded += (o, e) => initDummyGrid();
     }
     else {
         Grid parentGrid = (Grid)grid.Parent, dummyGrid = DestroyDummyGrid(grid);
         parentGrid.Children.Remove(dummyGrid);
         SetDummyGrid(grid, null);
     }
 }
Exemple #17
0
 private static void WindowButtons_Changed(Window window, DpChangedEventArgs <WindowButton> args)
 {
     window.InvokeOnHandle(() => {
         WS style      = window.GetWindowStyle();
         WS_EX styleEx = window.GetWindowStyleEx();
         SetBitIf(ref style, WS.SYSMENU, args.NewValue & WindowButton.System);
         SetBitIf(ref style, WS.MINIMIZEBOX, args.NewValue & WindowButton.Minimize);
         SetBitIf(ref style, WS.MAXIMIZEBOX, args.NewValue & WindowButton.Maximize);
         SetBitIf(ref styleEx, WS_EX.CONTEXTHELP, args.NewValue & WindowButton.Help);
         SetBitIf(ref styleEx, WS_EX.DLGMODALFRAME, ~(args.NewValue & WindowButton.Icon));
         window.SetWindowStyle(style);
         window.SetWindowStyleEx(styleEx);
         if ((args.NewValue & WindowButton.Icon) == 0)
         {
             window.ClearWindowIcons();
         }
         window.SetWindowPos(flags: SWP.FRAMECHANGED);
     });
 }
Exemple #18
0
        private static void Placement_Changed(Window window, DpChangedEventArgs <WINDOWPLACEMENT> args)
        {
            if (_isChangingPlace)
            {
                return;
            }
            WINDOWPLACEMENT place = args.NewValue;

            if (!args.NewValue.IsEmpty)
            {
                window.WindowStartupLocation = WindowStartupLocation.Manual;
                window.Left   = place.NormalPosition.Left;
                window.Top    = place.NormalPosition.Top;
                window.Width  = place.NormalPosition.Width;
                window.Height = place.NormalPosition.Height;
                SetNormalPosition(window, place.NormalPosition);
                window.WindowState = place.ShowCmd == SW.MAXIMIZE ? WindowState.Maximized : WindowState.Normal;
            }
            EnsureWindowPlaceSubscribtions(window);
        }
 private static void ValidationIcon_Changed (FrameworkElement control, DpChangedEventArgs<FrameworkElement> args)
 {
     if (args.OldValue != null) {
         control.SizeChanged -= UpdatePopup;
         control.GotKeyboardFocus -= UpdatePopup;
         control.LostKeyboardFocus -= UpdatePopup;
         if (control is TextBoxBase)
             ((TextBox)control).TextChanged -= UpdatePopup;
         control.ClearValue(Validation.ErrorTemplateProperty);
     }
     if (args.NewValue != null) {
         GetOrCreateTooltipPopup(control);
         control.SizeChanged += UpdatePopup;
         control.GotKeyboardFocus += UpdatePopup;
         control.LostKeyboardFocus += UpdatePopup;
         if (control is TextBoxBase)
             ((TextBox)control).TextChanged += UpdatePopup;
         control.SetValue(Validation.ErrorTemplateProperty, null);
     }
     UpdatePopup(control, EventArgs.Empty);
 }
        private static void AnimationVisibility_Changed(ProgressBar progress, DpChangedEventArgs <Visibility> args)
        {
            RoutedEventHandler handler = null;

            handler = (s, a) => {
                var animation = progress.Template.FindName("Animation", progress) as UIElement;
                if (animation != null)
                {
                    animation.Visibility = args.NewValue;
                }
                progress.Loaded -= handler;
            };
            if (progress.Template == null)
            {
                progress.Loaded += handler;
            }
            else
            {
                handler(progress, null);
            }
        }
Exemple #21
0
 private static void SelectedItem_Changed(TreeView tree, DpChangedEventArgs <object> args)
 {
 }
Exemple #22
0
 private static void SelectedItem_Changed (TreeView tree, DpChangedEventArgs<object> args)
 {}
Exemple #23
0
 private static void Template_Changed (DependencyObject d, DpChangedEventArgs<bool> args)
 {
     if (args.NewValue)
         BindingOperations.SetBinding(d, CaliburnMicro.Bind.ModelWithoutContextProperty, new Binding());
 }
Exemple #24
0
 private static void Animate_Changed(FrameworkElement ctl, DpChangedEventArgs <bool> args)
 {
     SetAnimations(ctl, new AnimationCollection(ctl));
 }
Exemple #25
0
 private static void MinInt_Changed(RangeBase slider, DpChangedEventArgs <int> args)
 {
     slider.SetCurrentValue(RangeBase.MinimumProperty, (double)args.NewValue);
 }
Exemple #26
0
 private static void MinInt_Changed (RangeBase slider, DpChangedEventArgs<int> args)
 {
     slider.SetCurrentValue(RangeBase.MinimumProperty, (double)args.NewValue);
 }