static void perform(int action, Keys key) { if (!Working) { return; } if (ExcludedKeys.Contains(key)) { return; } var fore = Win32ApiWrapper.GetForegroundWindow(); if (!MainWindows.Any(w => w.SameOrBelongTo(fore))) { return; } WorkingNotice?.BeginInvoke(fore, null, null); for (var i = AllWindows.Count - 1; i >= 0; i--) { var item = AllWindows[i]; var w = item.Key; if (w.SameOrBelongTo(fore)) { continue; } var r = Win32ApiWrapper.PostMessage(w, action, (int)key, 0); if (r == 0) { AllWindows.Remove(item); WindowLost?.BeginInvoke(w, null, null); } } }
//指定のオブジェクトのメッセージウィンドウをAdvEngineに埋め込み internal void EmbedWindow(IAdvMessageWindow window) { string windowName = window.gameObject.name; if (!AllWindows.ContainsKey(windowName)) { AddWindow(window); } AllWindows[windowName].MessageWindow = window; }
//管理対象のウィンドウのUIオブジェクトを削除 public void RemoveWindow(IAdvMessageWindow window) { string windowName = window.gameObject.name; if (!AllWindows.ContainsKey(windowName)) { return; } AllWindows.Remove(window.gameObject.name); }
//指定の名前のウィンドウを検索 internal AdvMessageWindow FindWindow(string name) { AdvMessageWindow window = CurrentWindow; if (!string.IsNullOrEmpty(name)) { if (!AllWindows.TryGetValue(name, out window)) { Debug.LogError(name + "is not found in all message windows"); } } return(window); }
public static void Collect() { if (Collector == null) { return; } var windows = Collector(); if (windows.Any()) { AllWindows.Clear(); AllWindows.AddRange(windows); } }
internal Window GetOrCreateWindow(string Name) { Window ret = GetWindowByName(Name); if (ret != null) { return(ret); } //Otherwise create the window ret = new Window(Name, SharedData); AllWindows.Add(ret); return(ret); }
public virtual UIBaseWindow GetGameWindow(WindowID id) { if (!IsWindowInControl(id)) { return(null); } if (AllWindows.ContainsKey(id)) { return(AllWindows[id]); } else { return(null); } }
/// <summary> /// Starts to sychronize keyboard events, will be failed if <see cref="MainWindows"/> is null or empty. /// </summary> public static void Start() { if (Working) { return; } Collect(); MainWindows = AllWindows.Where(w => w.Value).Select(w => w.Key); Working = MainWindows.Any(); if (!Working) { FailToStart?.BeginInvoke(null, null); return; } Started?.BeginInvoke(null, null); }
//メッセージウィンドを変更 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); } }
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(); }
private static Window GetOwner(OwnerOption ownerOption) { switch (ownerOption) { case OwnerOption.None: return(null); case OwnerOption.MainWindow: return(Application.Current.MainWindow); case OwnerOption.ActiveWindow: return(AllWindows.LastOrDefault(window => window.IsActive && window.IsVisible)); case OwnerOption.MostRecentlyOpen: return(AllWindows.LastOrDefault(window => window.IsVisible)); default: throw new ArgumentException("The OwnerOption is not valid", "ownerOption"); } }
public static void Init() { if (Initialized) { return; } AllWindows.Clear(); AllWindows.Add(new WindowsConfig("HallPalier_F1")); AllWindows.Add(new WindowsConfig("HallPalier_F2")); AllWindows.Add(new WindowsConfig("HallPalier_F3")); AllWindows.Add(new WindowsConfig("HallRdc_F1")); AllWindows.Add(new WindowsConfig("HallRdc_F2")); AllWindows.Add(new WindowsConfig("Tesla_F1")); AllWindows.Add(new WindowsConfig("Tesla_F2")); AllWindows.Add(new WindowsConfig("Tesla_F3")); AllWindows.Add(new WindowsConfig("Tesla_F4")); AllWindows.Add(new WindowsConfig("Turing_F1")); AllWindows.Add(new WindowsConfig("Turing_F2")); AllWindows.Add(new WindowsConfig("Turing_F3")); AllWindows.Add(new WindowsConfig("Lumiere_F1")); AllWindows.Add(new WindowsConfig("Lumiere_F2")); AllWindows.Add(new WindowsConfig("Lumiere_F3")); AllWindows.Add(new WindowsConfig("Nobel_F1")); AllWindows.Add(new WindowsConfig("Nobel_F2")); AllWindows.Add(new WindowsConfig("Nobel_F3")); Load(); _WindowsWatcherThread = new Thread(new ThreadStart(ThrRefresh)); _WindowsWatcherThread.Start(); Initialized = true; }
private static void RegisterWindow(WindowKey windowKey, Type windowType, Type viewModelType) { AllWindows.Add(windowKey, new RegisteredWindow(windowKey, windowType, viewModelType)); }
static void executeKeysQueue(KeysQueue queue) { Collect(); switch (queue.Id) { case -1: if (queue.Index > -1) { if (AllWindows.Count > queue.Index) { var w = AllWindows[queue.Index].Key; if (!w.SameOrBelongTo(Win32ApiWrapper.GetForegroundWindow())) { w.SwitchToThisWindow(); WorkingNotice?.BeginInvoke(w, null, null); } } } break; case 0: if (queue.Index == -1) //Toggle: NaN key { if (Working) { Stop(); } else { Start(); } } else //PostMessage: NaN key + N keys { if (AllWindows.Count > queue.Index) { var w = AllWindows[queue.Index].Key; if (queue.Starter == queue.Empty) //for accuration. { var k = (int)queue.IdToggler; Win32ApiWrapper.PostMessage(w, WinApiConsts.Msg.WM_KEYDOWN, k, 0); if (SendKeyUp) { Win32ApiWrapper.PostMessage(w, WinApiConsts.Msg.WM_KEYUP, k, 0); } } } } break; case 1: SendKeyUp = !SendKeyUp; try { SendKeyUpChanged?.BeginInvoke(null, null); } catch { } break; default: //ShowWindow: SW_MINIMIZE/SW_NORMAL if (queue.Starter == queue.Empty) //for accuration { if (queue.Index == -1) //for accuration { var c = Win32ApiWrapper.GetForegroundWindow(); if (AllWindows.Any(w => w.Key.SameOrBelongTo(c))) //find current { var iconic = AllWindows.Any(w => Win32ApiWrapper.IsIconic(w.Key.TillDesktop())); var nCmdShow = iconic ? WinApiConsts.nCmdShow.SW_NORMAL : WinApiConsts.nCmdShow.SW_MINIMIZE; foreach (var item in AllWindows.Select(w => w.Key)) { if (item.SameOrBelongTo(c)) //keep current { continue; } Win32ApiWrapper.ShowWindow(item.TillDesktop(), nCmdShow); } c.SwitchToThisWindow(); } } } break; } }