protected override void OnLaunchedMenuClosed() { int pendingMenuCloseTimeoutId = Root.PendingMenuCloseTimeoutId; if (pendingMenuCloseTimeoutId != -1) { Browser.Window.ClearTimeout(pendingMenuCloseTimeoutId); } Root.PendingMenuCloseTimeoutId = -1; Root.PendingMenuCloseMenuLauncherStackIndex = -1; RemoveHighlight(); CloseToolTip(); ControlComponent comp = DisplayedComponent; if (comp.DisplayMode.StartsWith("Menu")) { // We know that if we're in a Menu, the structure must be Menu > MenuSection > MenuItem // and the DisplayedComponent must be the MenuItem Menu parentMenu = (Menu)comp.Parent.Parent; parentMenu.OpenSubMenuLauncher = null; } // If Properties.CommandMenuClose is not set, Root will not send the command to the root user, // so this won't hit page components. It is important that we do this though so that bugs like // O14:653413 are mitigated. comp.RaiseCommandEvent(Properties.CommandMenuClose, CommandType.MenuClose, null); base.OnLaunchedMenuClosed(); }
private void CloseWebView() { if (_webView2Control != null) { _webView2Control.Close(); _webView2Control.EnvironmentCreated -= webView2Control1_EnvironmentCreated; _webView2Control.BrowserCreated -= _webView2Control_BrowserCreated; _webView2Control.ContainsFullScreenElementChanged -= _webView2Control_ContainsFullScreenElementChanged; _webView2Control.NewWindowRequested -= _webView2Control_NewWindowRequested; _environment.UnregisterNewVersionAvailable(_newVersionToken); _settingsComponent.CleanUp(); _settingsComponent = null; _fileComponent.CleanUp(); _fileComponent = null; _processComponent.CleanUp(); _processComponent = null; _scriptComponent.CleanUp(); _scriptComponent = null; _controlComponent.CleanUp(); _controlComponent = null; _viewComponent.CleanUp(); _viewComponent = null; tableLayoutPanel1.Controls.Remove(_webView2Control); _webView2Control.Dispose(); _webView2Control = null; } }
public override void Init() { base.Init(); worldManager = new WorldManager(); client = new Client("10.0.3.85", worldManager); client.StartConnecting(); client.GameInitialized += (object sender, GameObject player) => { thePlayer = (Player)player; control = thePlayer.GetComponent <ControlComponent>(); this.worldManager.Camera = thePlayer; connectBtn.Hide(); }; client.GameEnded += (object sender, EventArgs e) => { Vector offset = this.worldManager.Offset; this.worldManager = new WorldManager(); this.worldManager.Offset = offset; client.Manager = worldManager; thePlayer = null; control = null; connectBtn.Show(); }; }
protected override void OnClick(HtmlEvent evt) { bool enabled = Enabled; #if PERF_METRICS if (enabled && !MenuLaunched) { PMetrics.PerfMark(PMarker.perfCUIFlyoutAnchorOnClickStart); } #endif CloseToolTip(); Utility.CancelEventUtility(evt, false, true); if (!enabled || MenuLaunched) { return; } Root.LastCommittedControl = this; ControlComponent comp = DisplayedComponent; Anchor elm = (Anchor)comp.ElementInternal; LaunchMenuInternal(elm); if (!string.IsNullOrEmpty(Properties.Command)) { comp.RaiseCommandEvent(Properties.Command, CommandType.MenuCreation, null); } #if PERF_METRICS PMetrics.PerfMark(PMarker.perfCUIFlyoutAnchorOnClickEnd); #endif }
protected void HandleMouseFocus(HtmlEvent args) { OnBeginFocus(); if (!Enabled) { return; } ControlComponent comp = DisplayedComponent; if (comp is MenuItem) { ((MenuItem)comp).Focused = true; } if (string.IsNullOrEmpty(Properties.CommandPreview)) { return; } Dictionary <string, string> dict = this.StateProperties; dict["CommandValueId"] = this._commandValueId; dict["MenuItemId"] = this._menuItemId; CommandType ct = CommandType.Preview; string cmdtpe = Properties.CommandType; if (!string.IsNullOrEmpty(cmdtpe) && cmdtpe == "OptionSelection") { ct = CommandType.OptionPreview; } comp.RaiseCommandEvent(Properties.CommandPreview, ct, dict); }
private void _webView2Control_BrowserCreated(object sender, EventArgs e) { _settingsComponent = new SettingsComponent(_environment, _webView2Control); _fileComponent = new FileComponent(this, _webView2Control); _processComponent = new ProcessComponent(this, _webView2Control); _scriptComponent = new ScriptComponent(this, _webView2Control); _controlComponent = new ControlComponent(this, navigationToolBar, _webView2Control); _viewComponent = new ViewComponent(this, _webView2Control); if (_onWebViewFirstInitialized != null) { _onWebViewFirstInitialized.Invoke(); _onWebViewFirstInitialized = null; } if (!string.IsNullOrEmpty(_initialUrl)) { _webView2Control.Navigate(_initialUrl); } if (_newWindowRequestedEventArgs != null) { _newWindowRequestedEventArgs.NewWindow = _webView2Control.InnerWebView2WebView; _newWindowRequestedEventArgs.Handled = true; _newWindowDeferral.Complete(); _newWindowRequestedEventArgs = null; _newWindowDeferral = null; } }
public EntityPlayer(Texture2D playerTexture, int spriteId, Texture2D shadowTexture, int shadowOffset) : base() { PositionComponent = new PositionComponent(new Vector2(200, 200)); RenderComponent = new RenderComponent(playerTexture, new Vector2(0, spriteId), shadowTexture, shadowOffset, Color.White); ShooterComponent = new ShooterComponent(); ControlComponent = new ControlComponent(this); }
private void OnBlur(HtmlEvent args) { OnEndFocus(); if (!Enabled) { return; } ControlComponent comp = DisplayedComponent; if (comp is MenuItem) { ((MenuItem)comp).Focused = false; } if (string.IsNullOrEmpty(Properties.CommandRevert)) { return; } CommandType ct = CommandType.PreviewRevert; string cmdtpe = Properties.CommandType; if (!string.IsNullOrEmpty(cmdtpe) && cmdtpe == "OptionSelection") { ct = CommandType.OptionPreviewRevert; StateProperties[ToggleButtonCommandProperties.CommandValueId] = _commandValueId; } comp.RaiseCommandEvent(Properties.CommandRevert, ct, StateProperties); }
private void LaunchMenuInternal(Anchor launcher) { CloseToolTip(); Highlight(true); Root.FixedPositioningEnabled = false; _focusSet = false; ControlComponent comp = DisplayedComponent; bool isInMenu = comp.DisplayMode.StartsWith("Menu"); if (isInMenu) { // We know that if we're in a Menu, the structure must be Menu > MenuSection > MenuItem // and the DisplayedComponent must be the MenuItem Menu parentMenu = (Menu)comp.Parent.Parent; parentMenu.OpenSubMenuLauncher = this; } LaunchMenu(launcher); if (!isInMenu) { return; } Menu.ElementInternal.MouseOver += OnMenuMouseover; if (BrowserUtility.InternetExplorer) { Menu.ElementInternal.MouseLeave += OnMenuMouseleave; } else { Menu.ElementInternal.MouseOut += OnMenuMouseout; } }
private void OnMouseover(HtmlEvent args) { OnBeginFocus(); if (!Enabled || MenuLaunched) { return; } HtmlElement target = args.TargetElement; HtmlElement relatedTarget = args.RelatedTarget; // Check if mouseover is to this element or not if (!(target == _elmMenu || target == _elmMenu16 || target == _elmMenu32)) { return; } while (!CUIUtility.IsNullOrUndefined(relatedTarget) && relatedTarget != target) { try { if (relatedTarget.NodeName.ToLower() == "body") { break; } } catch { // Firefox will sometimes start trying to iterate its own chrome nodes such as // the scrollbar which causes an access denied exception. If we get here, there's // nothing we can do, so just break out of the loop break; } relatedTarget = (HtmlElement)relatedTarget.ParentNode; } // Still moused over the flyout anchor, don't handle event if (relatedTarget == target) { return; } ControlComponent comp = DisplayedComponent; Anchor elm = (Anchor)comp.ElementInternal; LaunchMenuInternal(elm); string command = Properties.Command; if (!string.IsNullOrEmpty(command)) { comp.RaiseCommandEvent(command, CommandType.MenuCreation, null); } }
public static void CopyToNode(Godot.LineEdit control, Props?oldProps, Props props) { ControlComponent.CopyToNode(control, oldProps, props); if (control.Text != props.text) { control.Text = props.text; } props.onTextChanged?.Connect(control, "text_changed", oldProps?.onTextChanged); props.onTextEntered?.Connect(control, "text_entered", oldProps?.onTextEntered); }
protected override void OnDynamicMenuPopulated() { // If we are dynamically populating the menu, we should build the lookup // table for autocomplete now ControlComponent cc = null; Control c = null; ISelectableControl isc = null; IMenuItem imi = null; string menuitemid = ""; string labeltext = ""; if (CUIUtility.IsNullOrUndefined(Menu)) { return; } foreach (MenuSection ms in Menu.Children) { foreach (Component comp in ms.Children) { // Only check if this is a MenuItem // Ignore Galleries and GroupPopouts if (comp is MenuItem) { cc = (ControlComponent)comp; c = cc.Control; // Get MenuItemId if (c is ISelectableControl) { isc = (ISelectableControl)c; menuitemid = isc.GetMenuItemId(); } // Get Label Text if (c is IMenuItem) { imi = (IMenuItem)c; labeltext = imi.GetTextValue(); } // If we have both MenuItemId and Label Text, add the item to the table if (!(string.IsNullOrEmpty(menuitemid) || string.IsNullOrEmpty(labeltext))) { MenuItems[labeltext] = menuitemid; labeltext = ""; menuitemid = ""; } } } } }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; camera = new CameraComponent(this); collision = new CollisionComponent(this); control = new ControlComponent(this); actorObj = new Actor(); cameraService = (ICameraService)this.Services.GetService(typeof(ICameraService)); controlService = (IControlService)this.Services.GetService(typeof(IControlService)); }
protected void HandleTabFocus(HtmlEvent args) { OnBeginFocus(); ControlComponent comp = DisplayedComponent; if (comp is MenuItem) { ((MenuItem)comp).Focused = true; Highlight(Enabled); } else if (Enabled) { Root.LastFocusedControl = this; } }
protected void HandleTabBlur(HtmlEvent args) { RemoveHighlight(); OnEndFocus(); if (!Enabled) { return; } ControlComponent comp = DisplayedComponent; if (comp is MenuItem) { ((MenuItem)comp).Focused = false; } }
protected void ValidateAndSave() { Dictionary <string, string> commandDict = new Dictionary <string, string>(); // If value is not a valid menu item if (!SelectMenuItemById(_pendingMenuItemId)) { ControlComponent comp = DisplayedComponent; if (!Utility.IsTrue(CBProperties.AutoComplete)) { string menuitemid = GetMenuItem(_elmMediumInput.Value); if (!string.IsNullOrEmpty(menuitemid) && SelectMenuItemById(menuitemid)) { IsFreeForm = false; commandDict["IsFreeForm"] = "false"; commandDict["CommandValueId"] = _selectedControl.GetCommandValueId(); comp.RaiseCommandEvent(CBProperties.Command, CommandType.OptionSelection, commandDict); return; } } // If autocomplete was off, but we haven't returned yet, then the value was not a valid item in the menu // If free-form entry is allowed, send the value to the PageManager if (_allowFreeForm) { IsFreeForm = true; commandDict["IsFreeForm"] = "true"; commandDict["Value"] = _elmMediumInput.Value; StateProperties[ComboBoxCommandProperties.Value] = _elmMediumInput.Value; comp.RaiseCommandEvent(CBProperties.Command, CommandType.OptionSelection, commandDict); } // If free-form entry is not allowed, reset to the last valid value and stop else { ResetToPreviousValue(); return; } } // If the value is a valid menu item, send it as a CommandValueId to the PageManager else { IsFreeForm = false; commandDict["IsFreeForm"] = "false"; commandDict["CommandValueId"] = _selectedControl.GetCommandValueId(); DisplayedComponent.RaiseCommandEvent(CBProperties.Command, CommandType.OptionSelection, commandDict); } }
private void SetupCarOnTrack(int gridStartIndex) { Debug.Log("Grid index " + gridStartIndex); var value = SlotLanes.Instance.GridPositions[gridStartIndex]; var pos = value.Start; _instance = PhotonNetwork.Instantiate(_prefabs[gridStartIndex].name, pos.position, Quaternion.identity); _instance.transform.LookAt(value.End); PhotonNetwork.RegisterPhotonView(_instance.GetComponent <PhotonView>()); _rigid = _instance.GetComponent <Rigidbody>(); _move = _instance.AddComponent <MoveComponent>(); _finish = _instance.AddComponent <FinishComponent>(); _control = _instance.AddComponent <ControlComponent>(); _jumpComponent = _instance.AddComponent <JumpComponent>(); _control.Init(this); _finish.Finish += OnFinish; }
public override void ReceiveFocus() { OnBeginFocus(); ControlComponent comp = DisplayedComponent; if (CUIUtility.IsNullOrUndefined(comp)) { return; } ((MenuItem)comp).Focused = true; if (!CUIUtility.IsNullOrUndefined(_elmMenu)) { _elmMenu.PerformFocus(); } if (!CUIUtility.IsNullOrUndefined(_elmSMenu)) { _elmSMenu.PerformFocus(); } }
protected override void OnClick(HtmlEvent args) { // evt.PreventDefault() will prevent checkbox state from being toggled CloseToolTip(); if (!Enabled) { return; } CommandType ct = CommandType.IgnoredByMenu; ControlComponent comp = DisplayedComponent; // Choose appropriate check box switch (comp.DisplayMode) { case "Small": StateProperties[CheckBoxCommandProperties.On] = _elmSmallCheckboxInput.Checked.ToString(); break; case "Medium": StateProperties[CheckBoxCommandProperties.On] = _elmMediumCheckboxInput.Checked.ToString(); break; default: EnsureValidDisplayMode(comp.DisplayMode); return; } // Send command comp.RaiseCommandEvent(Properties.Command, ct, StateProperties); if (Root.PollForState) { PollForStateAndUpdate(); } else { SetState(Utility.IsTrue(StateProperties[CheckBoxCommandProperties.On])); } }
private void OnMouseenter(HtmlEvent args) { OnBeginFocus(); if (!Enabled || MenuLaunched) { return; } ControlComponent comp = DisplayedComponent; Anchor elm = (Anchor)comp.ElementInternal; LaunchMenuInternal(elm); string command = Properties.Command; if (!string.IsNullOrEmpty(command)) { comp.RaiseCommandEvent(command, CommandType.MenuCreation, null); } }
private void OnKeyPress(HtmlEvent args) { CloseToolTip(); if (!Enabled) { return; } int key = args.KeyCode; if (MenuLaunched) { if ((Root.TextDirection == Direction.LTR && key == (int)Key.Right) || (Root.TextDirection == Direction.RTL && key == (int)Key.Left)) { Menu.FocusOnFirstItem(args); } } else { if (key == (int)Key.Enter || key == (int)Key.Space || (((Root.TextDirection == Direction.LTR && key == (int)Key.Right) || (Root.TextDirection == Direction.RTL && key == (int)Key.Left)) && (!args.CtrlKey || !args.ShiftKey))) { LaunchedByKeyboard = true; ControlComponent comp = DisplayedComponent; Anchor elm = (Anchor)comp.ElementInternal; string command = Properties.Command; if (!string.IsNullOrEmpty(command)) { comp.RaiseCommandEvent(command, CommandType.MenuCreation, null); } LaunchMenuInternal(elm); } } }
protected void HandleMouseBlur(HtmlEvent args) { RemoveHighlight(); OnEndFocus(); if (!Enabled) { return; } ControlComponent comp = DisplayedComponent; if (comp is MenuItem) { ((MenuItem)comp).Focused = false; } if (string.IsNullOrEmpty(Properties.CommandRevert)) { return; } CommandType ct = CommandType.PreviewRevert; Dictionary <string, string> dict = this.StateProperties; dict["CommandValueId"] = this._commandValueId; dict["MenuItemId"] = this._menuItemId; string cmdtpe = Properties.CommandType; if (!string.IsNullOrEmpty(cmdtpe) && cmdtpe == "OptionSelection") { ct = CommandType.OptionPreviewRevert; } comp.RaiseCommandEvent(Properties.CommandRevert, ct, dict); }
public abstract void Add(ControlComponent control);
private void CloseWebView(bool cleanupUserDataFolder) { if (_webView2Control != null) { _webView2Control.Close(); _webView2Control.EnvironmentCreated -= webView2Control1_EnvironmentCreated; _webView2Control.BrowserCreated -= _webView2Control_BrowserCreated; _webView2Control.ContainsFullScreenElementChanged -= _webView2Control_ContainsFullScreenElementChanged; _webView2Control.NewWindowRequested -= _webView2Control_NewWindowRequested; _environment.UnregisterNewVersionAvailable(_newVersionToken); _settingsComponent.CleanUp(); _settingsComponent = null; _fileComponent.CleanUp(); _fileComponent = null; _processComponent.CleanUp(); _processComponent = null; _scriptComponent.CleanUp(); _scriptComponent = null; _controlComponent.CleanUp(); _controlComponent = null; _viewComponent.CleanUp(); _viewComponent = null; tableLayoutPanel1.Controls.Remove(_webView2Control); _webView2Control.Dispose(); _webView2Control = null; } if (cleanupUserDataFolder) { // For non-UWP apps, the default user data folder {Executable File Name}.WebView2 // is in the same directory next to the app executable. If end // developers specify userDataFolder during WebView environment // creation, they would need to pass in that explicit value here. // For more information about userDataFolder: // https://docs.microsoft.com/microsoft-edge/hosting/webview2/reference/webview2.idl#createwebview2environmentwithdetails string userDataFolder = Environment.CurrentDirectory; // Obtain the absolute path for relative paths that include "./" or "../" userDataFolder = Path.Combine(userDataFolder, "MtrDev.WebView2.WinForms.Sample.exe.WebView2"); string userDataFolderPath = userDataFolder; string message = "Are you sure you want to clean up the user data folder at\n"; message += userDataFolderPath; message += "\n?\nWarning: This action is not reversible.\n\n"; message += "Click No if there are other open WebView instnaces.\n"; if (MessageBox.Show(this, message, "Cleanup User Data Folder", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { Directory.Delete(userDataFolderPath, true); } catch (Exception) { } } } }
public static void CopyToNode(Godot.Label control, Props?oldProps, Props props) { ControlComponent.CopyToNode(control, oldProps, props); control.Text = props.text; }
public abstract void Remove(ControlComponent control);
public static void CopyToNode(Godot.BoxContainer control, IBoxContainerProps?oldProps, IBoxContainerProps props) { ControlComponent.CopyToNode(control, oldProps, props); control.Alignment = props.alignment; }
public static void CopyToNode(Godot.BaseButton control, IBaseButtonProps?oldProps, IBaseButtonProps props) { ControlComponent.CopyToNode(control, oldProps, props); control.Disabled = props.disabled; props.onPressed?.Connect(control, "pressed", oldProps?.onPressed); }