private void ClearListToolStripMenuItem_Click(object sender, EventArgs e) { AppTimer.Stop(); if (WaveOutEvent != null) { WaveOutEvent.Dispose(); WaveOutEvent = null; } if (AudioFileReader != null) { AudioFileReader.Dispose(); AudioFileReader = null; } FlowLayoutPanelMusic.Controls.Clear(); Music.Clear(); LabelMusicCurrentTimeState.Text = "--:--"; LabelMusicEndTime.Text = "--:--"; CurrentPlayingMusicIndex = 0; PlaybackBarControl.Val = 0; PictureBoxMusicCover.BackgroundImage = Properties.Resources.MusicTon; ButtonPlayPause.BackgroundImage = Properties.Resources.Play; PlayAndPauseToolStripMenuItem.Text = "Play"; MusicState = MusicState.Pause; this.Text = "MusicPlayer"; }
private void HandleProvideRoomAccessCheck(IIncommingMessage message) { var data = message.Deserialize(new RoomAccessProvideCheckPacket()); var roomController = _roomsPlugin.GetRoomController(data.RoomId); if (roomController == null) { message.Respond("There's no room controller with room id " + data.RoomId, ResponseStatus.NotHandled); return; } var accessProvider = roomController._accessProvider ?? DefaultAccessProvider; var isProviderDone = false; var requester = new UsernameAndPeerIdPacket() { PeerId = data.PeerId, Username = data.Username }; // Invoke the access provider accessProvider.Invoke(requester, (access, error) => { // In case provider timed out if (isProviderDone) { return; } isProviderDone = true; if (access == null) { // If access is not provided message.Respond(error ?? "", ResponseStatus.Failed); return; } message.Respond(access, ResponseStatus.Success); if (Logger.IsLogging(LogLevel.Trace)) { Logger.Trace("Room controller gave address to peer " + data.PeerId + ":" + access); } }); // Timeout the access provider AppTimer.AfterSeconds(_roomsPlugin.AccessProviderTimeout, () => { if (!isProviderDone) { isProviderDone = true; message.Respond("Timed out", ResponseStatus.Timeout); Logger.Error("Access provider took longer than " + _roomsPlugin.AccessProviderTimeout + " seconds to provide access. " + "If it's intended, increase the threshold at Msf.Server.Rooms.AccessProviderTimeout"); } }); }
public DynamicEquipmentStatusBoard() { InitializeComponent(); LoadActiveStatusPages(); AppTimer.Subscribe(this, TimerInterval.Seconds); }
public EquipmentOutagesStatusBoard() { InitializeComponent(); AppTimer.Subscribe(this, TimerInterval.Minutes); AppTimer.Subscribe(this, TimerInterval.NewDayLocal); RefreshData(); }
public ApplicationStatusBar() { InitializeComponent(); AppTimer.Subscribe(this, TimerInterval.Minutes); CurrentUser.Subscribe(this); SetApplicationDateTime(); }
public StatusBarControl() { InitializeComponent(); SetDateTime(); AppTimer.Subscribe(this, TimerInterval.Minutes); AppModeNotifications.Subscribe(this); }
private void killTimer() { try { AppTimer.Dispose(); } catch { //swallow } }
public void onExpiration(Object cbArg) { AppTimer temp = (AppTimer)cbArg; if (temp.state != TimerState.PENDING) { System.Console.Error.WriteLine("ERROR: Timer executed and state != PENDING."); } System.Console.Error.WriteLine("ERROR: This timer should have been cancelled by now"); }
public About() { InitializeComponent(); IsFormShown = false; timer = new AppTimer(); timer.OnCount += new EventHandler <OnCountEventArgs>(OnTimerCount); LocalizeWindow(); UpdateUiBySettings(); timer.Start(); }
public CountdownViewModel() { countdown = new CountdownModel(); timer = new AppTimer(200); timer.AfterTick += AfterTick; timerSheets = new ObservableCollection <TimerSheetViewModel>(); CreateCommand = new CountdownViewModelCreateCommand(this); OutputFilename = ConfigurationManager.AppSettings["Filename"]; System.IO.File.Create(OutputFilename); }
public CountdownViewModel(SaveList saveList) { OutputFilename = ConfigurationManager.AppSettings["Filename"]; Countdown = new CountdownModel(); timer = new AppTimer(200); timer.AfterTick += AfterTick; TimerSheets = new ObservableCollection <TimerSheetViewModel>(); CreateCommand = new DelegateCommandResolver(SaveChanged, () => CanUpdate); System.IO.File.Create(OutputFilename); DoSaveList += saveList; }
public StatusBar() { InitializeComponent(); SetTime(); SetDate(); CurrentUserNotifications.Subscribe(this); AppTimer.Subscribe(this, TimerInterval.Minutes); AppTimer.Subscribe(this, TimerInterval.NewDayLocal); }
public static void StartRefreshDeviceListViewTimer() { if (_refreshDeviceListViewTimer?.IsActive ?? false) { return; } _refreshDeviceListViewTimer = new AppTimer((object sender, ElapsedEventArgs e) => { RefreshDeviceListView?.Invoke(sender, EventArgs.Empty); }, 2000); _refreshDeviceListViewTimer.Start(); }
void PostInitialize(params MuiAppService[] serviso) { foreach (var windex in WidgetsIndexed) { Widgets[windex].Initialize(this, null); } Services.AddRange(serviso); MuiAppService.RegisterAll(this); MouseWheel += OnMouseWheel; AppTimer.Tick += AppTimer_Tick; AppTimer.Start(); }
private static void StartMinerStatsCheckTimer() { if (_minerStatsCheck?.IsActive ?? false) { return; } _minerStatsCheck = new AppTimer(async(object sender, ElapsedEventArgs e) => { await MiningManager.MinerStatsCheck(); }, ConfigManager.GeneralConfig.MinerAPIQueryInterval * 1000); _minerStatsCheck.Start(); }
private static void StartPreventSleepTimer() { if (_preventSleepTimer?.IsActive ?? false) { return; } // sleep time setting is minimal 1 minute _preventSleepTimer = new AppTimer((s, e) => { PInvoke.PInvokeHelpers.PreventSleep(); }, 20 * 1000);// leave this interval, it works _preventSleepTimer.Start(); }
public void Pause() { try { resumeSeconds = this.GetSecondsRemaining(); paused = true; AppTimer.Dispose(); AppTimer = null; } catch { } }
private static void StartComputeDevicesCheckTimer() { if (_cudaDeviceCheckerTimer?.IsActive ?? false) { return; } _cudaDeviceCheckerTimer = new AppTimer(async(object sender, ElapsedEventArgs e) => { if (!GlobalDeviceSettings.Instance.CheckForMissingGPUs) { return; } // this function checks if count of CUDA devices is same as it was on application start, reason for that is // because of some reason (especially when algo switching occure) CUDA devices are dissapiring from system // creating tons of problems e.g. miners stop mining, lower rig hashrate etc. var hasMissingGPUs = await DeviceDetection.CheckIfMissingGPUs(); if (!hasMissingGPUs) { return; } if (GlobalDeviceSettings.Instance.RestartMachineOnLostGPU) { Logger.Info("ApplicationStateManager.Timers", $"Detected missing GPUs will execute 'OnGPUsLost.bat'"); try { var onGpusLost = new ProcessStartInfo { FileName = Paths.RootPath("OnGPUsLost.bat"), WindowStyle = ProcessWindowStyle.Minimized }; using (var p = Process.Start(onGpusLost)) { //p.WaitForExit(10 * 1000); } } catch (Exception ex) { Logger.Error("ApplicationStateManager.Timers", $"OnGPUsMismatch.bat error: {ex.Message}"); } } else { Logger.Info("ApplicationStateManager.Timers", $"Detected missing GPUs"); AvailableNotifications.CreateMissingGPUsInfo(); } }, 5 * 60 * 1000); // check every 5 minutes _cudaDeviceCheckerTimer.Start(); }
public void Ctor() { // given AppTimer timer1 = new AppTimer(); IList <string> times1 = new List <string>(); // when timer1.OnCount += (object sender, OnCountEventArgs e) => { times1.Add(e.Time); }; timer1.Start(); Thread.Sleep(6_000); timer1.Start(); // then Assert.IsTrue(times1.Count == 5); }
public void SetMode(AppMode newMode) { adminPageControls.Visibility = newMode == AppMode.Admin ? Visibility.Visible : Visibility.Collapsed; adminTechNextPage.Visibility = pageCount > 1 && newMode != AppMode.Slide ? Visibility.Visible : Visibility.Collapsed; if (newMode == AppMode.Slide && pageCount > 1) { SlideIntervalValueChanged(this, null); } else { AppTimer.Unsubscribe(this); } if (newMode == AppMode.Slide) { Save(); } }
public void onExpiration(Object cbArg) { AppTimer temp = (AppTimer)cbArg; if (temp.state == TimerState.PENDING) { try { temp.timer.cancel(); } catch (LBMException ex) { System.Console.Error.WriteLine("Error cancelling LBMTimer: " + ex.Message); System.Environment.Exit(1); } temp.state = TimerState.CANCELLED; temp.sync.Release(); } }
public static void StartInternetCheckTimer() { if (ConfigManager.GeneralConfig.IdleWhenNoInternetAccess) { OnInternetCheck?.Invoke(null, Helpers.IsConnectedToInternet()); } if (_internetCheckTimer?.IsActive ?? false) { return; } _internetCheckTimer = new AppTimer((object sender, ElapsedEventArgs e) => { if (ConfigManager.GeneralConfig.IdleWhenNoInternetAccess) { OnInternetCheck?.Invoke(null, Helpers.IsConnectedToInternet()); } }, 1000 * 60); _internetCheckTimer.Start(); }
private void _init() { _setUpSFML(); //resource-ok betöltése (font-ok és textúrák, képek a játékhoz) appAssets.LoadResources(Constants.FONT_NAMES); m_DeltaTime = 0.0; m_StepTime = 1.0 / 60.0; m_MaxDeltaTime = 0.25; //0.25f m_Accumulator = 0.0; m_Time = 0.0; m_FPS = 0.0; m_Timer = new AppTimer(); //ChangeGameState( new GameScene(this) ); fpsUpdater = new cRegulator(); fpsUpdater.resetByPeriodTime(1.0f); //Idő szöveg timeText = new Text("", appAssets.GetFont("pf_tempesta_seven")); timeText.Position = new Vector2f(this.defaultView.Size.X - 500, 30); timeText.CharacterSize = 28; // in pixels, not points! timeText.FillColor = Color.White; timeText.Style = Text.Styles.Bold; GlobalClock.Start(); // currentState = new GameScene(this); // currentState.Enter(); m_AppRunning = true; definiedStates.Add("main-menu", () => { this.SetGameState(new MainMenu(this)); }); definiedStates.Add("game-scene", () => { this.SetGameState(new GameScene(this)); }); this.ChangeGameState("main-menu"); }
static void Main(String[] args) { LBMContext ctx = null; /* Context object: container for UM "instance". */ /*** Initialization: create necessary UM objects. ***/ try { ctx = new LBMContext(); } catch (LBMException ex) { System.Console.Error.WriteLine("Error initializing LBM objects: " + ex.Message); System.Environment.Exit(1); } Callback cb = new Callback(); AppTimer timer = new AppTimer(ctx, 10000, cb); try { System.Threading.Thread.Sleep(1000); } catch (Exception eex) { System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception: " + eex.Message); System.Environment.Exit(1); } if (timer.state == TimerState.PENDING) { CancelCallback ccb = new CancelCallback(); LBMTimer cancelTimer = new LBMTimer(ctx, 0, ccb.onExpiration, (Object)timer); timer.sync.WaitOne(); } ctx.close(); Console.WriteLine("cts is closed, Press any key to exit..."); Console.ReadLine(); } /* main */
private static void StartComputeDevicesCheckTimer() { if (_cudaDeviceCheckerTimer?.IsActive ?? false) { return; } _cudaDeviceCheckerTimer = new AppTimer(async(object sender, ElapsedEventArgs e) => { if (!ConfigManager.GeneralConfig.RunScriptOnCUDA_GPU_Lost) { return; } // this function checks if count of CUDA devices is same as it was on application start, reason for that is // because of some reason (especially when algo switching occure) CUDA devices are dissapiring from system // creating tons of problems e.g. miners stop mining, lower rig hashrate etc. var nvidiaCount = await DeviceDetection.CUDADevicesNumCheck(); var isDevicesCountMistmatch = nvidiaCount != AvailableDevices.AvailNVGpus; if (isDevicesCountMistmatch) { try { var onGpusLost = new ProcessStartInfo { FileName = Paths.RootPath("OnGPUsLost.bat"), WindowStyle = ProcessWindowStyle.Minimized }; using (var p = Process.Start(onGpusLost)) { //p.WaitForExit(10 * 1000); } } catch (Exception ex) { Logger.Error("ApplicationStateManager.Timers", $"OnGPUsMismatch.bat error: {ex.Message}"); } } }, 60 * 1000); _cudaDeviceCheckerTimer.Start(); }
static void Main(String[] args) { LBMContext ctx = null; /* Context object: container for UM "instance". */ /*** Initialization: create necessary UM objects. ***/ try { ctx = new LBMContext(); } catch(LBMException ex) { System.Console.Error.WriteLine("Error initializing LBM objects: " + ex.Message); System.Environment.Exit(1); } Callback cb = new Callback(); AppTimer timer = new AppTimer(ctx,10000,cb); try { System.Threading.Thread.Sleep(1000); } catch (Exception eex) { System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception: " + eex.Message); System.Environment.Exit(1); } if (timer.state == TimerState.PENDING) { CancelCallback ccb = new CancelCallback(); LBMTimer cancelTimer = new LBMTimer(ctx,0,ccb.onExpiration,(Object)timer); timer.sync.WaitOne(); } ctx.close(); }
private void SlideIntervalValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { AppTimer.Unsubscribe(this); AppTimer.Subscribe(this, TimerInterval.Seconds, (int)slideInterval.Value); }
public void StartAppTimer() { AppTimer.StopAppTimer(); AppTimer.StartAppTimer(dispatcherTimer_Tick); }
public GameScene(SfmlApp controller) : base(controller) { levelTimer = new AppTimer(); }
public void DefaultSpawnRequestHandler(SpawnRequestPacket packet, IIncommingMessage message) { _logger.Debug("Default spawn handler started handling a request to spawn process"); var controller = _spawners.GetController(packet.SpawnerId); if (controller == null) { message.Respond("Failed to spawn a process. Spawner controller not found", ResponseStatus.Failed); return; } var port = _spawners.GetAvailablePort(); // Check if we're overriding an IP to master server var masterIp = string.IsNullOrEmpty(controller.DefaultSpawnerSettings.MasterIp) ? controller.Connection.ConnectionIp : controller.DefaultSpawnerSettings.MasterIp; // Check if we're overriding a port to master server var masterPort = controller.DefaultSpawnerSettings.MasterPort < 0 ? controller.Connection.ConnectionPort : controller.DefaultSpawnerSettings.MasterPort; // Machine Ip var machineIp = controller.DefaultSpawnerSettings.MachineIp; // Path to executable var path = controller.DefaultSpawnerSettings.ExecutablePath; if (string.IsNullOrEmpty(path)) { path = File.Exists(Environment.GetCommandLineArgs()[0]) ? Environment.GetCommandLineArgs()[0] : Process.GetCurrentProcess().MainModule.FileName; } // In case a path is provided with the request if (packet.Properties.ContainsKey(OptionKeys.ExecutablePath)) { path = packet.Properties[OptionKeys.ExecutablePath]; } // Get the scene name var sceneNameArgument = packet.Properties.ContainsKey(OptionKeys.SceneName) ? string.Format("{0} {1} ", CommandLineArgs.Names.LoadScene, packet.Properties[OptionKeys.SceneName]) : ""; if (!string.IsNullOrEmpty(packet.OverrideExePath)) { path = packet.OverrideExePath; } // If spawn in batchmode was set and `DontSpawnInBatchmode` arg is not provided var spawnInBatchmode = controller.DefaultSpawnerSettings.SpawnInBatchmode && !CommandLineArgs.DontSpawnInBatchmode; var startProcessInfo = new ProcessStartInfo(path) { CreateNoWindow = false, UseShellExecute = false, Arguments = " " + (spawnInBatchmode ? "-batchmode -nographics " : "") + (controller.DefaultSpawnerSettings.AddWebGlFlag ? CommandLineArgs.Names.WebGl + " " : "") + sceneNameArgument + string.Format("{0} {1} ", CommandLineArgs.Names.MasterIp, masterIp) + string.Format("{0} {1} ", CommandLineArgs.Names.MasterPort, masterPort) + string.Format("{0} {1} ", CommandLineArgs.Names.SpawnId, packet.SpawnId) + string.Format("{0} {1} ", CommandLineArgs.Names.AssignedPort, port) + string.Format("{0} {1} ", CommandLineArgs.Names.MachineIp, machineIp) + (CommandLineArgs.DestroyUi ? CommandLineArgs.Names.DestroyUi + " " : "") + string.Format("{0} \"{1}\" ", CommandLineArgs.Names.SpawnCode, packet.SpawnCode) + packet.CustomArgs }; _logger.Debug("Starting process with args: " + startProcessInfo.Arguments); var processStarted = false; try { new Thread(() => { try { _logger.Debug("New thread started"); using (var process = Process.Start(startProcessInfo)) { _logger.Debug("Process started. Spawn Id: " + packet.SpawnId + ", pid: " + process.Id); processStarted = true; lock (_processLock) { // Save the process _processes[packet.SpawnId] = process; } var processId = process.Id; // Notify server that we've successfully handled the request AppTimer.ExecuteOnMainThread(() => { message.Respond(ResponseStatus.Success); controller.NotifyProcessStarted(packet.SpawnId, processId, startProcessInfo.Arguments); }); process.WaitForExit(); } } catch (Exception e) { if (!processStarted) { AppTimer.ExecuteOnMainThread(() => { message.Respond(ResponseStatus.Failed); }); } _logger.Error("An exception was thrown while starting a process. Make sure that you have set a correct build path. " + "We've tried to start a process at: '" + path + "'. You can change it at 'SpawnerBehaviour' component"); _logger.Error(e); } finally { lock (_processLock) { // Remove the process _processes.Remove(packet.SpawnId); } AppTimer.ExecuteOnMainThread(() => { // Release the port number _spawners.ReleasePort(port); _logger.Debug("Notifying about killed process with spawn id: " + packet.SpawnerId); controller.NotifyProcessKilled(packet.SpawnId); }); } }).Start(); } catch (Exception e) { message.Respond(e.Message, ResponseStatus.Error); Logs.Error(e); } }
private void ReadElement(XmlReader xmlReader) { switch (xmlReader.Name) { case ConstTagUser: ReadUser(xmlReader); break; case ConstTagProxy: ReadProxy(xmlReader); break; case ConstTagMap: ReadMap(xmlReader); break; case ConstTagCure: ReadCure(xmlReader); break; case ConstTagAutoAnswer: ReadAutoAnswer(xmlReader); break; case ConstTagFish: ReadFish(xmlReader); break; case ConstTagChat: ReadChat(xmlReader); break; case ConstTagLightForum: ReadForum(xmlReader); break; case ConstTagTorg: ReadTorg(xmlReader); break; case "window": Window.State = FormWindowState.Normal; var windowState = xmlReader["state"] ?? string.Empty; try { Window.State = (FormWindowState)Enum.Parse(typeof(FormWindowState), windowState); } catch (ArgumentException) { } Window.Left = (xmlReader["left"] == null) ? 0 : Convert.ToInt32(xmlReader["left"], CultureInfo.InvariantCulture); Window.Top = (xmlReader["top"] == null) ? 0 : Convert.ToInt32(xmlReader["top"], CultureInfo.InvariantCulture); Window.Width = (xmlReader["width"] == null) ? 0 : Convert.ToInt32(xmlReader["width"], CultureInfo.InvariantCulture); Window.Height = (xmlReader["height"] == null) ? 0 : Convert.ToInt32(xmlReader["height"], CultureInfo.InvariantCulture); break; case "stat": Stat.Drop = xmlReader["drop"] ?? string.Empty; Stat.LastReset = (xmlReader["lastreset"] == null) ? 0 : Convert.ToInt64(xmlReader["lastreset"]); Stat.LastUpdateDay = (xmlReader["lastupdateday"] == null) ? DateTime.Now.DayOfYear : Convert.ToInt32(xmlReader["lastupdateday"]); Stat.Reset = (xmlReader["reset"] != null) && Convert.ToBoolean(xmlReader["reset"]); Stat.SavedTraffic = (xmlReader["savedtraffic"] == null) ? 0 : Convert.ToInt64(xmlReader["savedtraffic"]); Stat.Show = (xmlReader["show"] == null) ? 0 : Convert.ToInt32(xmlReader["show"]); Stat.Traffic = (xmlReader["traffic"] == null) ? 0 : Convert.ToInt64(xmlReader["traffic"]); Stat.XP = (xmlReader["xp"] == null) ? 0 : Convert.ToInt64(xmlReader["xp"]); Stat.NV = (xmlReader["nv"] == null) ? 0 : Convert.ToInt32(xmlReader["nv"]); Stat.FishNV = (xmlReader["fishnv"] == null) ? 0 : Convert.ToInt32(xmlReader["fishnv"]); break; case "itemdrop": var itemdrop = new TypeItemDrop { Name = xmlReader["name"] ?? string.Empty, Count = (xmlReader["count"] == null) ? 1 : Convert.ToInt32(xmlReader["count"]) }; Stat.ItemDrop.Add(itemdrop); break; case "splitter": Splitter.Collapsed = (xmlReader["collapsed"] != null) && Convert.ToBoolean(xmlReader["collapsed"], CultureInfo.InvariantCulture); Splitter.Width = (xmlReader["width"] == null) ? 200 : Convert.ToInt32(xmlReader["width"], CultureInfo.InvariantCulture); break; case "inv": DoInvPack = (xmlReader["doInvPack"] == null) || Convert.ToBoolean(xmlReader["doInvPack"]); DoInvPackDolg = (xmlReader["doInvPackDolg"] == null) || Convert.ToBoolean(xmlReader["doInvPackDolg"]); DoInvSort = (xmlReader["doInvSort"] == null) || Convert.ToBoolean(xmlReader["doInvSort"]); break; case "dopromptexit": xmlReader.Read(); DoPromptExit = xmlReader.ReadContentAsBoolean(); break; case "dostopondig": xmlReader.Read(); DoStopOnDig = xmlReader.ReadContentAsBoolean(); break; case "dohttplog": xmlReader.Read(); DoHttpLog = xmlReader.ReadContentAsBoolean(); break; case "dotexlog": xmlReader.Read(); DoTexLog = xmlReader.ReadContentAsBoolean(); break; case "doautocutwritechat": xmlReader.Read(); DoAutoCutWriteChat = xmlReader.ReadContentAsBoolean(); break; case "showperformance": xmlReader.Read(); ShowPerformance = xmlReader.ReadContentAsBoolean(); break; case "showoverwarning": xmlReader.Read(); ShowOverWarning = xmlReader.ReadContentAsBoolean(); break; case "selectedrightpanel": xmlReader.Read(); SelectedRightPanel = xmlReader.ReadContentAsInt(); break; case "notepad": xmlReader.Read(); Notepad = HelperPacks.UnpackString(xmlReader.ReadContentAsString()); break; case "nextcheckversion": xmlReader.Read(); var binaryNextCheckVersion = xmlReader.ReadContentAsLong(); NextCheckVersion = DateTime.FromBinary(binaryNextCheckVersion); break; case "tab": xmlReader.Read(); _listtabs.Add(xmlReader.ReadContentAsString()); break; case "favlocation": xmlReader.Read(); _listfavlocations.Add(xmlReader.ReadContentAsString()); break; case "herbautocut": xmlReader.Read(); HerbsAutoCut.Add(xmlReader.ReadContentAsString()); break; case "complects": xmlReader.Read(); Complects = xmlReader.ReadContentAsString(); break; case "dotray": xmlReader.Read(); DoTray = xmlReader.ReadContentAsBoolean(); break; case "showtraybaloons": xmlReader.Read(); ShowTrayBaloons = xmlReader.ReadContentAsBoolean(); break; /* * case "servdiff": * xmlReader.Read(); * var servdiff = xmlReader.ReadContentAsString(); * TimeSpan val; * if (!TimeSpan.TryParse(servdiff, out val)) * { * val = TimeSpan.MinValue; * } * * ServDiff = val; * break; */ case "doconvertrussian": xmlReader.Read(); DoConvertRussian = xmlReader.ReadContentAsBoolean(); break; case "apptimer": var appTimer = new AppTimer(); var triggertime = xmlReader["triggertime"]; if (triggertime != null) { long binary; if (long.TryParse(triggertime, out binary)) { appTimer.TriggerTime = DateTime.FromBinary(binary); } } appTimer.Description = xmlReader["description"] ?? string.Empty; appTimer.Complect = xmlReader["complect"] ?? string.Empty; appTimer.Potion = xmlReader["potion"] ?? string.Empty; var xmldrinkcount = xmlReader["drinkcount"]; if (xmldrinkcount != null) { int drinkcount; if (int.TryParse(xmldrinkcount, out drinkcount)) { appTimer.DrinkCount = drinkcount; } } var xmlisrecur = xmlReader["isrecur"]; if (xmlisrecur != null) { bool isrecur; if (bool.TryParse(xmlisrecur, out isrecur)) { appTimer.IsRecur = isrecur; } } var xmlisherb = xmlReader["isherb"]; if (xmlisherb != null) { bool isherb; if (bool.TryParse(xmlisherb, out isherb)) { appTimer.IsHerb = isherb; } } var xmleveryminutes = xmlReader["everyminutes"]; if (xmleveryminutes != null) { int everyMinutes; if (int.TryParse(xmleveryminutes, out everyMinutes)) { appTimer.EveryMinutes = everyMinutes; } } appTimer.Destination = xmlReader["destination"] ?? string.Empty; AppConfigTimers.Add(appTimer); break; case "pers": Pers.Guamod = (xmlReader["guamod"] == null) || Convert.ToBoolean(xmlReader["guamod"], CultureInfo.InvariantCulture); Pers.IntHP = (xmlReader["inthp"] != null) ? Convert.ToDouble(xmlReader["inthp"], CultureInfo.InvariantCulture) : 2000; Pers.IntMA = (xmlReader["intma"] != null) ? Convert.ToDouble(xmlReader["intma"], CultureInfo.InvariantCulture) : 9000; Pers.Ready = (xmlReader["ready"] != null) ? Convert.ToInt64(xmlReader["ready"], CultureInfo.InvariantCulture) : 0; Pers.LogReady = xmlReader["logready"] ?? string.Empty; break; case "navigator": Navigator.AllowTeleports = (xmlReader["allowteleports"] == null) || Convert.ToBoolean(xmlReader["allowteleports"], CultureInfo.InvariantCulture); break; case "contactentry": var strclassid = xmlReader["classid"] ?? string.Empty; int classid; if (!int.TryParse(strclassid, out classid)) { classid = 0; } var strtoolid = xmlReader["toolid"] ?? string.Empty; int toolid; if (!int.TryParse(strtoolid, out toolid)) { toolid = 0; } var contact = new Contact( xmlReader["name"] ?? string.Empty, classid, toolid, xmlReader["sign"] ?? string.Empty, xmlReader["clan"] ?? string.Empty, xmlReader["align"] ?? string.Empty, HelperPacks.UnpackString(xmlReader["comments"] ?? string.Empty), xmlReader["tracing"] == null || Convert.ToBoolean(xmlReader["tracing"], CultureInfo.InvariantCulture), xmlReader["level"] ?? string.Empty, true); if (Contacts == null) { Contacts = new SortedList <string, Contact>(); } if (!Contacts.ContainsKey(contact.Name.ToLower())) { Contacts.Add(contact.Name.ToLower(), contact); } break; case "herbcell": var herbCell = new HerbCell(); var location = xmlReader["location"] ?? string.Empty; if (!string.IsNullOrEmpty(location)) { herbCell.RegNum = location; var herbs = xmlReader["herbs"] ?? string.Empty; if (!string.IsNullOrEmpty(location)) { herbCell.Herbs = herbs; } var lastViewString = xmlReader["lastview"] ?? string.Empty; if (!string.IsNullOrEmpty(location)) { long updatedInTicks; if (long.TryParse(lastViewString, out updatedInTicks)) { if ((ServDiff != TimeSpan.MinValue) && (updatedInTicks < DateTime.Now.Subtract(ServDiff).Ticks)) { herbCell.UpdatedInTicks = updatedInTicks; var timediff = TimeSpan.FromTicks(DateTime.Now.Subtract(ServDiff).Ticks - updatedInTicks); if (timediff.TotalHours < 6) { if (!HerbCells.ContainsKey(location)) { HerbCells.Add(location, herbCell); } } } } } } break; case "dorob": xmlReader.Read(); DoRob = xmlReader.ReadContentAsBoolean(); break; case "doautocure": xmlReader.Read(); DoAutoCure = xmlReader.ReadContentAsBoolean(); break; case "autowearcomplect": xmlReader.Read(); AutoWearComplect = xmlReader.ReadContentAsString(); break; case "sound": Sound.Enabled = (xmlReader["enabled"] == null) || Convert.ToBoolean(xmlReader["enabled"], CultureInfo.InvariantCulture); Sound.DoPlayAlarm = (xmlReader["alarm"] == null) || Convert.ToBoolean(xmlReader["alarm"], CultureInfo.InvariantCulture); Sound.DoPlayAttack = (xmlReader["attack"] == null) || Convert.ToBoolean(xmlReader["attack"], CultureInfo.InvariantCulture); Sound.DoPlayDigits = (xmlReader["digits"] == null) || Convert.ToBoolean(xmlReader["digits"], CultureInfo.InvariantCulture); Sound.DoPlayRefresh = (xmlReader["refresh"] == null) || Convert.ToBoolean(xmlReader["refresh"], CultureInfo.InvariantCulture); Sound.DoPlaySndMsg = (xmlReader["sndmsg"] == null) || Convert.ToBoolean(xmlReader["sndmsg"], CultureInfo.InvariantCulture); Sound.DoPlayTimer = (xmlReader["timer"] == null) || Convert.ToBoolean(xmlReader["timer"], CultureInfo.InvariantCulture); break; case "autoadv": AutoAdv.Sec = (xmlReader["sec"] != null) ? Convert.ToInt32(xmlReader["sec"], CultureInfo.InvariantCulture) : 600; AutoAdv.Phraz = HelperPacks.UnpackString(xmlReader["phraz"] ?? string.Empty); break; case "autodrinkblaz": DoAutoDrinkBlaz = (xmlReader["do"] != null) && Convert.ToBoolean(xmlReader["do"], CultureInfo.InvariantCulture); AutoDrinkBlazTied = (xmlReader["tied"] != null) ? Convert.ToInt32(xmlReader["tied"], CultureInfo.InvariantCulture) : 84; break; case "autodrinkblazorder": xmlReader.Read(); AutoDrinkBlazOrder = xmlReader.ReadContentAsInt(); if ((AutoDrinkBlazOrder < 0) || (AutoDrinkBlazOrder > 1)) { AutoDrinkBlazOrder = 0; } break; case "fastactions": DoShowFastAttack = (xmlReader["simple"] != null) && Convert.ToBoolean(xmlReader["simple"], CultureInfo.InvariantCulture); DoShowFastAttackBlood = (xmlReader["blood"] == null) || Convert.ToBoolean(xmlReader["blood"], CultureInfo.InvariantCulture); DoShowFastAttackUltimate = (xmlReader["ultimate"] == null) || Convert.ToBoolean(xmlReader["ultimate"], CultureInfo.InvariantCulture); DoShowFastAttackClosedUltimate = (xmlReader["closedultimate"] == null) || Convert.ToBoolean(xmlReader["closedultimate"], CultureInfo.InvariantCulture); DoShowFastAttackClosed = (xmlReader["closed"] == null) || Convert.ToBoolean(xmlReader["closed"], CultureInfo.InvariantCulture); DoShowFastAttackFist = (xmlReader["fist"] != null) && Convert.ToBoolean(xmlReader["fist"], CultureInfo.InvariantCulture); DoShowFastAttackClosedFist = (xmlReader["closedfist"] == null) || Convert.ToBoolean(xmlReader["closedfist"], CultureInfo.InvariantCulture); DoShowFastAttackOpenNevid = (xmlReader["opennevid"] == null) || Convert.ToBoolean(xmlReader["opennevid"], CultureInfo.InvariantCulture); DoShowFastAttackPoison = (xmlReader["poison"] == null) || Convert.ToBoolean(xmlReader["poison"], CultureInfo.InvariantCulture); DoShowFastAttackStrong = (xmlReader["strong"] == null) || Convert.ToBoolean(xmlReader["strong"], CultureInfo.InvariantCulture); DoShowFastAttackNevid = (xmlReader["nevid"] == null) || Convert.ToBoolean(xmlReader["nevid"], CultureInfo.InvariantCulture); DoShowFastAttackFog = (xmlReader["fog"] == null) || Convert.ToBoolean(xmlReader["fog"], CultureInfo.InvariantCulture); DoShowFastAttackZas = (xmlReader["zas"] == null) || Convert.ToBoolean(xmlReader["zas"], CultureInfo.InvariantCulture); DoShowFastAttackTotem = (xmlReader["totem"] == null) || Convert.ToBoolean(xmlReader["totem"], CultureInfo.InvariantCulture); DoShowFastAttackPortal = (xmlReader["portal"] == null) || Convert.ToBoolean(xmlReader["portal"], CultureInfo.InvariantCulture); break; case AppConsts.TagLezDoAutoboi: xmlReader.Read(); LezDoAutoboi = xmlReader.ReadContentAsBoolean(); break; case AppConsts.TagLezDoWaitHp: xmlReader.Read(); LezDoWaitHp = xmlReader.ReadContentAsBoolean(); break; case AppConsts.TagLezDoWaitMa: xmlReader.Read(); LezDoWaitMa = xmlReader.ReadContentAsBoolean(); break; case AppConsts.TagLezWaitHp: xmlReader.Read(); LezWaitHp = xmlReader.ReadContentAsInt(); break; case AppConsts.TagLezWaitMa: xmlReader.Read(); LezWaitMa = xmlReader.ReadContentAsInt(); break; case AppConsts.TagLezDoDrinkHp: xmlReader.Read(); LezDoDrinkHp = xmlReader.ReadContentAsBoolean(); break; case AppConsts.TagLezDoDrinkMa: xmlReader.Read(); LezDoDrinkMa = xmlReader.ReadContentAsBoolean(); break; case AppConsts.TagLezDrinkHp: xmlReader.Read(); LezDrinkHp = xmlReader.ReadContentAsInt(); break; case AppConsts.TagLezDrinkMa: xmlReader.Read(); LezDrinkMa = xmlReader.ReadContentAsInt(); break; case AppConsts.TagLezDoWinTimeout: xmlReader.Read(); LezDoWinTimeout = xmlReader.ReadContentAsBoolean(); break; case AppConsts.TagLezSay: xmlReader.Read(); LezSay = (LezSayType)Enum.Parse(typeof(LezSayType), xmlReader.ReadContentAsString()); break; case AppConsts.TagLezBotsGroup: var group = new LezBotsGroup(001, 0); int.TryParse(xmlReader[AppConsts.AttrLezBotsGroupId] ?? "0", out group.Id); int.TryParse(xmlReader[AppConsts.AttrLezBotsMinimalLevelId] ?? "0", out group.MinimalLevel); bool.TryParse(xmlReader[AppConsts.AttrLezBotsDoRestoreHp] ?? "true", out group.DoRestoreHp); bool.TryParse(xmlReader[AppConsts.AttrLezBotsDoRestoreMa] ?? "true", out group.DoRestoreMa); int.TryParse(xmlReader[AppConsts.AttrLezBotsRestoreHp] ?? "50", out group.RestoreHp); int.TryParse(xmlReader[AppConsts.AttrLezBotsRestoreMa] ?? "50", out group.RestoreMa); bool.TryParse(xmlReader[AppConsts.AttrLezBotsDoAbilBlocks] ?? "true", out group.DoAbilBlocks); bool.TryParse(xmlReader[AppConsts.AttrLezBotsDoAbilHits] ?? "true", out group.DoAbilHits); bool.TryParse(xmlReader[AppConsts.AttrLezBotsDoMagHits] ?? "true", out group.DoMagHits); int.TryParse(xmlReader[AppConsts.AttrLezBotsMagHits] ?? "5", out group.MagHits); bool.TryParse(xmlReader[AppConsts.AttrLezBotsDoMagBlocks] ?? "false", out group.DoMagBlocks); bool.TryParse(xmlReader[AppConsts.AttrLezBotsDoHits] ?? "true", out group.DoHits); bool.TryParse(xmlReader[AppConsts.AttrLezBotsDoBlocks] ?? "true", out group.DoBlocks); bool.TryParse(xmlReader[AppConsts.AttrLezBotsDoMiscAbils] ?? "true", out group.DoMiscAbils); group.SpellsHits = LezSpellCollection.SpellsFromString(xmlReader[AppConsts.AttrLezBotsSpellsHits] ?? ""); group.SpellsBlocks = LezSpellCollection.SpellsFromString(xmlReader[AppConsts.AttrLezBotsSpellsBlocks] ?? ""); group.SpellsRestoreHp = LezSpellCollection.SpellsFromString(xmlReader[AppConsts.AttrLezBotsSpellsRestoreHp] ?? ""); group.SpellsRestoreMa = LezSpellCollection.SpellsFromString(xmlReader[AppConsts.AttrLezBotsSpellsRestoreMa] ?? ""); group.SpellsMisc = LezSpellCollection.SpellsFromString(xmlReader[AppConsts.AttrLezBotsSpellsMisc] ?? ""); if (group.SpellsHits.Length == 0) { group.SpellsHits = LezSpellCollection.Hits; } if (group.SpellsBlocks.Length == 0) { group.SpellsBlocks = LezSpellCollection.Blocks; } if (group.SpellsRestoreHp.Length == 0) { group.SpellsRestoreHp = LezSpellCollection.RestoreHp; } if (group.SpellsRestoreMa.Length == 0) { group.SpellsRestoreMa = LezSpellCollection.RestoreMa; } if (group.SpellsMisc.Length == 0) { group.SpellsMisc = LezSpellCollection.Misc; } bool.TryParse(xmlReader[AppConsts.AttrLezBotsDoStopNow] ?? "false", out group.DoStopNow); bool.TryParse(xmlReader[AppConsts.AttrLezBotsDoStopLowHp] ?? "false", out group.DoStopLowHp); bool.TryParse(xmlReader[AppConsts.AttrLezBotsDoStopLowMa] ?? "false", out group.DoStopLowMa); int.TryParse(xmlReader[AppConsts.AttrLezBotsStopLowHp] ?? "25", out group.StopLowHp); int.TryParse(xmlReader[AppConsts.AttrLezBotsStopLowMa] ?? "25", out group.StopLowMa); bool.TryParse(xmlReader[AppConsts.AttrLezBotsDoExit] ?? "false", out group.DoExit); bool.TryParse(xmlReader[AppConsts.AttrLezBotsDoExitRisky] ?? "true", out group.DoExitRisky); LezGroups.Add(group); break; case AppConsts.TagDoContactTrace: xmlReader.Read(); DoContactTrace = xmlReader.ReadContentAsBoolean(); break; case AppConsts.TagDoBossTrace: xmlReader.Read(); DoBossTrace = xmlReader.ReadContentAsBoolean(); break; case AppConsts.TagBossSay: xmlReader.Read(); BossSay = (LezSayType)Enum.Parse(typeof(LezSayType), xmlReader.ReadContentAsString()); break; case AppConsts.TagSkinAuto: xmlReader.Read(); SkinAuto = xmlReader.ReadContentAsBoolean(); break; } }