public Login() { this.InitializeComponent(); this.Loaded += async(sender, e) => { if (NotLogged) { await ClearState(); } }; okButton.Click += DoLogin; captchaContainer.Click += async(sender, e) => { ImageSource = await Refresh?.Invoke(this, new EventArgs()); }; username.TextChanged += (sender, e) => { if (e.Reason == AutoSuggestionBoxTextChangeReason.UserInput) { sender.ItemsSource = names.Where((item) => { return(item.StartsWith(sender.Text)); }); remember.IsChecked = false; password.Password = ""; } }; username.SuggestionChosen += (sender, e) => { var username = e.SelectedItem as string; password.Password = Globals.Accounts[UsedFor][username]; remember.IsChecked = true; }; }
private void LeaveMember(string user_token) { try { this.Loading(true); var api = new ApiAsnycTask(this.Context, GetString(Resource.String.api_url) + "user/LeaveMember", user_token); api.Execute(); api.SendFinish += (s, e) => { var _result = JsonConvert.DeserializeObject <ApiResult <string> >(e.Json); if (_result != null) { if (_result.success == true) { var app_cache = new AppPreferences(this.Context); app_cache.UserTokenKey = ""; Refresh?.Invoke(this, new RefreshEventArgs(true)); } else { AppDialog.SNG.Alert(this.Context, _result.message); } } this.Loading(false); }; } catch (Java.Lang.Exception ex) { Log.Error(this.GetType().Name, ex.Message); } }
async Task Engine() { try { while (IsActive && Piece != null) { await Task.Delay(Piece.Delay); if (!IsPaused) { await Piece.SetPosition(Piece.Position.x, Piece.Position.y + 1, LastRow); if (Piece.Position.y + Piece.Tetris.GridHeight >= LastRow || !Piece.Active) { Console.WriteLine($"Piece has reached Row {Piece.Position.y + Piece.Tetris.GridHeight}"); Piece.Active = false; DeActivate?.Invoke(Piece); } Refresh?.Invoke(); } } } catch (Exception ex) { Console.WriteLine(); Console.WriteLine("******** ENGINE ERROR **********"); Console.WriteLine(ex); throw; } }
void InvokeRefresh() { if (Refresh != null) { Refresh.Invoke(); } }
private void NotifyRefresh() { if (Refresh != null) { Refresh.Invoke(new RefreshEventArgs("")); } }
public Boolean RemoveFromConfig(Int32 index) { if (!ListProtocols.Any()) { Refresh?.Invoke(this, new EventArgs()); if (!ListProtocols.Any()) { return(false); } else { RemoveFromConfig(index); } } if (ListProtocols.ContainsKey(index)) { _rootNode.Elements(DataConfiguration) .Select(x => x).ToArray()[index].Remove(); _rootNode.Save(ConfigFileName); Refresh?.Invoke(this, new EventArgs()); return(true); } else { return(false); } }
private async Task BackgroundCacheOperation() { var originalKeys = cache.Keys.ToArray(); foreach (var kv in originalKeys) { if (!cache.TryGetValue(kv, out CacheEntry entry)) { continue; } if (entry.IsExpired()) { cache.TryRemove(kv, out _); } else if (RefreshTickets) { await Refresh?.Invoke(entry); } } var finalKeys = cache.Keys.ToArray(); var newKeys = finalKeys.Except(originalKeys); var purgedKeys = originalKeys.Except(finalKeys); if (newKeys.Any() || purgedKeys.Any()) { logger.LogDebug("Cache Operation. New: {NewKeys}; Purged: {PurgedKeys}", string.Join("; ", newKeys), string.Join("; ", purgedKeys)); } }
protected IEnumerator RefreshDestination() { do { Refresh?.Invoke(); yield return(waiting); } while (enabled); }
[HarmonyPriority(Priority.HigherThanNormal)] // Above alexanderabramov's Real Hit Chance mod public static bool OverrideDisplayedHitChance(CombatHUDWeaponSlot __instance, float chance) { try { HitChance.Invoke(__instance, new object[] { chance }); __instance.HitChanceText.text = string.Format(WeaponHitChanceFormat, Mathf.Clamp(chance * 100f, 0f, 100f)); Refresh.Invoke(__instance, null); return(false); } catch (Exception ex) { return(Error(ex)); } }
public async Task <int> Run(DiceSite Site) { var currentAmount = _settings.BaseBet; bool bettingHigh = true; if (_settings.BetOn == BetOnEnum.Low) { bettingHigh = false; } while (CanExecute(Site)) { if (!await Site.PlaceBet(bettingHigh, currentAmount, _settings.Chance)) { // perdita if (_settings.BetAction_OnLose == BetResultAction.ReturnToBase) { currentAmount = _settings.BaseBet; } if (_settings.BetAction_OnLose == BetResultAction.Increase) { currentAmount *= (_settings.IncreaseAmount_OnLose / 100m + 1); } if (_settings.BetAction_OnLose == BetResultAction.ChangeOdds) { _settings.BetOdds = _settings.NewOdd_OnLose; } } else { // vincita if (_settings.BetAction_OnWin == BetResultAction.ReturnToBase) { currentAmount = _settings.BaseBet; } if (_settings.BetAction_OnWin == BetResultAction.Increase) { currentAmount *= (_settings.IncreaseAmount_OnWin / 100m + 1); } if (_settings.BetAction_OnWin == BetResultAction.ChangeOdds) { _settings.BetOdds = _settings.NewOdd_OnWin; } } if (_settings.BetOn == BetOnEnum.Alternate) { bettingHigh = !bettingHigh; } Refresh?.Invoke(this, EventArgs.Empty); } ; return(await Task <int> .FromResult(Site.wins - Site.losses)); }
public void Add(string message, EType type) { Notification item = new Notification() { Message = message, Type = type }; Notifications.Enqueue(item); Refresh?.Invoke(this, EventArgs.Empty); }
public void SetRefresh(bool isRefresh) { _isRefreshing = isRefresh; if (_isRefreshing) { VisualStateManager.GoToState(this, RefreshState, true); Refresh?.Invoke(); } else { VisualStateManager.GoToState(this, NormalState, true); } }
public Dictionary <int, PingerModule.IPinger> GetFromConfig() { if (!ListProtocols.Any()) { Refresh?.Invoke(this, new EventArgs()); if (!ListProtocols.Any()) { return(ListProtocols); } GetFromConfig(); } return(ListProtocols); }
public void ChangeSelectedIndex(int newValue, int oldValue) { try { ItemsSource[newValue].IsActive = true; ItemsSource[oldValue].IsActive = false; if (ItemsSource[newValue].UnreadCount > 0) { ItemsSource[newValue].UnreadCount = 0; Refresh?.Invoke(this, new EventArgs()); } } catch { } }
private void ListView_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) { var index = ItemsSource.FindIndex(item => item == (e.OriginalSource as FrameworkElement).DataContext as HeaderModel); try { if (ItemsSource[index].UnreadCount > 0) { ItemsSource[index].UnreadCount = 0; } Refresh?.Invoke(this, new EventArgs()); } catch { } }
public void AddMod(Mod mod) { if (mod == null) { return; } Mod oldMod = GetModFromDirectory(mod.ModDirectory); if (oldMod != null) { Remove(oldMod); } Add(mod); Refresh?.Invoke(); }
public static void MergerManyShapeFile(String[] files, string TargetFile, ContorlValue contorlValue, Refresh refreshProBar) { if (File.Exists(TargetFile)) { File.Delete(TargetFile); } contorlValue.Invoke(0, files.Length - 1); File.Copy(files[0], TargetFile, true); FileStream fileStream1 = new FileStream(TargetFile, FileMode.Open, FileAccess.ReadWrite); BinaryReader binaryReader1 = new BinaryReader(fileStream1); BinaryWriter binaryWriter = new BinaryWriter(fileStream1); ShapeHeader shapeHeader1 = new ShapeHeader(); shapeHeader1 = ShapeFucntion.ReadShapeHeader(binaryReader1); Record record = new Record(); while (binaryReader1.BaseStream.Position < binaryReader1.BaseStream.Length) { record = ShapeFucntion.ReadRecord(binaryReader1); } int recordNum = record.recordNumber; for (int i = 1; i < files.Length; i++) { FileStream fileStream2 = new FileStream(files[i], FileMode.Open, FileAccess.Read); BinaryReader binaryReader2 = new BinaryReader(fileStream2); ShapeHeader shapeHeader2 = new ShapeHeader(); shapeHeader2 = ShapeFucntion.ReadShapeHeader(binaryReader2); shapeHeader1 = ShapeFucntion.MergeShapeHeader(shapeHeader1, shapeHeader2); while (binaryReader2.BaseStream.Position < binaryReader2.BaseStream.Length) { recordNum++; record = ShapeFucntion.ReadRecord(binaryReader2); record.recordNumber = recordNum; ShapeFucntion.WriteRecord(record, binaryWriter); } binaryReader2.Close(); fileStream2.Close(); refreshProBar.Invoke(i); Thread.Sleep(500); } fileStream1.Seek(0, SeekOrigin.Begin); ShapeFucntion.WriteShapeHeader(shapeHeader1, binaryWriter); binaryReader1.Close(); binaryWriter.Close(); fileStream1.Close(); }
/// <summary> /// Set control to initial state /// </summary> public async Task ClearState() { Animations.StartFadeAnimation(backdrop, this, FADE_DELAY); // get username and password of last logged user var accounts = Globals.Accounts[UsedFor]; var username = accounts.Active; var password = accounts[username]; if (CaptchaRequired) { ImageSource = await Refresh?.Invoke(this, new EventArgs()); } names = accounts.Users; this.username.Text = username; this.username.ItemsSource = names; this.password.Password = password ?? ""; this.remember.IsChecked = !String.IsNullOrEmpty(password); NotLogged = true; }
private void Controller() { journalmonitor = new EDJournalUIScanner(InvokeAsyncOnUiThread); journalmonitor.OnNewJournalEntry += (je) => { Entry(je, false); }; journalmonitor.OnNewUIEvent += (ui) => { InvokeAsyncOnUiThread(() => NewUI?.Invoke(ui)); }; LogLine?.Invoke("Reading Journals"); Reset(); journalmonitor.SetupWatchers(); // order the reading of last 2 files (in case continue) and fire back the last two journalmonitor.ParseJournalFilesOnWatchers(UpdateWatcher, 2, (a) => InvokeAsyncOnUiThread(() => { Entry(a, true); }), 2); InvokeAsyncOnUiThread(() => { Refresh?.Invoke(currenthe); }); LogLine?.Invoke("Finished reading Journals"); journalmonitor.StartMonitor(); while (!stopit) { if (RequestRescan) { RequestRescan = false; LogLine?.Invoke("Re-reading Journals"); journalmonitor.StopMonitor(); Reset(); journalmonitor.SetupWatchers(); journalmonitor.ParseJournalFilesOnWatchers(UpdateWatcher, 2, (a) => InvokeAsyncOnUiThread(() => { Entry(a, true); }), 2); journalmonitor.StartMonitor(); InvokeAsyncOnUiThread(() => { Refresh?.Invoke(currenthe); }); LogLine?.Invoke("Finished reading Journals"); } Thread.Sleep(100); } journalmonitor.StopMonitor(); }
private void ItemsControl_Tapped(object sender, TappedRoutedEventArgs e) { var index = ItemsSource.FindIndex(item => item == (e.OriginalSource as FrameworkElement).DataContext as HeaderModel); if (SelectedIndex == index) { BackToTop?.Invoke(this, new EventArgs()); try { if (ItemsSource[index].UnreadCount > 0) { ItemsSource[index].UnreadCount = 0; Refresh?.Invoke(this, new EventArgs()); } } catch { } } else { SelectedIndex = index; } }
static void RouteSkill(SkillCooldown skillCooldown) { if (skillCooldown.Cooldown == 0) { ResetSkill(skillCooldown.Skill); } if (NormalSkillsQueue.ToList().Any(x => x.Skill.Name == skillCooldown.Skill.Name) || LongSkillsQueue.ToList().Any(x => x.Skill.Name == skillCooldown.Skill.Name)) { Refresh?.Invoke(skillCooldown); } else { if (skillCooldown.Cooldown < LongSkillTreshold) { App.Current.Dispatcher.Invoke(() => NormalSkillsQueue.Add(skillCooldown)); } else { App.Current.Dispatcher.Invoke(() => LongSkillsQueue.Add(skillCooldown)); } } }
private void DeleteWorld(WorldModel world) { new Thread(() => { State = EState.Deleting; string status = Remote.DeleteWorld(world.ID); if (status != "ok") { MessageBox.Show($"An error occurred while deleting world: {status}", "Error"); } else { MessageBox.Show("World deleted successfully!", "Success"); Refresh?.Invoke(this, EventArgs.Empty); Close(); } State = EState.Idle; }).Start(); }
private void ListenerClickBT(object sender, System.EventArgs e) { var app_cache = new AppPreferences(this.Context); var view = (Button)sender; switch (view.Id) { case Resource.Id.btn_logout: app_cache.UserTokenKey = ""; Refresh?.Invoke(this, new RefreshEventArgs(true)); break; case Resource.Id.btn_leave: AppDialog.SNG.CancelAlert(this.Context, "모든 정보가 삭제됩니다.\n정말로 탈퇴하시겠습니까?", (s1, e1) => { var _token = app_cache.UserTokenKey; LeaveMember(_token); }); break; } }
private void SaveInConfig(CustomConfigAttribute attribute) { if (_rootNode == null) { return; } XElement dataConfiguration = new XElement(DataConfiguration); dataConfiguration.Add(new XElement(nameof(attribute.Host), attribute.Host, new XAttribute("Name", CustomConfigAttribute.GetValueAttribute(nameof(attribute.Host) ?? ""))), new XElement(nameof(attribute.Interval), attribute.Interval, new XAttribute("Name", CustomConfigAttribute.GetValueAttribute(nameof(attribute.Interval) ?? ""))), new XElement(nameof(attribute.Protocol), attribute.Protocol, new XAttribute("Name", CustomConfigAttribute.GetValueAttribute(nameof(attribute.Protocol) ?? "")))); if (attribute.HttpCode != null) { dataConfiguration.Add(new XElement(nameof(attribute.HttpCode), attribute.HttpCode, new XAttribute("Name", CustomConfigAttribute.GetValueAttribute(nameof(attribute.HttpCode) ?? "")))); } else if (attribute.Port != null) { dataConfiguration.Add(new XElement(nameof(attribute.Port), attribute.Port, new XAttribute("Name", CustomConfigAttribute.GetValueAttribute(nameof(attribute.Port) ?? "")))); } _rootNode.Add(dataConfiguration); _rootNode.Save(ConfigFileName); Refresh?.Invoke(this, new EventArgs()); }
public void AddProfiles(List <Profile> profiles) { foreach (Profile profile in profiles) { if (!InternalDictionary.ContainsKey(profile.Hash)) { switch (profile.Type) { case Profile.ProfileType.Custom: Add(profile); break; case Profile.ProfileType.LatestBeta: LatestBeta = profile; break; case Profile.ProfileType.LatestRelease: LatestRelease = profile; break; } } } Refresh?.Invoke(); }
protected virtual void OnRefresh() { Refresh?.Invoke(this, new TimerEventArgs(this)); }
public void OnRefresh() { Refresh?.Invoke(this, new EventArgs()); }
private void Image_Tapped(object sender, TappedRoutedEventArgs e) { Refresh?.Invoke(this, null); }
public void Rfsh(itmAction _itmaction) { Refresh.Invoke(_itmaction); }
private void RegisterWindowCallbacks() { if (_callbackRegistered) { return; } _callbackRegistered = true; // [NOTE] // Do not register callback to GLFW as lambda or method. (That cannot work) // Put delegate on a field and register it to GLFW. _posCallback = (wnd, x, y) => { if (wnd != _window) { return; } _location = new Vector2i(x, y); Move?.Invoke(this, new WindowPositionEventArgs(x, y)); }; GLFW.SetWindowPosCallback(_window, _posCallback); _sizeCallback = (wnd, width, height) => { if (wnd != _window) { return; } GLFW.GetWindowFrameSize(_window, out var left, out var top, out var right, out var bottom); _clientSize = new Vector2i(width, height); _size = new Vector2i(_clientSize.X + left + right, _clientSize.Y + top + bottom); Resize?.Invoke(this, new ResizeEventArgs(width, height)); }; GLFW.SetWindowSizeCallback(_window, _sizeCallback); _frameBufferSizeCallback = (wnd, width, height) => { if (wnd != _window) { return; } _frameBufferSize = new Vector2i(width, height); FrameBufferSizeChanged?.Invoke(this, _frameBufferSize); }; GLFW.SetFramebufferSizeCallback(_window, _frameBufferSizeCallback); _closeCallback = wnd => { if (wnd != _window) { return; } var cancel = false; var e = new CancelEventArgs(&cancel); Closing?.Invoke(this, e); if (e.Cancel) { GLFW.SetWindowShouldClose(_window, false); } }; GLFW.SetWindowCloseCallback(_window, _closeCallback); _iconifyCallback = (wnd, minimized) => { if (wnd != _window) { return; } Minimized?.Invoke(this, new MinimizedEventArgs(minimized)); }; GLFW.SetWindowIconifyCallback(_window, _iconifyCallback); _focusCallback = (wnd, focused) => { if (wnd != _window) { return; } FocusedChanged?.Invoke(this, new FocusedChangedEventArgs(focused)); }; GLFW.SetWindowFocusCallback(_window, _focusCallback); _charCallback = (wnd, unicode) => { if (wnd != _window) { return; } CharInput?.Invoke(this, new CharInputEventArgs(unicode)); }; GLFW.SetCharCallback(_window, _charCallback); _keyCallback = (wnd, glfwKey, scanCode, action, glfwMods) => { if (wnd != _window) { return; } var e = new KeyboardKeyEventArgs(glfwKey, scanCode, glfwMods, action == GlfwInputAction.Repeat); if (action == GlfwInputAction.Release) { KeyUp?.Invoke(this, e); } else { KeyDown?.Invoke(this, e); } }; GLFW.SetKeyCallback(_window, _keyCallback); _cursorEnterCallback = (wnd, entered) => { if (wnd != _window) { return; } if (entered) { MouseEnter?.Invoke(this); } else { MouseLeave?.Invoke(this); } }; GLFW.SetCursorEnterCallback(_window, _cursorEnterCallback); _mouseButtonCallback = (wnd, button, action, mods) => { if (wnd != _window) { return; } var e = new MouseButtonEventArgs(button, action, mods); if (action == GlfwInputAction.Release) { MouseUp?.Invoke(this, e); } else { MouseDown?.Invoke(this, e); } }; GLFW.SetMouseButtonCallback(_window, _mouseButtonCallback); _cursorPosCallback = (wnd, posX, posY) => { if (wnd != _window) { return; } var e = new MouseMoveEventArgs(new Vector2((int)posX, (int)posY)); MouseMove?.Invoke(this, e); }; GLFW.SetCursorPosCallback(_window, _cursorPosCallback); _scrollCallback = (wnd, offsetX, offsetY) => { if (wnd != _window) { return; } var e = new MouseWheelEventArgs((float)offsetX, (float)offsetY); MouseWheel?.Invoke(this, e); }; GLFW.SetScrollCallback(_window, _scrollCallback); _dropCallback = (wnd, count, paths) => { if (wnd != _window) { return; } var e = new FileDropEventArgs(count, paths); FileDrop?.Invoke(this, e); }; GLFW.SetDropCallback(_window, _dropCallback); _joystickCallback = (joystick, state) => { var e = new JoystickConnectionEventArgs(joystick, state == GlfwConnectedState.Connected); JoystickConnectionChanged?.Invoke(this, e); }; GLFW.SetJoystickCallback(_joystickCallback); _monitorCallback = (monitor, state) => { var e = new MonitorConnectionEventArgs(monitor, state == GlfwConnectedState.Connected); MonitorConnectionChanged?.Invoke(this, e); }; GLFW.SetMonitorCallback(_monitorCallback); _refreshCallback = wnd => { if (wnd != _window) { return; } Refresh?.Invoke(this); }; GLFW.SetWindowRefreshCallback(_window, _refreshCallback); }