/// <summary> /// Initializes a new instance of the <see cref="HamburgerMenu"/> class. /// </summary> public HamburgerMenu() { DefaultStyleKey = typeof(HamburgerMenu); actualWidthPropertyChangeNotifier = new PropertyChangeNotifier(this, ActualWidthProperty); actualWidthPropertyChangeNotifier.ValueChanged += (s, e) => CoerceValue(OpenPaneLengthProperty); }
public static IDisposable Track(this DataGrid dataGrid, DataGridSetting dataGridSetting) { EventHandler <DataGridColumnEventArgs> columnDisplayIndexChanged = (sender, args) => DataGridColumnDisplayIndexChanged(dataGridSetting, args); DataGridSortingEventHandler dataGridSortingChanged = (sender, args) => DataGridSorting(dataGridSetting, args); dataGrid.ColumnDisplayIndexChanged += columnDisplayIndexChanged; dataGrid.Sorting += dataGridSortingChanged; var notifiers = new List <PropertyChangeNotifier>(); foreach (var column in dataGrid.Columns) { EventHandler ev = (sender, x) => WidthChanged(column, dataGridSetting); var notifier = new PropertyChangeNotifier(column, DataGridColumn.ActualWidthProperty); notifier.ValueChanged += ev; notifiers.Add(notifier); } return(Disposable.Create(() => { dataGrid.ColumnDisplayIndexChanged -= columnDisplayIndexChanged; dataGrid.Sorting -= dataGridSortingChanged; notifiers.DoForEach( notifier => notifier.Dispose()); })); }
/// <summary> /// Creates a new element wrapper for observing visibility changes and hold weak references. /// </summary> /// <param name="element"></param> /// <param name="onValueChanged">The event handler for <see cref="UIElement.IsVisible"/> changes.</param> /// <remarks> /// In some situations such as when using drag & drop in docked settings, such as ActiproSoftware docking, the user can start /// dragging an element to the tab of a Docking/Tool window and drop in a new window. Without handling the changes to visibility, /// the hint adorner will not be displayed when the element becomes visible. Likewise, drop hint adorners for elements that gets /// hidden should no longer be visible. /// </remarks> public HintTargetElementWrapper(UIElement element, EventHandler onValueChanged) { this.onValueChanged = onValueChanged; this._element = new WeakReference <UIElement>(element); this._propertyChangedNotifier = new PropertyChangeNotifier <UIElement>(element, UIElement.IsVisibleProperty); this._propertyChangedNotifier.ValueChanged += this.onValueChanged; }
/// <summary> /// Inicialização /// Podemos adicionar novas opções de menu aqui /// IN: /// e.get_data(): ExtendedPropertyList /// "PropertyChangeNotifier" = Evento que podemos subscrever para controlar quando uma propriedade é alterada /// "TransactionManager" = BSOItemTransaction; Controlador da transação em curso /// /// OUT: /// result.Sucess: true para sinalizar sucesso e carregar novos menus; false para cancelar /// result.ResultMessage: Ignorado /// result.set_data( ExtenderMenuItems ): Items de menu a carregar /// </summary> /// <param name="Sender"></param> /// <param name="e"></param> void HeaderEvents_OnInitialize(object Sender, ExtenderEventArgs e) { var propList = (ExtendedPropertyList)e.get_data(); propChangeNotifier = (PropertyChangeNotifier)propList.get_Value("PropertyChangeNotifier"); propChangeNotifier.PropertyChanged += OnPropertyChanged; bsoItemTrans = (BSOItemTransaction)propList.get_Value("TransactionManager"); bsoItemTrans.WarningItemStock += BsoItemTrans_WarningItemStock; // Colocar o caminho para o icone. // Não usar os nomes de ficheiro da Sage em: // TARGETDIR\Icons50c // TARGETDIR\Images var myTargetDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName); myTargetDir = System.IO.Path.Combine(myTargetDir, "Icons"); var newMenus = new ExtenderMenuItems(); // //Criar o grupo: Tab var mnuGroup = newMenus.Add("mniXCustomTools", "Custom Tools"); //criar item1 var mnuItem1 = mnuGroup.ChildItems.Add("mniXTrans1", "Custom Item 1"); mnuItem1.GroupType = ExtenderGroupType.ExtenderGroupTypeExtraOptions; mnuItem1.PictureName = System.IO.Path.Combine(myTargetDir, "icon-save.ico"); //mnuItem1.PictureName = System.IO.Path.Combine(myTargetDir, "icon-sample-01.png"); //criar item2 mnuItem1 = mnuGroup.ChildItems.Add("mniXTrans2", "Custom Item 2"); mnuItem1.GroupType = ExtenderGroupType.ExtenderGroupTypeExtraOptions; mnuItem1.PictureName = System.IO.Path.Combine(myTargetDir, "icon-sample-02.png"); object returnMenu = newMenus; e.result.set_data(returnMenu); }
public static bool Change <T>( this IPropertyOwner owner, T oldValue, T value, Action setter, [CallerMemberName] string propertyName = null, params string[] derivedProperties) { if (AreEqual(oldValue, value)) { return(false); } string isDefaultedPropertyName = PropertyOwnerExtensions.IsDefaultedPropertyName(propertyName); bool isDefaultedChange = owner.HasProperty(isDefaultedPropertyName) && (owner.IsDefaulted(propertyName) ^ ((object)value is null)); PropertyChangeNotifier.OnChanging(owner, propertyName); if (isDefaultedChange) { PropertyChangeNotifier.OnChanging(owner, isDefaultedPropertyName); } if (derivedProperties?.Any() ?? false) { PropertyChangeNotifier.OnChanging(owner, derivedProperties); } setter(); PropertyChangeNotifier.OnChanged(owner, propertyName); if (isDefaultedChange) { PropertyChangeNotifier.OnChanged(owner, isDefaultedPropertyName); } if (derivedProperties?.Any() ?? false) { PropertyChangeNotifier.OnChanged(owner, derivedProperties); } return(true); }
private void HeaderStockEvents_OnInitialize(object Sender, ExtenderEventArgs e) { var propList = (ExtendedPropertyList)e.get_data(); propaChangeNotifier = (PropertyChangeNotifier)propList.get_Value("PropertyChangeNotifier"); propaChangeNotifier.PropertyChanged += OnaPropertyChanged; bsoStockTrans = (BSOStockTransaction)propList.get_Value("TransactionManager"); e.result.ResultMessage = "HeaderEvents_OnInitialize"; var newMenus1 = new ExtenderMenuItems(); // //Criar o grupo: Tab var mnuGroup1 = newMenus1.Add("mniXCustomTools1", "Custom Tools"); //criar item1 var mnuItem1 = mnuGroup1.ChildItems.Add("mniXTrans11", "Custom Item 1"); mnuItem1.GroupType = ExtenderGroupType.ExtenderGroupTypeExtraOptions; //mnuItem1.Picture = ImageConverter.GetIPictureDispFromImage( ) //criar item2 mnuItem1 = mnuGroup1.ChildItems.Add("mniXTrans21", "Custom Item 2"); mnuItem1.GroupType = ExtenderGroupType.ExtenderGroupTypeExtraOptions; object returnMenu = newMenus1; e.result.set_data(returnMenu); }
/// <summary> /// Inicialização /// Podemos adicionar novas opções de menu aqui /// IN: /// e.get_data(): ExtendedPropertyList /// "PropertyChangeNotifier" = Evento que podemos subscrever para controlar quando uma propriedade é alterada /// "TransactionManager" = BSOItemTransaction; Controlador da transação em curso /// /// OUT: /// result.Sucess: true para sinalizar sucesso e carregar novos menus; false para cancelar /// result.ResultMessage: Ignorado /// result.set_data( ExtenderMenuItems ): Items de menu a carregar /// </summary> /// <param name="Sender"></param> /// <param name="e"></param> void HeaderEvents_OnInitialize(object Sender, ExtenderEventArgs e) { var propList = (ExtendedPropertyList)e.get_data(); propChangeNotifier = (PropertyChangeNotifier)propList.get_Value("PropertyChangeNotifier"); propChangeNotifier.PropertyChanged += OnPropertyChanged; bsoItemTrans = (BSOItemTransaction)propList.get_Value("TransactionManager"); bsoItemTrans.WarningItemStock += BsoItemTrans_WarningItemStock; var newMenus = new ExtenderMenuItems(); // //Criar o grupo: Tab var mnuGroup = newMenus.Add("mniXCustomTools", "Custom Tools"); //criar item1 var mnuItem1 = mnuGroup.ChildItems.Add("mniXTrans1", "Custom Item 1"); mnuItem1.GroupType = ExtenderGroupType.ExtenderGroupTypeExtraOptions; //mnuItem1.Picture = ImageConverter.GetIPictureDispFromImage( ) //criar item2 mnuItem1 = mnuGroup.ChildItems.Add("mniXTrans2", "Custom Item 2"); mnuItem1.GroupType = ExtenderGroupType.ExtenderGroupTypeExtraOptions; object returnMenu = newMenus; e.result.set_data(returnMenu); }
public RCONWindow(RCONParameters parameters) { InitializeComponent(); WindowUtils.RemoveDefaultResourceDictionary(this); this.CurrentInputWindowMode = InputWindowMode.None; this.RCONParameters = parameters; this.PlayerFiltering = (PlayerFilterType)Config.Default.RCON_PlayerListFilter; this.PlayerSorting = (PlayerSortType)Config.Default.RCON_PlayerListSort; this.ServerRCON = new ServerRCON(parameters); this.ServerRCON.RegisterCommandListener(RenderRCONCommandOutput); this.PlayersView = CollectionViewSource.GetDefaultView(this.ServerRCON.Players); this.PlayersView.Filter = p => { var player = p as PlayerInfo; return((this.PlayerFiltering.HasFlag(PlayerFilterType.Online) && player.IsOnline) || (this.PlayerFiltering.HasFlag(PlayerFilterType.Offline) && !player.IsOnline) || (this.PlayerFiltering.HasFlag(PlayerFilterType.Banned) && player.IsBanned) || (this.PlayerFiltering.HasFlag(PlayerFilterType.Whitelisted) && player.IsWhitelisted)); }; var notifier = new PropertyChangeNotifier(this.ServerRCON, ServerRCON.StatusProperty, (s, a) => { this.RenderConnectionStateChange(a); }); this.DataContext = this; AddCommentsBlock( "Enter commands or chat into the box at the bottom.", "In Command mode, everything you enter will be a normal admin command", "In Broadcast mode, everything you enter will be a global broadcast", "You may always prefix a command with / to be treated as a command and not chat.", "Right click on players in the list to access player commands", "Type /help to get help"); if (this.RCONParameters.RCONWindowExtents.Width > 50 && this.RCONParameters.RCONWindowExtents.Height > 50) { this.Left = this.RCONParameters.RCONWindowExtents.Left; this.Top = this.RCONParameters.RCONWindowExtents.Top; this.Width = this.RCONParameters.RCONWindowExtents.Width; this.Height = this.RCONParameters.RCONWindowExtents.Height; // // Fix issues where the console was saved while offscreen. if (this.Left == -32000) { this.Left = 0; } if (this.Top == -32000) { this.Top = 0; } } this.ConsoleInput.Focus(); }
protected override void OnAttached() { windowChrome = new WindowChrome { ResizeBorderThickness = SystemParameters2.Current.WindowResizeBorderThickness, CaptionHeight = 0, CornerRadius = new CornerRadius(0), GlassFrameThickness = new Thickness(0), UseAeroCaptionButtons = false }; var metroWindow = AssociatedObject as MetroWindow; if (metroWindow != null) { windowChrome.IgnoreTaskbarOnMaximize = metroWindow.IgnoreTaskbarOnMaximize; windowChrome.UseNoneWindowStyle = metroWindow.UseNoneWindowStyle; System.ComponentModel.DependencyPropertyDescriptor.FromProperty(MetroWindow.IgnoreTaskbarOnMaximizeProperty, typeof(MetroWindow)) .AddValueChanged(AssociatedObject, IgnoreTaskbarOnMaximizePropertyChangedCallback); System.ComponentModel.DependencyPropertyDescriptor.FromProperty(MetroWindow.UseNoneWindowStyleProperty, typeof(MetroWindow)) .AddValueChanged(AssociatedObject, UseNoneWindowStylePropertyChangedCallback); } AssociatedObject.SetValue(WindowChrome.WindowChromeProperty, windowChrome); // no transparany, because it hase more then one unwanted issues var windowHandle = new WindowInteropHelper(AssociatedObject).Handle; if (!AssociatedObject.IsLoaded && windowHandle == IntPtr.Zero) { try { AssociatedObject.AllowsTransparency = false; } catch (Exception) { //For some reason, we can't determine if the window has loaded or not, so we swallow the exception. } } AssociatedObject.WindowStyle = WindowStyle.None; savedBorderThickness = AssociatedObject.BorderThickness; borderThicknessChangeNotifier = new PropertyChangeNotifier(this.AssociatedObject, Window.BorderThicknessProperty); borderThicknessChangeNotifier.ValueChanged += BorderThicknessChangeNotifierOnValueChanged; savedTopMost = AssociatedObject.Topmost; topMostChangeNotifier = new PropertyChangeNotifier(this.AssociatedObject, Window.TopmostProperty); topMostChangeNotifier.ValueChanged += TopMostChangeNotifierOnValueChanged; AssociatedObject.Loaded += AssociatedObject_Loaded; AssociatedObject.Unloaded += AssociatedObject_Unloaded; AssociatedObject.SourceInitialized += AssociatedObject_SourceInitialized; AssociatedObject.StateChanged += OnAssociatedObjectHandleMaximize; // handle the maximized state here too (to handle the border in a correct way) this.HandleMaximize(); base.OnAttached(); }
private IDisposable IsExpanded(Expander expander) { EventHandler ev = (s, x) => IsExpandedChanged(expander); var notifer = new PropertyChangeNotifier(expander, Expander.IsExpandedProperty); notifer.ValueChanged += ev; return(Disposable.Create(notifer.Dispose)); }
private IDisposable TrackRowDefinition(RowDefinition rowDefinition) { EventHandler ev = (s, x) => HeightChanged(rowDefinition); var notifier = new PropertyChangeNotifier(rowDefinition, RowDefinition.HeightProperty); notifier.ValueChanged += ev; return(Disposable.Create(notifier.Dispose)); }
public void Dispose() { headerEvents = null; detailEvents = null; if (bsoItemTrans != null) { bsoItemTrans.WarningItemStock -= BsoItemTrans_WarningItemStock; bsoItemTrans = null; } propChangeNotifier = null; }
public void Dispose() { headerEvents = null; detailEvents = null; if (_tenderTransactionManager != null) { _tenderTransactionManager = null; } _propChangeNotifier = null; }
public RCONWindow(RCONParameters parameters) { InitializeComponent(); WindowUtils.RemoveDefaultResourceDictionary(this); this.CurrentInputWindowMode = InputWindowMode.None; this.PlayerFiltering = (PlayerFilterType)Config.Default.RCON_PlayerListFilter; this.PlayerSorting = (PlayerSortType)Config.Default.RCON_PlayerListSort; this.RCONParameters = parameters; this.ServerRCON = new ServerRCON(parameters); this.ServerRCON.RegisterCommandListener(RenderRCONCommandOutput); this.ServerRCON.Players.CollectionChanged += Players_CollectionChanged; this.ServerRCON.PlayersCollectionUpdated += Players_CollectionUpdated; this.PlayersView = CollectionViewSource.GetDefaultView(this.ServerRCON.Players); this.PlayersView.Filter = new Predicate <object>(PlayerFilter); var notifier = new PropertyChangeNotifier(this.ServerRCON, ServerRCON.StatusProperty, (s, a) => { this.RenderConnectionStateChange(a); }); this.DataContext = this; AddCommentsBlock( _globalizer.GetResourceString("RCON_Comments_Line1"), _globalizer.GetResourceString("RCON_Comments_Line2"), _globalizer.GetResourceString("RCON_Comments_Line3"), _globalizer.GetResourceString("RCON_Comments_Line4"), _globalizer.GetResourceString("RCON_Comments_Line5"), String.Format(_globalizer.GetResourceString("RCON_Comments_Line6"), _globalizer.GetResourceString("RCON_Help_Keyword"))); if (this.RCONParameters.RCONWindowExtents.Width > 50 && this.RCONParameters.RCONWindowExtents.Height > 50) { this.Left = this.RCONParameters.RCONWindowExtents.Left; this.Top = this.RCONParameters.RCONWindowExtents.Top; this.Width = this.RCONParameters.RCONWindowExtents.Width; this.Height = this.RCONParameters.RCONWindowExtents.Height; // // Fix issues where the console was saved while offscreen. if (this.Left == -32000) { this.Left = 0; } if (this.Top == -32000) { this.Top = 0; } } this.ConsoleInput.Focus(); }
internal void ActivateSourceListener() { if (Source != null && !_posTracersActivatedS) { _sourceTrace = Source.EventOptions.PositionChangeNotification; Source.EventOptions.PositionChangeNotification = true; Source.PositionChanged += source_PositionChanged; _sourceListener = new PropertyChangeNotifier(this, SourceProperty); _sourceListener.ValueChanged += SourceChanged; _posTracersActivatedS = true; } }
internal void ActivateTargetListener() { if (Target != null && !_posTracersActivatedT) { _targetTrace = Target.EventOptions.PositionChangeNotification; Target.EventOptions.PositionChangeNotification = true; Target.PositionChanged += source_PositionChanged; _targetListener = new PropertyChangeNotifier(this, TargetProperty); _targetListener.ValueChanged += TargetChanged; _posTracersActivatedT = true; } }
public SplitterHandler() { Control = new EtoGrid { Handler = this }; xcolumn = new swc.ColumnDefinition(); Control.ColumnDefinitions.Add(xcolumn); Control.ColumnDefinitions.Add(new swc.ColumnDefinition() { Width = sw.GridLength.Auto }); Control.ColumnDefinitions.Add(new swc.ColumnDefinition()); ycolumn = new swc.RowDefinition(); Control.RowDefinitions.Add(ycolumn); Control.RowDefinitions.Add(new swc.RowDefinition { Height = sw.GridLength.Auto }); Control.RowDefinitions.Add(new swc.RowDefinition()); splitter = new swc.GridSplitter { //Background = sw.SystemColors.ControlLightLightBrush, ResizeBehavior = swc.GridResizeBehavior.PreviousAndNext }; pane1 = new swc.DockPanel { LastChildFill = true }; pane2 = new swc.DockPanel { LastChildFill = true }; Control.Children.Add(pane1); Control.Children.Add(splitter); Control.Children.Add(pane2); style = new sw.Style(); style.Setters.Add(new sw.Setter(sw.FrameworkElement.VerticalAlignmentProperty, sw.VerticalAlignment.Stretch)); style.Setters.Add(new sw.Setter(sw.FrameworkElement.HorizontalAlignmentProperty, sw.HorizontalAlignment.Stretch)); UpdateOrientation(); Control.Loaded += Control_Loaded; Control.SizeChanged += (sender, e) => ResetMinMax(); panel1VisibilityNotifier = new PropertyChangeNotifier(sw.UIElement.VisibilityProperty); panel1VisibilityNotifier.ValueChanged += HandlePanel1IsVisibleChanged; panel2VisibilityNotifier = new PropertyChangeNotifier(sw.UIElement.VisibilityProperty); panel2VisibilityNotifier.ValueChanged += HandlePanel2IsVisibleChanged; }
public override void AttachEvent(string id) { switch (id) { case RadioMenuItem.CheckedChangedEvent: Widget.Properties.Set(swc.MenuItem.IsCheckedProperty, PropertyChangeNotifier.Register(swc.MenuItem.IsCheckedProperty, HandleIsCheckedChanged, Control)); break; default: base.AttachEvent(id); break; } }
public override void AttachEvent(string id) { switch (id) { case Expander.ExpandedChangedEvent: Widget.Properties.Set(swc.Expander.IsExpandedProperty, PropertyChangeNotifier.Register(swc.Expander.IsExpandedProperty, HandleIsExpandedChanged, Control)); break; default: base.AttachEvent(id); break; } }
/// <summary> /// Creates a new instance of <see cref="AutoFilteredComboBox" />. /// </summary> public AutoFilteredComboBox() { if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) { return; } _monitorTextProperty = new PropertyChangeNotifier(this, ComboBox.TextProperty); _monitorTextProperty.ValueChanged += this.OnTextChanged; _monitorIsCaseSensitiveProperty = new PropertyChangeNotifier(this, IsCaseSensitiveProperty); _monitorIsCaseSensitiveProperty.ValueChanged += this.OnIsCaseSensitiveChanged; }
public static void AddVisibilityChangedHandler(DependencyObject d, EventHandler handler) { var pcn = new PropertyChangeNotifier(d, UI.Transitionz.Transitionz.VisibilityProperty); pcn.ValueChanged += handler; var currentValue = (Visibility)d.GetValue(Transitionz.VisibilityProperty); if (currentValue == Visibility.Visible) { // Execute handler now if already Visible handler(pcn, EventArgs.Empty); } }
protected override void OnAttached() { base.OnAttached(); // Versions can be taken from https://msdn.microsoft.com/library/windows/desktop/ms724832.aspx this.isWindwos10OrHigher = Environment.OSVersion.Version >= new Version(10, 0); this.InitializeWindowChrome(); this.AssociatedObject.SetValue(WindowChrome.WindowChromeProperty, this.windowChrome); // no transparany, because it hase more then one unwanted issues var windowHandle = new WindowInteropHelper(this.AssociatedObject).Handle; if (this.AssociatedObject.IsLoaded == false && windowHandle == IntPtr.Zero) { try { this.AssociatedObject.AllowsTransparency = false; } catch (Exception) { //For some reason, we can't determine if the window has loaded or not, so we swallow the exception. } } this.windowStyleChangeNotifier = new PropertyChangeNotifier(this.AssociatedObject, Window.WindowStyleProperty); this.windowStyleChangeNotifier.ValueChanged += this.OnPropertyChangedThatRequiresForceRedrawWindow; this.resizeModeChangeNotifier = new PropertyChangeNotifier(this.AssociatedObject, Window.ResizeModeProperty); this.resizeModeChangeNotifier.ValueChanged += this.OnPropertyChangedThatRequiresForceRedrawWindow; this.AssociatedObject.Loaded += this.OnAssociatedObjectLoaded; this.AssociatedObject.Unloaded += this.AssociatedObject_Unloaded; this.AssociatedObject.StateChanged += this.OnAssociatedObjectHandleWindowStateChanged; // If Window is already initialized if (PresentationSource.FromVisual(this.AssociatedObject) != null) { this.HandleSourceInitialized(); } else { this.AssociatedObject.SourceInitialized += this.OnAssociatedObjectSourceInitialized; } // handle the maximized state here too (to handle the border in a correct way) this.FixMaximizedWindow(); }
public static void RemoveVisibilityChangedHandler(DependencyObject d, EventHandler handler) { if (d == null) throw new ArgumentNullException("d"); var notifiers = PropertyChangeNotifier.GetNotifiers(d); if (notifiers == null) return; var pcn = notifiers.FirstOrDefault(n => n.PropertySource == d); if (pcn != null) { pcn.ValueChanged -= handler; pcn.Dispose(); notifiers.Remove(pcn); } }
/* * Mask Character Accepts Required? * 0 Digit (0-9) Required * 9 Digit (0-9) or space Optional # Digit (0-9) or space Required # L Letter (a-z, A-Z) Required # ? Letter (a-z, A-Z) Optional # &amp; Any character Required # C Any character Optional # A Alphanumeric (0-9, a-z, A-Z) Required # a Alphanumeric (0-9, a-z, A-Z) Optional # Space separator Required # . Decimal separator Required # , Group (thousands) separator Required # : Time separator Required # / Date separator Required # $ Currency symbol Required # # In addition, the following characters have special meaning: # # Mask Character Meaning # < All subsequent characters are converted to lower case # > All subsequent characters are converted to upper case | Terminates a previous &lt; or &gt; \ Escape: treat the next character in the mask as literal text rather than a mask symbol \ */ private void AssociatedObjectLoaded(object sender, System.Windows.RoutedEventArgs e) { this.Provider = new MaskedTextProvider(InputMask, CultureInfo.CurrentCulture); this.Provider.PromptChar = this.PromptChar; this.Provider.SkipLiterals = true; this.Provider.ResetOnSpace = this.ResetOnSpace; this.Provider.Set(HandleCharacterCasing(AssociatedObject.Text)); this.AssociatedObject.AllowDrop = false; this.AssociatedObject.Text = GetProviderText(); // seems the only way that the text is formatted correct, when source is updated // AddValueChanged for TextProperty in a weak manner this.textPropertyNotifier = new PropertyChangeNotifier(this.AssociatedObject, TextBox.TextProperty); this.textPropertyNotifier.ValueChanged += this.UpdateText; }
public override void AttachEvent(string id) { switch (id) { case Splitter.PositionChangedEvent: PositionChangedEnabled++; Widget.Properties.Set(swc.RowDefinition.HeightProperty, PropertyChangeNotifier.Register(swc.RowDefinition.HeightProperty, HandlePositionChanged, Control.RowDefinitions[0])); Widget.Properties.Set(swc.ColumnDefinition.WidthProperty, PropertyChangeNotifier.Register(swc.ColumnDefinition.WidthProperty, HandlePositionChanged, Control.ColumnDefinitions[0])); PositionChangedEnabled--; break; default: base.AttachEvent(id); break; } }
protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); this.hwndSource = (HwndSource)PresentationSource.FromVisual(this); if (this.hwndSource is null) { return; } this.windowHandle = this.hwndSource.Handle; var ownerWindowInteropHelper = new WindowInteropHelper(this.owner); this.ownerWindowHandle = ownerWindowInteropHelper.Handle; // Set parent to the owner of our owner, that way glows on modeless windows shown with an owner work correctly. // We must do that only in case our owner has an owner. if (ownerWindowInteropHelper.Owner != IntPtr.Zero) { NativeMethods.SetWindowLongPtr(this.windowHandle, GWL.HWNDPARENT, ownerWindowInteropHelper.Owner); } var ws = NativeMethods.GetWindowStyle(this.windowHandle); var wsex = NativeMethods.GetWindowStyleEx(this.windowHandle); ws &= ~WS.CAPTION; // We don't need a title bar ws &= ~WS.SYSMENU; // We don't need a system context menu ws |= WS.POPUP; wsex &= ~WS_EX.APPWINDOW; // We don't want our window to be visible on the taskbar wsex |= WS_EX.TOOLWINDOW; // We don't want our window to be visible on the taskbar wsex |= WS_EX.NOACTIVATE; // We don't want our this window to be activated if (this.owner.ResizeMode == ResizeMode.NoResize || this.owner.ResizeMode == ResizeMode.CanMinimize) { wsex |= WS_EX.TRANSPARENT; } NativeMethods.SetWindowStyle(this.windowHandle, ws); NativeMethods.SetWindowStyleEx(this.windowHandle, wsex); this.hwndSource.AddHook(this.WndProc); this.resizeModeChangeNotifier = new PropertyChangeNotifier(this.owner, ResizeModeProperty); this.resizeModeChangeNotifier.ValueChanged += this.ResizeModeChanged; }
protected override void OnAttached() { this.windowChrome = new WindowChrome() { ResizeBorderThickness = SystemParameters.WindowResizeBorderThickness, CaptionHeight = 0, CornerRadius = new CornerRadius(0), GlassFrameThickness = new Thickness(0), UseAeroCaptionButtons = false }; MetroWindow associatedObject = base.AssociatedObject as MetroWindow; if (associatedObject != null) { this.windowChrome.IgnoreTaskbarOnMaximize = associatedObject.IgnoreTaskbarOnMaximize; this.windowChrome.UseNoneWindowStyle = associatedObject.UseNoneWindowStyle; DependencyPropertyDescriptor.FromProperty(MetroWindow.IgnoreTaskbarOnMaximizeProperty, typeof(MetroWindow)).AddValueChanged(base.AssociatedObject, new EventHandler(this.IgnoreTaskbarOnMaximizePropertyChangedCallback)); DependencyPropertyDescriptor.FromProperty(MetroWindow.UseNoneWindowStyleProperty, typeof(MetroWindow)).AddValueChanged(base.AssociatedObject, new EventHandler(this.UseNoneWindowStylePropertyChangedCallback)); } base.AssociatedObject.SetValue(WindowChrome.WindowChromeProperty, this.windowChrome); IntPtr handle = (new WindowInteropHelper(base.AssociatedObject)).Handle; if (!base.AssociatedObject.IsLoaded && handle == IntPtr.Zero) { try { base.AssociatedObject.AllowsTransparency = false; } catch (Exception exception) { } } base.AssociatedObject.WindowStyle = WindowStyle.None; this.savedBorderThickness = new Thickness?(base.AssociatedObject.BorderThickness); this.borderThicknessChangeNotifier = new PropertyChangeNotifier(base.AssociatedObject, Control.BorderThicknessProperty); this.borderThicknessChangeNotifier.ValueChanged += new EventHandler(this.BorderThicknessChangeNotifierOnValueChanged); this.savedTopMost = base.AssociatedObject.Topmost; this.topMostChangeNotifier = new PropertyChangeNotifier(base.AssociatedObject, Window.TopmostProperty); this.topMostChangeNotifier.ValueChanged += new EventHandler(this.TopMostChangeNotifierOnValueChanged); base.AssociatedObject.Loaded += new RoutedEventHandler(this.AssociatedObject_Loaded); base.AssociatedObject.Unloaded += new RoutedEventHandler(this.AssociatedObject_Unloaded); base.AssociatedObject.SourceInitialized += new EventHandler(this.AssociatedObject_SourceInitialized); base.AssociatedObject.StateChanged += new EventHandler(this.OnAssociatedObjectHandleMaximize); this.HandleMaximize(); base.OnAttached(); }
/// <inheritdoc /> protected override void OnAttached() { this.isWindwos10OrHigher = IsWindows10OrHigher(); this.InitializeWindowChrome(); // no transparany, because it hase more then one unwanted issues if (this.AssociatedObject.AllowsTransparency && this.AssociatedObject.IsLoaded == false && new WindowInteropHelper(this.AssociatedObject).Handle == IntPtr.Zero) { try { this.AssociatedObject.AllowsTransparency = false; } catch (Exception) { //For some reason, we can't determine if the window has loaded or not, so we swallow the exception. } } this.AssociatedObject.WindowStyle = WindowStyle.None; this.savedBorderThickness = this.AssociatedObject.BorderThickness; this.borderThicknessChangeNotifier = new PropertyChangeNotifier(this.AssociatedObject, Control.BorderThicknessProperty); this.borderThicknessChangeNotifier.ValueChanged += this.BorderThicknessChangeNotifierOnValueChanged; this.savedResizeBorderThickness = this.ResizeBorderThickness; this.resizeBorderThicknessChangeNotifier = new PropertyChangeNotifier(this, ResizeBorderThicknessProperty); this.resizeBorderThicknessChangeNotifier.ValueChanged += this.ResizeBorderThicknessChangeNotifierOnValueChanged; this.savedTopMost = this.AssociatedObject.Topmost; this.topMostChangeNotifier = new PropertyChangeNotifier(this.AssociatedObject, Window.TopmostProperty); this.topMostChangeNotifier.ValueChanged += this.TopMostChangeNotifierOnValueChanged; this.AssociatedObject.SourceInitialized += this.AssociatedObject_SourceInitialized; this.AssociatedObject.Loaded += this.AssociatedObject_Loaded; this.AssociatedObject.Unloaded += this.AssociatedObject_Unloaded; this.AssociatedObject.Closed += this.AssociatedObject_Closed; this.AssociatedObject.StateChanged += this.AssociatedObject_StateChanged; this.AssociatedObject.LostFocus += this.AssociatedObject_LostFocus; this.AssociatedObject.Deactivated += this.AssociatedObject_Deactivated; base.OnAttached(); }
public WmpPlayerController(MpvMediaPlayer player, Window playerWindow) { this.Player = player; this.PlayerWindow = playerWindow; player.MediaPlayerInitialized += (o, e) => { Loop = true; Player.Host.OnMediaLoaded += Player_MediaOpened; if (playerWindow != null) { playerWindow.Closing += Window_Closing; } IsPlayingNotifier = new PropertyChangeNotifier(player.Host, MpvMediaPlayerHost.IsPlayingProperty); IsPlayingNotifier.ValueChanged += IsPlayingNotifier_ValueChanged; //Player.LostFocus += Player_LostFocus; }; }
// ReSharper restore PrivateFieldCanBeConvertedToLocalVariable internal NodeSlotConnector(BiaNodeEditor parent, MouseOperator mouseOperator) { _parent = parent; for (var i = 0; i != RowCount * ColumnCount; ++i) { Children.Add(new LinkConnectorCell(this)); } mouseOperator.LinkMoving += OnLinkMoving; SizeChanged += (_, e) => UpdateChildren(e.NewSize.Width, e.NewSize.Height); _parent.PreviewMouseUp += (_, __) => _mousePos = new ImmutableVec2_double(double.NaN, double.NaN); _sourceNotifier = new PropertyChangeNotifier(_parent, BiaNodeEditor.SourceNodeSlotConnectingProperty); _targetNotifier = new PropertyChangeNotifier(_parent, BiaNodeEditor.TargetNodeSlotConnectingProperty); _sourceNotifier.ValueChanged += ConnectionChangedHandler; _targetNotifier.ValueChanged += ConnectionChangedHandler; }