protected void fireIconChanged() { if (IconChanged != null) { IconChanged.Invoke(this); } }
private void setAppIcon(Icon icon) { if (icon == null) { return; } this.__appIcon = icon; try { IconChanged?.Invoke(icon); } catch { } }
private void DisplayHandler_FaviconChanged(string uri) { var request = new HttpRequestMessage(HttpMethod.Head, uri); var response = httpClient.SendAsync(request).ContinueWith(task => { if (task.IsCompleted && task.Result.IsSuccessStatusCode) { var icon = new BrowserIconResource(uri); IconChanged?.Invoke(icon); window.UpdateIcon(icon); } }); }
internal void Update() { var icon = nativeMethods.GetWindowIcon(Handle); var iconChanged = icon != IntPtr.Zero && (!(Icon is NativeIconResource) || Icon is NativeIconResource r && r.Handle != icon); var title = nativeMethods.GetWindowTitle(Handle); var titleChanged = Title?.Equals(title, StringComparison.Ordinal) != true; if (iconChanged) { Icon = new NativeIconResource { Handle = icon }; IconChanged?.Invoke(Icon); } if (titleChanged) { Title = title; TitleChanged?.Invoke(title); } }
public BrowserApplicationInstance( AppSettings appSettings, IMessageBox messageBox, int id, bool isMainInstance, int numWindows, string startUrl, IModuleLogger logger, IText text) { this.appSettings = appSettings; this.messageBox = messageBox; this.Id = id; this.isMainInstance = isMainInstance; this.logger = logger; this.text = text; this.startUrl = startUrl; this.settings = new BrowserSettings(); settings.QuitUrl = appSettings.QuitUrl; settings.DownloadDirectory = appSettings.DownloadDirectory; settings.AllowDownloads = true; settings.MainWindow.AllowReloading = appSettings.AllowReload; settings.AdditionalWindow.AllowReloading = appSettings.AllowReload; var instanceLogger = new ModuleLogger(logger, nameof(MainWindow)); window = new MainWindow(appSettings, settings, messageBox, id, isMainInstance, numWindows, startUrl, instanceLogger, text); window.TerminationRequested += () => TerminationRequested?.Invoke(); window.IconChanged += (i) => IconChanged?.Invoke(i); Handle = window.Handle; Icon = new BrowserIconResource(); window.Closing += Control_Closing; window.TitleChanged += Control_TitleChanged; window.PopupRequested += Control_PopupRequested; }
private void tabItem_InternalIconChanged(object sender, DependencyPropertyChangedEventArgs e) { IconChanged?.Invoke(this, e); }
private void OnInternalIconChanged(object sender, EventArgs e) { OnIconChanged(this, e); IconChanged?.Invoke(this, e); }
void WmSetIcon(ref Message m) { IconChanged.Invoke(m, (IconType)m.WParam); }
private static async void OnWebsocketMessage(object sender, MessageEventArgs e) { var Messages = JArray.Parse(e.Data); int MessageType = 0; if (!int.TryParse(Messages[0].ToString(), out MessageType) || MessageType != 8) { return; } var EventName = Messages[1].ToString(); #if DEBUG_EVENTS Debug.WriteLine("Received an event: " + EventName); #endif switch (EventName) { case LoggedInEvent: while (!IsLoggedIn) { try { CurrentSummoner = await Summoner.GetCurrent(); var Lobby = await LobbyRequest.Get(); SetGameModeFromString(Lobby != null ? Lobby.gameConfig.gameMode : "UNKNOWN"); LoggedIn?.Invoke(null, EventArgs.Empty); IconChanged?.Invoke(null, EventArgs.Empty); break; } // We aren't logged in! catch (System.Net.Http.HttpRequestException) { await Task.Delay(TimeSpan.FromSeconds(5)); } } break; case SummonerIconChangedEvent: CurrentSummoner = await Summoner.GetCurrent(); if (CurrentSummoner.profileIconId != ForcedPoroIcon) { IconChanged?.Invoke(null, EventArgs.Empty); } else if (ForcedPoroIcon != -1 && CurrentSummoner.profileIconId != ForcedPoroIcon) { Icon.Set(ForcedPoroIcon); } break; case QueueUpEvent: var QueueEvent = Messages[2]; var QueueURI = QueueEvent["uri"].ToString(); if (QueueURI == "/lol-lobby-team-builder/v1/lobby/countdown" && QueueEvent["data"]["phaseName"].ToString() == "MATCHMAKING") { Debug.WriteLine("Noticed start of matchmaking, setting poro icon."); Icon.SetToPoro(CurrentGameMode, out ForcedPoroIcon); break; } if (QueueURI != "/lol-lobby-team-builder/v1/lobby") { break; } var QueueEventType = QueueEvent["eventType"].ToString(); Debug.WriteLine($"QueueUpEvent: {QueueEventType}"); if (QueueEventType == "Delete") { Icon.ResetToDefault(); ForcedPoroIcon = -1; } else if (ForcedPoroIcon == -1) { Icon.SetToPoro(CurrentGameMode, out ForcedPoroIcon); } break; case GameModeChangedEvent: var EventContainer = Messages[2]; if (EventContainer["uri"].ToString() != "/lol-lobby/v2/lobby") { break; } var EventType = EventContainer["eventType"].ToString(); Debug.WriteLine("GameModeChangedEvent: " + EventType); switch (EventType) { case "Create": var LobbyCreatedEvent = JsonConvert.DeserializeObject <LobbyCreateEvent>(Messages[2].ToString()); SetGameModeFromString(LobbyCreatedEvent.data.gameConfig.gameMode); break; case "Delete": CurrentGameMode = LeagueOfLegends.GameMode.Unknown; break; case "Update": var LobbyUpdatedEvent = JsonConvert.DeserializeObject <LobbyCreateEvent>(Messages[2].ToString()); SetGameModeFromString(LobbyUpdatedEvent.data.gameConfig.gameMode); break; } GameModeUpdated?.Invoke(null, EventArgs.Empty); break; case GameEvent: var GameEventData = Messages[2]; var GameURI = GameEventData["uri"].ToString(); if (GameURI != "/lol-gameflow/v1/session") { break; } if (GameEventData["data"] == null) { break; } var Phase = GameEventData["data"]["phase"].ToString(); Debug.WriteLine("Current GameFlow phase: " + Phase); if (Phase == "InProgress") { Icon.ResetToDefault(); } break; } }
private static async void Init() { IsActive = true; var Parts = LockFile.Split(':'); ushort Port = ushort.Parse(Parts[2]); var Password = Parts[3]; var Protocol = Parts[4]; APIDomain = String.Format("{0}://127.0.0.1:{1}", Protocol, Port); Request.SetUserData("riot", Password); #if DEBUG_EVENTS try { var AllEventsText = await Request.Get(APIDomain + "/help"); File.WriteAllText("events.json", AllEventsText); } catch (System.Net.Http.HttpRequestException) { } #endif var Versions = await JSONRequest.Get <string[]>("http://ddragon.leagueoflegends.com/api/versions.json"); LatestVersion = Versions[0]; Started?.Invoke(null, EventArgs.Empty); Connection = new WebSocket("wss://127.0.0.1:" + Port + "/", "wamp"); Connection.SetCredentials("riot", Password, true); Connection.SslConfiguration.EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12; Connection.OnMessage += OnWebsocketMessage; Connection.Connect(); #if !DEBUG_EVENTS Connection.Send("[5,\"" + SummonerIconChangedEvent + "\"]"); Connection.Send("[5,\"" + QueueUpEvent + "\"]"); Connection.Send("[5,\"" + GameModeChangedEvent + "\"]"); Connection.Send("[5,\"" + GameEvent + "\"]"); #else var HelpDocument = JsonConvert.DeserializeObject <DebugEventHelper>(File.ReadAllText("events.json")); foreach (var EventName in HelpDocument.events) { var Event = EventName.Key; if (Event == "OnJsonApiEvent") { continue; } Connection.Send("[5,\"" + Event + "\"]"); } #endif try { CurrentSummoner = await Summoner.GetCurrent(); var Lobby = await LobbyRequest.Get(); SetGameModeFromString(Lobby != null ? Lobby.gameConfig.gameMode : "UNKNOWN"); LoggedIn?.Invoke(null, EventArgs.Empty); IconChanged?.Invoke(null, EventArgs.Empty); } // We aren't logged in! catch (System.Net.Http.HttpRequestException e) { #if !DEBUG_EVENTS Connection.Send("[5,\"" + LoggedInEvent + "\"]"); #endif } }
/// <summary> /// Raises the <see cref="E:IconChanged"/> event. /// </summary> /// <param name="e">The <see cref="MarkerEventArgs"/> instance containing the event data.</param> protected virtual void OnIconChanged(MarkerEventArgs e) { IconChanged?.Invoke(this, e); }