private void openWindow(object param)
 {
     this._formWindow = new MainFormWindow();
     this._formWindow.MainFormViewModel.setViewModel(this._entityName);
     // TODO add checking if param is not null for update
     if (param != null)
     {
         BaseEntity entity = (BaseEntity)param;
         this._formWindow.MainFormViewModel.SelectedViewModel.loadData(entity);
     }
     this._formWindow.MainFormViewModel.addMediator(
         WindowObserver.getObserver(this)
         );
     this._formWindow.Show();
 }
Exemple #2
0
        private static WindowObserver GetOrCreateObsever(DependencyObject sender)
        {
            var observer = GetObserver(sender);

            if (observer == null)
            {
                var window = sender as Window;
                if (window != null)
                {
                    observer = new WindowObserver(window);
                    SetObserver(sender, observer);
                }
            }

            return(observer);
        }
Exemple #3
0
        /// <summary>
        /// Starts an observing of the window which contains the control to determine when the item has to be closed.
        /// </summary>
        /// <param name="observedControl">The control which owner window has to be observed.</param>
        /// <param name="closeMethod">The close callback. This gets invoked when the owner window has send notifications to close the popup.</param>
        /// <exception cref="System.ArgumentNullException">observedControl is null.</exception>
        /// <exception cref="System.ArgumentNullException">closeMethod is null.</exception>
        public void AutoClose(UIElement observedControl, Action closeMethod)
        {
            if (observedControl == null)
                throw new ArgumentNullException("observedControl");
            if (closeMethod == null)
                throw new ArgumentNullException("closeMethod");

            _observedControl = observedControl;
            _closeMethod = closeMethod;
            var ownerWindow = Window.GetWindow(observedControl);
            if (ownerWindow != null)
            {
                _observer = new WindowObserver(ownerWindow);
                _observer.AddCallbackFor(WindowMessages.WM_NCLBUTTONDOWN, p => CallMethod());
                _observer.AddCallbackFor(WindowMessages.WM_LBUTTONDOWN, p => CallMethod());
                _observer.AddCallbackFor(WindowMessages.WM_KILLFOCUS, p => CallMethod());
            }
        }
Exemple #4
0
 private static void SetObserver(DependencyObject obj, WindowObserver value)
 {
     obj.SetValue(ObserverProperty, value);
 }
        private static WindowObserver GetOrCreateObsever(DependencyObject sender)
        {
            var observer = GetObserver(sender);
            if (observer == null)
            {
                var window = sender as Window;
                if (window != null)
                {
                    observer = new WindowObserver(window);
                    SetObserver(sender, observer);
                }
            }

            return observer;
        }
 private static void SetObserver(DependencyObject obj, WindowObserver value)
 {
     obj.SetValue(ObserverProperty, value);
 }