コード例 #1
0
ファイル: Window.cs プロジェクト: ununian/WPFLight
        public virtual void Show(bool modal)
        {
            if (!IsInitialized)
            {
                this.Initialize();
            }

            this.DialogResult = null;
            this.IsOpened     = true;
            this.IsActive     = true;
            this.Visibility   = Visibility.Visible;
            this.IsModal      = modal;

            if (modal)
            {
                ActiveModal = this;
            }

            this.Invalidate();

            if (!ActiveWindows.Contains(this))
            {
                ActiveWindows.Add(this);
            }

            if (this.Activated != null)
            {
                this.Activated(this, EventArgs.Empty);
            }

            this.Focus();
        }
コード例 #2
0
 public ViewService(Window window)
 {
     Window             = window;
     DispatcherService  = new DispatcherService(window.Dispatcher);
     DisplayInformation = Windows.Graphics.Display.DisplayInformation.GetForCurrentView();
     ApplicationView    = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
     UIViewSettings     = Windows.UI.ViewManagement.UIViewSettings.GetForCurrentView();
     ActiveWindows.Add(this);
 }
コード例 #3
0
        private void OnViewModelCloseEvent(object sender, EventArgs eventArgs)
        {
            ViewModel viewModel = sender as ViewModel;

            if (viewModel != null)
            {
                viewModel.CloseEvent -= OnViewModelCloseEvent;
                ActiveWindows.Remove((ViewModel)sender);
            }
        }
コード例 #4
0
        //メッセージウィンドを変更
        internal void ChangeCurrentWindow(string name)
        {
            //設定なしならなにもしない
            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            if (CurrentWindow != null && CurrentWindow.Name == name)
            {
                //変化なし
                return;
            }
            else
            {
                AdvMessageWindow window;
                if (!ActiveWindows.TryGetValue(name, out window))
                {
                    //アクティブなウィンドウにない場合、全ウィンドウから検索
                    if (!AllWindows.TryGetValue(name, out window))
                    {
                        //全ウィンドウにもない場合どうしようもないので、デフォルトウィンドウを
                        Debug.LogWarning(name + "is not found in window manager");
                        name   = DefaultActiveWindowNameList[0];
                        window = AllWindows[name];
                    }
                    //非アクティブなウィンドウと交換
                    if (CurrentWindow != null)
                    {
                        ActiveWindows.Remove(CurrentWindow.Name);
                    }
                    ActiveWindows.Add(name, window);

                    //登録されたイベントを呼ぶ
                    CalllEventActiveWindows();
                }
                LastWindow    = CurrentWindow;
                CurrentWindow = window;
                //登録されたイベントを呼ぶ
                if (LastWindow != null)
                {
                    LastWindow.ChangeCurrent(false);
                }
                CurrentWindow.ChangeCurrent(true);
                OnChangeCurrentWindow.Invoke(this);
            }
        }
コード例 #5
0
ファイル: Window.cs プロジェクト: ununian/WPFLight
        public virtual void Close()
        {
            this.IsActive   = false;
            this.Visibility = Visibility.Hidden;
            this.IsOpened   = false;

            if (this.IsModal)
            {
                ActiveModal = null;
            }

            ActiveWindows.Remove(this);

            if (this.Closed != null)
            {
                this.Closed(this, EventArgs.Empty);
            }
        }
コード例 #6
0
        /// <summary>
        /// Create a new instance of the <see cref="ActiveWindowsDesignModel"/>
        /// </summary>
        public ActiveWindowsDesignModel()
        {
            DisplayLocation = false;

            var windows = new List <Domain.Windows.Window>
            {
                new Domain.Windows.Window
                {
                    Id           = 1,
                    WindowHandle = (IntPtr)1,
                    Description  = "Window 1",
                    Dimensions   = new Rect {
                        Left = 0, Top = 0, Right = 100, Bottom = 100
                    }
                },
                new Domain.Windows.Window
                {
                    Id           = 2,
                    WindowHandle = (IntPtr)2,
                    Description  = "Window 2",
                    Dimensions   = new Rect {
                        Left = 0, Top = 0, Right = 200, Bottom = 200
                    }
                },
                new Domain.Windows.Window
                {
                    Id           = 2,
                    WindowHandle = (IntPtr)2,
                    Description  = "Trailing Window Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test",
                    Dimensions   = new Rect {
                        Left = 0, Top = 0, Right = 999999999, Bottom = 999999999
                    }
                },
            };

            ActiveWindows.UpdateCollection(windows);
            SelectedActiveWindows.UpdateCollection(new List <Domain.Windows.Window> {
                windows[1]
            });

            FilteredActiveWindows = CollectionViewSource.GetDefaultView(ActiveWindows);
        }
コード例 #7
0
        internal void ChangeActiveWindows(List <string> names)
        {
            //複数ウィンドウの設定
            ActiveWindows.Clear();
            foreach (var name in names)
            {
                AdvMessageWindow window;
                if (!AllWindows.TryGetValue(name, out window))
                {
                    Debug.LogError(name + " is not found in message windows");
                }
                else
                {
                    ActiveWindows.Add(name, window);
                }
            }

            //登録されたイベントを呼ぶ
            CalllEventActiveWindows();
        }
コード例 #8
0
ファイル: Window.cs プロジェクト: ununian/WPFLight
        /// <summary>
        /// Gibt das Window-Objekt an der Postion zurück,
        /// - Priorität haben Modal-Windows
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public static Window GetHitWindow(Vector2 v)
        {
            var modalWindow = ActiveWindows.FirstOrDefault(w => w.IsModal);

            if (modalWindow != null)
            {
                return(modalWindow);
            }
            else
            {
                // Neue aktive Fenster werden bevorzugt, da sie später gezeichnet wurden
                // und somit im Fordergrund sind
                for (var n = ActiveWindows.Count - 1; n >= 0; n--)
                {
                    var window = ActiveWindows [n];
                    if (window.HitTest(v))
                    {
                        return(window);
                    }
                }
            }
            return(null);
        }
コード例 #9
0
        /// <summary>
        /// Создать и отобразить окно для указанной модели
        /// </summary>
        /// <param name="viewModel">Модель окна</param>
        /// <param name="asDialog">Создать новое окно модально или нет</param>
        /// <returns>Созданное окно</returns>
        public virtual void ShowWindow(ViewModel viewModel, bool asDialog)
        {
            if (!ModelWindowDictionary.ContainsKey(viewModel.GetType()))
            {
                throw new ArgumentException("Not registered ViewModel type");
            }
            var window = Activator.CreateInstance(ModelWindowDictionary[viewModel.GetType()]) as Window;

            ActiveWindows.Add(viewModel, window);
            viewModel.CloseEvent += OnViewModelCloseEvent;
            if (window != null)
            {
                window.DataContext = viewModel;
                if (asDialog)
                {
                    window.ShowDialog();
                }
                else
                {
                    window.Show();
                }
            }
        }
コード例 #10
0
 //指定の名前がアィティブなウィンドウか
 public bool IsActiveWindow(string name)
 {
     return(ActiveWindows.ContainsKey(name));
 }
コード例 #11
0
 public override void ShowWindow(ViewModel viewModel, bool asDialog)
 {
     Subscribe(viewModel);
     ActiveWindows.Add(viewModel, null);
 }