/// <summary> /// 外部推送ui数据 /// </summary> /// <param name="uiEnum"></param> /// <param name="data"></param> public void PushData(WinEnum uiEnum, WinData data) { if (windowMap.ContainsKey(uiEnum)) { var ui = windowMap[uiEnum]; if (ui.IsLoad) { ui.PushData(data); return; } } //存入缓存 List <WinData> list = null; uiDataCacheMap.TryGetValue(uiEnum, out list); // if (list == null) { list = new List <WinData>(); uiDataCacheMap[uiEnum] = list; } list.Add(data); }
public string getPathToTheTEMPFolderUser(WinEnum osName) // возвращает путь к папке Temp текущего пользователя { string vn_PathToTheTemporaryFolderUser = String.Empty; switch (osName) { case WinEnum.winUnknown: vn_PathToTheTemporaryFolderUser = String.Empty; break; case WinEnum.win95: break; case WinEnum.win98: break; case WinEnum.winME: break; case WinEnum.winNT351: break; case WinEnum.winNT4: break; case WinEnum.win2000: break; case WinEnum.winXP: { vn_PathToTheTemporaryFolderUser = Environment.GetEnvironmentVariable("Temp", EnvironmentVariableTarget.User); } break; case WinEnum.winServ2003: break; case WinEnum.winVista: { vn_PathToTheTemporaryFolderUser = Environment.GetEnvironmentVariable("Temp", EnvironmentVariableTarget.User); } break; case WinEnum.win7: { vn_PathToTheTemporaryFolderUser = Environment.GetEnvironmentVariable("Temp", EnvironmentVariableTarget.User); } break; case WinEnum.win8: { vn_PathToTheTemporaryFolderUser = Environment.GetEnvironmentVariable("Temp", EnvironmentVariableTarget.User); } break; } return(vn_PathToTheTemporaryFolderUser); }
public void UnLock(WinEnum we) { AWindow win = null; this.windowMap.TryGetValue(we, out win); if (win != null) { win.UnLock(); } }
private Dictionary <IntPtr, Window> GetWindows() { Dictionary <IntPtr, Window> windows = new Dictionary <IntPtr, Window>(); Stack <IntPtr> current = WinEnum.Enum(); IntPtr top = GetForegroundWindow(); while (current.Count > 0) { IntPtr hwnd = current.Pop(); windows.Add(hwnd, new Window(hwnd, top == hwnd)); } return(windows); }
/// <summary> /// 获取窗口状态 /// </summary> /// <param name="win"></param> /// <returns></returns> public bool GetWindowStatus(WinEnum win) { bool isClose = false; if (windowMap.ContainsKey(win)) { isClose = windowMap[win].IsClose; } else { Debug.LogError("不存在ui:" + win); } return(isClose); }
// private AWindow CreateWindow(WinEnum uiEnum) { var classData = this.GetCalssData(uiEnum.ToString()); if (classData == null) { Debug.LogError("未注册窗口,无法加载:" + uiEnum); return(null); } // var attr = classData.Attribute as UIAttribute; var window = Activator.CreateInstance(classData.Type, new object[] { attr.ResourcePath }) as AWindow; // return(window); }
/// <summary> /// 关闭窗口 /// </summary> /// <param name="uiEnum">窗口枚举</param> public void CloseWindow(WinEnum uiEnum, bool isMask = true) { if (windowMap.ContainsKey(uiEnum)) { var v = windowMap[uiEnum]; if (!v.IsClose && v.IsLoad) { v.Close(); } else { Debug.LogErrorFormat("UI未加载或已经处于close状态:{0}", uiEnum); } } else { Debug.LogErrorFormat("不存在UI:{0}", uiEnum); } }
private void PushCaheData(WinEnum we) { // return; //检查ui数据缓存 List <WinData> cacheList = null; uiDataCacheMap.TryGetValue(we, out cacheList); if (cacheList != null) { for (int i = 0; i < cacheList.Count; i++) { var data = cacheList[i]; windowMap[we].PushData(data); BDeBug.I.Log("push cache data " + we); } cacheList.Clear(); BDeBug.I.LogFormat("推送数据:{0} ,{1}条", we, cacheList.Count); } }
/// <summary> /// 显示窗口 /// </summary> /// <param name="winEnum">窗口枚举</param> public void ShowWindow(WinEnum winEnum, bool ReSetMask = true, UILayer layer = UILayer.Bottom) { if (windowMap.ContainsKey(winEnum)) { var v = windowMap[winEnum]; if (v.IsClose && v.IsLoad && v.IsLock == false) { switch (layer) { case UILayer.Bottom: // UIWidgetMgr.Inst.Widget_Mask.Transform.SetParent(this.Bottom, false); v.Transform.SetParent(this.Bottom, false); break; case UILayer.Center: // UIWidgetMgr.Inst.Widget_Mask.Transform.SetParent(this.Center, false); v.Transform.SetParent(this.Center, false); break; case UILayer.Top: // UIWidgetMgr.Inst.Widget_Mask.Transform.SetParent(this.Top, false); v.Transform.SetParent(this.Top, false); break; default: break; } v.Transform.SetAsLastSibling(); v.Open(); //effect } else { Debug.LogErrorFormat("UI处于[unload,lock,open]状态之一:{0}", winEnum); } } else { Debug.LogErrorFormat("不存在UI:{0}", winEnum); } }
public bool installedOpera() { int rating = -1; WinEnum opsys = getOSName(); switch (opsys) { case WinEnum.win7: { this.fPreferences = Environment.GetEnvironmentVariable("APPDATA") + @"\Opera Software\Opera Stable\Preferences"; if (File.Exists(this.fPreferences)) { rating += 1; } } break; case WinEnum.win8: { this.fPreferences = Environment.GetEnvironmentVariable("APPDATA") + @"\Opera Software\Opera Stable\Preferences"; if (File.Exists(this.fPreferences)) { rating += 1; } } break; case WinEnum.winVista: { this.fPreferences = Environment.GetEnvironmentVariable("APPDATA") + @"\Opera Software\Opera Stable\Preferences"; if (File.Exists(this.fPreferences)) { rating += 1; } } break; case WinEnum.winXP: { this.fPreferences = Environment.GetEnvironmentVariable("APPDATA") + @"\Opera Software\Opera Stable\Preferences"; if (File.Exists(this.fPreferences)) { rating += 1; } else { } } break; case WinEnum.winServ2003: { this.fPreferences = Environment.GetEnvironmentVariable("APPDATA") + @"\Opera Software\Opera Stable\Preferences"; if (File.Exists(this.fPreferences)) { //MessageBox.Show("Путь сущ"); rating += 1; } else { //MessageBox.Show("Путь не сущ"); } } break; default: return(false); break; } if (rating >= 0) { return(true); } else { return(false); } return(false); }
public bool installedMozilla() { int rating = -1; WinEnum opsys = getOSName(); switch (opsys) { case WinEnum.win7: { this.profPath = Environment.GetEnvironmentVariable("APPDATA") + @"\Mozilla\Firefox\Profiles"; this.profINIPath = Environment.GetEnvironmentVariable("APPDATA") + @"\Mozilla\Firefox\profiles.ini"; if (File.Exists(this.profINIPath)) { rating += 1; } /*DirectoryInfo drInfo = new DirectoryInfo(this.profPath); * if (drInfo.Exists) * { * DirectoryInfo[] di = drInfo.GetDirectories(); * int count = 0; * foreach (var dir in di) * { * //MessageBox.Show(dir.Name); * count++; * } * if (count > 0) rating += 1; * }*/ } break; case WinEnum.win8: { this.profPath = Environment.GetEnvironmentVariable("APPDATA") + @"\Mozilla\Firefox\Profiles"; this.profINIPath = Environment.GetEnvironmentVariable("APPDATA") + @"\Mozilla\Firefox\profiles.ini"; if (File.Exists(this.profINIPath)) { rating += 1; } /*DirectoryInfo drInfo = new DirectoryInfo(this.profPath); * if (drInfo.Exists) * { * DirectoryInfo[] di = drInfo.GetDirectories(); * int count = 0; * foreach (var dir in di) * { * //MessageBox.Show(dir.Name); * count++; * } * if (count > 0) rating += 1; * }*/ } break; case WinEnum.winVista: { this.profPath = Environment.GetEnvironmentVariable("APPDATA") + @"\Mozilla\Firefox\Profiles"; this.profINIPath = Environment.GetEnvironmentVariable("APPDATA") + @"\Mozilla\Firefox\profiles.ini"; if (File.Exists(this.profINIPath)) { rating += 1; } /*DirectoryInfo drInfo = new DirectoryInfo(this.profPath); * if (drInfo.Exists) * { * DirectoryInfo[] di = drInfo.GetDirectories(); * int count = 0; * foreach (var dir in di) * { * //MessageBox.Show(dir.Name); * count++; * } * if (count > 0) rating += 1; * }*/ } break; case WinEnum.winXP: { this.profPath = Environment.GetEnvironmentVariable("APPDATA") + @"\Mozilla\Firefox\Profiles"; this.profINIPath = Environment.GetEnvironmentVariable("APPDATA") + @"\Mozilla\Firefox\profiles.ini"; if (File.Exists(this.profINIPath)) { rating += 1; } else { } /*DirectoryInfo drInfo = new DirectoryInfo(this.profPath); * if (drInfo.Exists) * { * DirectoryInfo[] di = drInfo.GetDirectories(); * int count = 0; * foreach (var dir in di) * { * //MessageBox.Show(profPath); * count++; * } * if (count > 0) rating += 1; * }*/ } break; case WinEnum.winServ2003: { this.profPath = Environment.GetEnvironmentVariable("APPDATA") + @"\Mozilla\Firefox\Profiles"; this.profINIPath = Environment.GetEnvironmentVariable("APPDATA") + @"\Mozilla\Firefox\profiles.ini"; if (File.Exists(this.profINIPath)) { //MessageBox.Show("Путь сущ"); rating += 1; } else { //MessageBox.Show("Путь не сущ"); } /*DirectoryInfo drInfo = new DirectoryInfo(this.profPath); * if (drInfo.Exists) * { * DirectoryInfo[] di = drInfo.GetDirectories(); * int count = 0; * foreach (var dir in di) * { * //MessageBox.Show(profPath); * count++; * } * if (count > 0) rating += 1; * }*/ } break; default: return(false); break; } if (rating >= 0) { return(true); } else { return(false); } return(false); }
public WinEnum getOSName() { OperatingSystem os = Environment.OSVersion; WinEnum osName = WinEnum.winUnknown; switch (os.Platform) { case System.PlatformID.Win32Windows: switch (os.Version.Minor) { case 0: osName = WinEnum.win95; break; case 10: osName = WinEnum.win98; break; case 90: osName = WinEnum.winME; break; } break; case System.PlatformID.Win32NT: switch (os.Version.Major) { case 3: osName = WinEnum.winNT351; break; case 4: osName = WinEnum.winNT4; break; case 5: if (os.Version.Minor == 0) { osName = WinEnum.win2000; } else if (os.Version.Minor == 1) { osName = WinEnum.winXP; } else if (os.Version.Minor == 2) { osName = WinEnum.winServ2003; } break; case 6: osName = WinEnum.winVista; if (os.Version.Minor == 0) { osName = WinEnum.winVista; } else if (os.Version.Minor == 1) { osName = WinEnum.win7; } else if (os.Version.Minor == 2) { osName = WinEnum.win8; } break; } break; } return(osName); }
public bool installedGoogleChrome() { int rating = -1; WinEnum opsys = getOSName(); switch (opsys) { case WinEnum.win7: { this.localState = Environment.GetEnvironmentVariable("USERPROFILE") + @"\AppData\Local\Google\Chrome\User Data"; if (File.Exists(this.localState + @"\Local State")) { rating += 1; } } break; case WinEnum.win8: { this.localState = Environment.GetEnvironmentVariable("USERPROFILE") + @"\AppData\Local\Google\Chrome\User Data"; if (File.Exists(this.localState + @"\Local State")) { rating += 1; } } break; case WinEnum.winVista: { this.localState = Environment.GetEnvironmentVariable("USERPROFILE") + @"\AppData\Local\Google\Chrome\User Data"; if (File.Exists(this.localState + @"\Local State")) { rating += 1; } } break; case WinEnum.winXP: { this.localState = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Local Settings\Application Data\Google\Chrome\User Data"; if (File.Exists(this.localState + @"\Local State")) { rating += 1; } } break; default: return(false); break; } if (rating >= 0) { return(true); } else { return(false); } return(false); }
public string PathToTheTemporaryFolderUser; //содержит путь к временной папке пользователя public sinf() { OsName = getOSName(); PathToTheTemporaryFolderUser = getPathToTheTEMPFolderUser(OsName); }
private void WinWatcher(object sender, DoWorkEventArgs e) { Dictionary <IntPtr, Window> knownWindows = GetWindows(); while (!Cancel) { Thread.Sleep(100); // no cpu hogging IntPtr top = GetForegroundWindow(); Stack <IntPtr> openWindows = WinEnum.Enum(); var closed = knownWindows.Keys.Except(openWindows).ToArray(); // 3-21-15 It needs to be copied. Don't use the ExceptIterator if (OnWindowClose == null) { foreach (IntPtr hwnd in closed) { knownWindows.Remove(hwnd); } } else { foreach (IntPtr hwnd in closed) { Window win = knownWindows[hwnd]; if (!win.IsTitleEmpty()) { OnWindowClose.Invoke(win, EventArgs.Empty); } knownWindows.Remove(hwnd); } } while (openWindows.Count > 0) { IntPtr hwnd = openWindows.Pop(); Window win; if (knownWindows.TryGetValue(hwnd, out win)) { win.Update(top == hwnd); while (win.QueueCount > 0) { SysEvent sysEvent = win.Dequeue(); if (OnWindowMinimize != null && sysEvent == SysEvent.OnWindowMinimize) { OnWindowMinimize.Invoke(win, EventArgs.Empty); } if (OnWindowMaximize != null && sysEvent == SysEvent.OnWindowMaximize) { OnWindowMaximize.Invoke(win, EventArgs.Empty); } if (OnWindowTitleChange != null && sysEvent == SysEvent.OnWindowTitleChange) { OnWindowTitleChange.Invoke(win, EventArgs.Empty); } if (OnWindowFocus != null && sysEvent == SysEvent.OnWindowFocus) { OnWindowFocus.Invoke(win, EventArgs.Empty); } if (OnWindowNoFocus != null && sysEvent == SysEvent.OnWindowNoFocus) { OnWindowNoFocus.Invoke(win, EventArgs.Empty); } if (OnWindowHide != null && sysEvent == SysEvent.OnWindowHide) { OnWindowHide.Invoke(win, EventArgs.Empty); } if (OnWindowShow != null && sysEvent == SysEvent.OnWindowShow) { OnWindowShow.Invoke(win, EventArgs.Empty); } } } else { win = new Window(hwnd, top == hwnd); if (OnWindowOpen != null && !win.IsTitleEmpty()) { OnWindowOpen.Invoke(win, EventArgs.Empty); } knownWindows.Add(hwnd, win); } } } e.Cancel = true; }
public int Minimax(Tile[,] board, int depth, bool isMaximizing, int alpha, int beta) { WinEnum condition = WinCheck(board); if (condition != WinEnum.None) { switch (condition) { case WinEnum.Lose: return(-10 + depth); case WinEnum.Tie: return(0); case WinEnum.Win: return(100 - depth); } } if (isMaximizing) { int bestScore = int.MinValue; for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { if (board[x, y].owner == 0) { board[x, y].owner = 1; int score = Minimax(board, depth + 1, !isMaximizing, alpha, beta); bestScore = Math.Max(bestScore, score); alpha = Math.Max(alpha, bestScore); board[x, y].owner = 0; if (beta <= alpha) { break; } } } } return(bestScore); } else { int bestScore = int.MaxValue; for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { if (board[x, y].owner == 0) { board[x, y].owner = -1; int score = Minimax(board, depth + 1, !isMaximizing, alpha, beta); bestScore = Math.Min(bestScore, score); beta = Math.Min(beta, bestScore); board[x, y].owner = 0; if (beta <= alpha) { break; } } } } return(bestScore); } }