public void Save(ClickerSettings ClickerSettings) { XMLhelper XML = new XMLhelper(UserSettings); XML.XMLWriteFile(xmlRootCLICKERLocation, DirectoryKey, ClickerSettings.Directory); XML.XMLWriteFile(xmlRootCLICKERLocation, ExportKey, ClickerSettings.Export.ToString(CultureInfo.CurrentCulture)); XML.XMLWriteFile(xmlRootCLICKERLocation, UnderscoreKey, ClickerSettings.Underscore.ToString(CultureInfo.CurrentCulture)); XML.XMLWriteFile(xmlRootCLICKERLocation, SelectedOutputkey, ClickerSettings.SelectedValue.ToString(CultureInfo.CurrentCulture)); }
public ClickerSettings Load() { ClickerSettings ClickerSettings = new ClickerSettings(); XMLhelper XML = new XMLhelper(UserSettings); ClickerSettings.Directory = XML.XMLReadFile(xmlRootCLICKERLocation, DirectoryKey); if (ClickerSettings.Directory == "") { ClickerSettings.Directory = DefaultDirectory; XML.XMLWriteFile(xmlRootCLICKERLocation, DirectoryKey, ClickerSettings.Directory); } try { ClickerSettings.Export = Convert.ToBoolean(XML.XMLReadFile(xmlRootCLICKERLocation, ExportKey).ToLower()); } catch { ClickerSettings.Export = false; XML.XMLWriteFile(xmlRootCLICKERLocation, ExportKey, ClickerSettings.Export.ToString(CultureInfo.CurrentCulture)); } try { ClickerSettings.Underscore = Convert.ToBoolean(XML.XMLReadFile(xmlRootCLICKERLocation, UnderscoreKey).ToLower()); } catch { ClickerSettings.Underscore = true; XML.XMLWriteFile(xmlRootCLICKERLocation, UnderscoreKey, ClickerSettings.Underscore.ToString(CultureInfo.CurrentCulture)); } try { ClickerSettings.SelectedValue = Convert.ToInt32(XML.XMLReadFile(xmlRootCLICKERLocation, SelectedOutputkey)); } catch { ClickerSettings.SelectedValue = SelectedOutputDefault; XML.XMLWriteFile(xmlRootCLICKERLocation, SelectedOutputkey, ClickerSettings.SelectedValue.ToString(CultureInfo.CurrentCulture)); } return(ClickerSettings); }
private static void KeyboardListener2_KeyPressed(KeyboardWatcher.KeyExt obj) { if (obj == _settings.ClickerHotkey) { if (_settings.ClickerKey == Keys.None) { Notify.TrayPopup("Incorrect parameter!", "Clicker don't know what key it should press. Click here to setup clicker", NotifyUserType.Error, true, null, 10, (sender, args) => { ClickerSettings clickerSettings = Utils.FindForms <ClickerSettings>().FirstOrDefault(); if (clickerSettings == null) { new ClickerSettings().Show(MainWindow.Instance); } else { clickerSettings.ActivateBrutal(); } }); return; } if (Enabled) { Stop(); WowProcess cProcess = WoWProcessManager.Processes.Values.FirstOrDefault(i => i.MainWindowHandle == Handle); logger.Info(cProcess != null ? $"{cProcess} Disabled" : "UNKNOWN:null :: Disabled"); } else { WowProcess cProcess = WoWProcessManager.Processes.Values.FirstOrDefault(i => i.MainWindowHandle == NativeMethods.GetForegroundWindow()); if (cProcess != null) { Start(_settings.ClickerInterval, cProcess.MainWindowHandle, (IntPtr)_settings.ClickerKey); logger.Info($"{cProcess} Enabled, interval {_settings.ClickerInterval}ms, window handle 0x{cProcess.MainWindowHandle.ToInt64():X}"); } } } }
public void Export(ClickerSettings ClickerSettings, UserSettings UserSettings, Courses myCourses) { //========================================================== // // IN: UserInfo - user specific Options // myCourses - contains the courses to export // // Returns: Nothing - Events are raised to send status messages // // DESCRIPTION // This procedure exports to an Clicker output file //========================================================== bool DeleteFileError; // Verify that MTG is to be exported if (!ClickerSettings.Export) { return; } // Create Directory if it does not exist if (!Directory.Exists(ClickerSettings.Directory)) { Directory.CreateDirectory(ClickerSettings.Directory); } try { foreach (Course C in myCourses) { StringBuilder SB = new StringBuilder(2880); // 72 character per student * 40 students if (C.Export) { // Export to clicker output format // Index, Last,First,UniqueID (Made up of last name first initial and ID int StudentCount = C.Students.Length; // this is a 1 dimensional array for (int i = 0; i < StudentCount; i++) { if (ClickerSettings.SelectedValue == 1) { SB.Append((i + 1).ToString(CultureInfo.CurrentCulture)).Append(". "); Student S = C.Students[i]; SB.Append(S.LastName + ","); // Student Last Name SB.Append(S.FirstName + ","); // Student First Name SB.Append(S.LastName).Append(S.FirstName[0]).Append((i + 1).ToString(CultureInfo.CurrentCulture)); // UniqueID } else if (ClickerSettings.SelectedValue == 2) { // need to define the format SB.Append((i + 1).ToString(CultureInfo.CurrentCulture)).Append(". "); Student S = C.Students[i]; SB.Append(S.LastName + ","); // Student Last Name SB.Append(S.FirstName + ","); // Student First Name SB.Append(S.LastName).Append(S.FirstName[0]).Append((i + 1).ToString(CultureInfo.CurrentCulture)); // UniqueID } if (i < StudentCount) { SB.Append("\r\n"); } } if (ClickerSettings.ExportWaitlist) { // Export to clicker output format // Index, Last,First,UniqueID (Made up of last name first initial and ID int WaitlistCount = C.Waitlist.Length; // this is a 1 dimensional array for (int i = 0; i < WaitlistCount; i++) { int j = i + StudentCount; Student S = C.Waitlist[i]; if (ClickerSettings.SelectedValue == 1) { SB.Append((j + 1).ToString(CultureInfo.CurrentCulture)).Append(". "); SB.Append(S.LastName + ","); // Student Last Name SB.Append(S.FirstName + ","); // Student First Name SB.Append(S.LastName).Append(S.FirstName[0]).Append((j + 1).ToString(CultureInfo.CurrentCulture)); // UniqueID } else if (ClickerSettings.SelectedValue == 2) { // need to define the format SB.Append((j + 1).ToString(CultureInfo.CurrentCulture)).Append(". "); SB.Append(S.LastName + ","); // Student Last Name SB.Append(S.FirstName + ","); // Student First Name SB.Append(S.LastName).Append(S.FirstName[0]).Append((j + 1).ToString(CultureInfo.CurrentCulture)); // UniqueID } if (i < WaitlistCount) { SB.Append("\r\n"); } } } string DiskNames = C.DiskName(ClickerSettings.Underscore) + "_Roster.txt"; FileInformation FE = new FileInformation("The file " + DiskNames + " already exists.", ClickerSettings.Directory, DiskNames); DeleteFileError = false; // check to see if file exists SendMessage(this, new Information("Preparing " + DiskNames + ".")); if (File.Exists(FE.OldFileNameandPath)) { SendMessage(this, new Information("File already exists.")); if (UserSettings.OverWriteAll) { try { SendMessage(this, new Information("Attempting to replace.")); File.Delete(FE.OldFileNameandPath); } catch { DeleteFileError = true; } } else { FileExistsMessage(this, FE); UserSettings.OverWriteAll = FE.OverWriteAll; if (FE.CancelALLExport) { SendMessage(this, new Information("Canceling Clicker export.")); return; } if ((!FE.CancelExport) && (FE.OldFileNameandPath == FE.NewFileNameandPath)) { try { File.Delete(FE.OldFileNameandPath); } catch { DeleteFileError = true; } } } } if (FE.CancelExport) { SendMessage(this, new Information("User Canceled export for file.")); } else if (DeleteFileError) { SendMessage(this, new Information("Unable to delete file!")); } else { try { SendMessage(this, new Information("Writing file to disk.")); File.WriteAllText(FE.NewFileNameandPath, SB.ToString()); } catch (Exception Ex) { SendMessage(this, new Information("While trying to write " + FE.OldFileNameandPath + "An error occurred.\r\n" + Ex.Message)); } } } } } catch (Exception Ex) { SendMessage(this, new Information("An unexpected error occurred - " + Ex.Message)); throw; } }