private static void GetWindowInfo(IntPtr hWnd, bool isInFocus = false) { // http://www.codeproject.com/Articles/1698/MS-Spy-style-Window-Finder if (hWnd != IntPtr.Zero && WinApi.IsWindow(hWnd) && hWnd != hWndFoundWindow) { WindowSelectorEventArgs e = new WindowSelectorEventArgs(); //Программа int pId; var threadId = WinApi.GetWindowThreadProcessId(hWnd, out pId); using (var p = Process.GetProcessById(pId)) e.ProgramName = p.MainModule.ModuleName; if (isInFocus) { e.HGetForegroundWindow = (int)hWnd; var h = Misc.GetFocusedHandle(threadId, e); if (h != IntPtr.Zero) { hWnd = h; } if (hWnd == hWndFoundWindow) { return; } } //Класс var temp = new StringBuilder(256); WinApi.GetClassName(hWnd, temp, temp.Capacity); e.ClassName = temp.ToString(); temp.Clear(); //Заголовок temp.Capacity = 256; WinApi.GetWindowText(hWnd, temp, temp.Capacity); e.WindowCaption = temp.ToString(); temp.Clear(); //Дескриптор e.HWindow = (int)hWnd; e.HParent = (int)WinApi.GetParent(hWnd); //Очищаем RefreshWindow(hWndFoundWindow); //Рисуем прямоугольник HighlightFoundWindow(hWnd); hWndFoundWindow = hWnd; if (UiUpdate != null) { UiUpdate.Invoke(null, e); } } }
public void UpdateUi() { UiUpdate.SetMainImage(GameModel, MainImage); UiUpdate.SetButtonTextToDirectionName(GameModel, ForwardButton, 0); UiUpdate.SetButtonTextToDirectionName(GameModel, BackButton, 1); UiUpdate.SetButtonTextToDirectionName(GameModel, LeftButton, 2); UiUpdate.SetButtonTextToDirectionName(GameModel, RightButton, 3); UiUpdate.ClearLists(StoryList, InventoryList); UiUpdate.AddInfoToList(StoryList, GameModel.Screens[GameModel.CurrentScreen].GetLocationInfo()); UiUpdate.AddInfoToList(InventoryList, GameModel.Player.GetInventoryInfo()); }
void addGameGui() { Panel statPanel = new Panel(new Vector2(600, 100), PanelSkin.Golden, Anchor.TopCenter); Paragraph timeDisplay = new Paragraph("", Anchor.Center); Paragraph speedDisplay = new Paragraph("", Anchor.CenterLeft); Paragraph damageDisplay = new Paragraph("", Anchor.CenterRight); statPanel.AddChild(timeDisplay); statPanel.AddChild(speedDisplay); statPanel.AddChild(damageDisplay); Panel gameOverPanel = new Panel(new Vector2(500, 500), PanelSkin.Fancy, Anchor.Center); Paragraph gameOverText = new Paragraph(""); gameOverText.Identifier = "gameover"; gameOverPanel.AddChild(gameOverText); gameOverPanel.Visible = false; Panel endImagePanel = new Panel(new Vector2(1920, 1200), PanelSkin.None, Anchor.TopCenter); Texture2D winTex = ResourcesManager.Instance.GetTexture("Images/victory"); Image winImage = new Image(winTex, new Vector2(400, 200), ImageDrawMode.Stretch, Anchor.TopCenter, new Vector2(0, 70)); winImage.Visible = false; winImage.Identifier = "win"; Texture2D loseTex = ResourcesManager.Instance.GetTexture("Images/lose"); Image loseImage = new Image(loseTex, new Vector2(400, 200), ImageDrawMode.Stretch, Anchor.TopCenter, new Vector2(0, 70)); loseImage.Visible = false; loseImage.Identifier = "lose"; endImagePanel.AddChild(winImage); endImagePanel.AddChild(loseImage); Button retryButton = new Button("Retry", ButtonSkin.Fancy, Anchor.Center) { OnClick = (Entity btn) => { gameState.changeScene(State.GAME); } }; // 80 down from the Center Vector2 menuLocationOffset = new Vector2(0f, 95f); Button menuButton = new Button("Return to Menu", ButtonSkin.Fancy, Anchor.Center, null, menuLocationOffset) { OnClick = (Entity btn) => { gameState.changeScene(State.MAIN_MENU); } }; Button quitButton = new Button("Quit", ButtonSkin.Fancy, Anchor.BottomCenter) { OnClick = (Entity btn) => { gameState.quitFlag = true; } }; gameOverPanel.AddChild(retryButton); gameOverPanel.AddChild(menuButton); gameOverPanel.AddChild(quitButton); GameObject uiManager = new GameObject("ui"); uiUpdater = new UiUpdate(timeDisplay, damageDisplay, speedDisplay, gameOverPanel, endImagePanel); uiManager.AddComponent(uiUpdater); uiManager.Parent = Root; UserInterface.AddEntity(endImagePanel); UserInterface.AddEntity(statPanel); UserInterface.AddEntity(gameOverPanel); }
protected virtual void OnUiUpdate(string message, bool isError, bool append, EventArgs e) { UiUpdate?.Invoke(this, message, isError, append, e); }
private void DeviceNotifcation(object sender, string message, bool isCritical, EventArgs e) { UiUpdate?.Invoke(sender, message, isCritical, true, e); }