public void TestSaveSingleLine() { string[] PreppedDOD = DOD.Prep(DOD.Parse(DOD2)); for (int i = 0; i < DOD2.Length; i++) { Assert.AreEqual(DOD2[i], PreppedDOD[i]); } }
public void TestMultiKey() { Dictionary <string, string> Dict2 = DOD.Parse(DOD2); Assert.AreEqual("Probably not", Dict2["Coincidence"]); Assert.AreEqual("Maybe", Dict2["Mystery"]); Assert.AreEqual("Trivago", Dict2["Hotel"]); }
private void selected_button_Click(object sender, EventArgs e) //снятие выделение со строки в dgv о очищение tb { button_off(); foreach (DataGridViewRow row in Data_Person.SelectedRows) { row.Selected = false; } LN.Clear(); N.Clear(); MN.Clear(); DOB.Clear(); Act.Checked = false; Pasp.Clear(); DOE.Clear(); pos.Clear(); DOD.Clear(); Reas.Clear(); }
public void TestMultiLineKey() { Dictionary <string, string> Dict3 = DOD.Parse(DOD3); Assert.AreEqual("Chopo", Dict3["Name"]); Assert.AreEqual("Existence\nLife\nCoding", Dict3["Experience"]); Assert.AreEqual("Beans", Dict3["Cool"]); Assert.AreEqual("No Fighting\nNo Running", Dict3["Rules"]); Assert.AreEqual("boop", Dict3["beep"]); }
public void TestSaveAndLoad() { Dictionary <string, string> PreSave = DOD.Parse(DOD3); DOD.Save(PreSave, "TestFile.DOD"); Dictionary <string, string> PostSave = DOD.Load("TestFile.DOD"); foreach (string Key in PreSave.Keys) { Assert.AreEqual(PreSave[Key], PostSave[Key]); } }
public void TestSaveMultiLine() { string[] PreppedDOD = DOD.Prep(DOD.Parse(DOD3)); //DOD.PREP has \n. In order for this simulation to go through, it must be written. PreppedDOD = string.Join("\n", PreppedDOD).Split('\n'); for (int i = 0; i < DOD3.Length; i++) { Assert.AreEqual(DOD3[i], PreppedDOD[i]); } }
//-[Methods]------------------------------------------------------------------------------------------------------------------------------------------ /// <summary>saves the UserTrace to a directory</summary> /// <param name="ProjectDir"></param> public void SaveTrace(string ProjectDir) { if (rootuser is null) { throw new InvalidOperationException("Root user is not defined!"); } if (!Directory.Exists(ProjectDir)) { Directory.CreateDirectory(ProjectDir); } if (!Directory.Exists(ProjectDir + "/images")) { Directory.CreateDirectory(ProjectDir + "/images"); } Dictionary <string, string> ProjectDOD = new Dictionary <string, string> { { "name", ServerName }, { "date", string.Join("-", ServerCreationDate.Year, ServerCreationDate.Month, ServerCreationDate.Day) }, { "root", RootUser.Name } }; DOD.Save(ProjectDOD, ProjectDir + "/" + "Project.UTrace"); if (File.Exists(ProjectDir + "/" + "Logo.png")) { File.Delete(ProjectDir + "/" + "Logo.png"); } ServerLogo.Save(ProjectDir + "/" + "Logo.png", System.Drawing.Imaging.ImageFormat.Png); if (File.Exists(ProjectDir + "/" + "TileBG.png")) { File.Delete(ProjectDir + "/" + "TileBG.png"); } TileBackground.Save(ProjectDir + "/" + "TileBG.png", System.Drawing.Imaging.ImageFormat.Png); //now to save the users: Dictionary <string, string> UsersDOD = new Dictionary <string, string>(); foreach (User user in AllUsers) { //Add the user to the DOD UsersDOD.Add(user.Name, user.GenerateUserString()); //Save their image if (File.Exists(ProjectDir + "/images/" + user.Name + ".png")) { File.Delete(ProjectDir + "/images/" + user.Name + ".png"); } user.PFP.Save(ProjectDir + "/images/" + user.Name + ".png", System.Drawing.Imaging.ImageFormat.Png); } //Save the DOD DOD.Save(UsersDOD, ProjectDir + "/" + "Users.DOD"); }
public void NullValues() { Dictionary <string, string> D = new Dictionary <string, string> { { "C", "C" }, { "D", null }, { "E", "E" } }; DOD.Save(D, "TestFile.DOD"); Dictionary <string, string> E = DOD.Load("TestFile.DOD"); Assert.AreEqual("C", E["C"]); Assert.IsTrue(string.IsNullOrEmpty(E["D"])); Assert.AreEqual("E", E["E"]); }
public static void Save() { Dictionary <string, string> SaveDict = new Dictionary <string, string> { { "FONT", FontDir }, { "BG", BasicFont.ConsoleColorToColorChar(MainClock.BG) + "" }, { "FG", BasicFont.ConsoleColorToColorChar(MainClock.FG) + "" }, { "MILITTIME", MainClock.MilitaryTime.ToString() }, { "SHOWDATE", MainClock.ShowDate.ToString() }, { "SHOWSECONDS", MainClock.ShowSeconds.ToString() }, { "ADJUSTHOURS", MainClock.HourAdjust.ToString() }, { "AUDIO", Audio.ToString() }, { "VOICE", Voice.ToString() }, { "COLLAPSED", Collapsed.ToString() } }; DOD.Save(SaveDict, dir); }
public static Clock LoadClock() { if (!File.Exists(dir)) { return(DefaultClock()); } Dictionary <String, String> LoadDict = DOD.Load(dir); try { Clock ReturnClock; if (string.IsNullOrWhiteSpace(FontDir)) { FontDir = LoadDict["FONT"]; } if (!string.IsNullOrWhiteSpace(FontDir)) { ReturnClock = new Clock(BasicFont.LoadFromFile(FontDir), 2, 1); } else { ReturnClock = new Clock(2, 1); } ReturnClock.BG = GraphicUtils.ColorCharToConsoleColor(LoadDict["BG"][0]); ReturnClock.FG = GraphicUtils.ColorCharToConsoleColor(LoadDict["FG"][0]); ReturnClock.MilitaryTime = Boolean.Parse(LoadDict["MILITTIME"]); ReturnClock.ShowDate = Boolean.Parse(LoadDict["SHOWDATE"]); ReturnClock.ShowSeconds = Boolean.Parse(LoadDict["SHOWSECONDS"]); ReturnClock.HourAdjust = int.Parse(LoadDict["ADJUSTHOURS"]); Audio = Boolean.Parse(LoadDict["AUDIO"]); Voice = Boolean.Parse(LoadDict["VOICE"]); Collapsed = Boolean.Parse(LoadDict["COLLAPSED"]); return(ReturnClock); } catch (Exception) { Draw.CenterText("There was an error loading file " + dir.Split('\\')[dir.Split('\\').Length - 1], Console.WindowHeight / 2, ConsoleColor.Red, ConsoleColor.Black); RenderUtils.Pause(); Draw.ClearLine(Console.WindowHeight / 2); return(DefaultClock()); } }
/// <summary>Loads a UserTrace from a directory.</summary> /// <param name="ProjectDir"></param> public Trace(string ProjectDir) { if (!Directory.Exists(ProjectDir) || !File.Exists(ProjectDir + "/" + "Project.UTrace") || !File.Exists(ProjectDir + "/" + "Users.DOD") || !Directory.Exists(ProjectDir + "/" + "Images") ) { throw new ArgumentException(ProjectDir + " does not contain a project"); } //Load the Project DOD Dictionary <string, string> ProjectDOD = DOD.Load(ProjectDir + "/" + "Project.UTrace"); //Load the Tile IMG and the Server Logo if (File.Exists(ProjectDir + "/TileBG.png")) { TileBackground = SafeLoadImage(ProjectDir + "/TileBG.png"); } if (File.Exists(ProjectDir + "/Logo.png")) { ServerLogo = SafeLoadImage(ProjectDir + "/Logo.png"); } //Load the server name and server start date ServerName = ProjectDOD["name"]; string[] DateTemp = ProjectDOD["date"].Split('-'); ServerCreationDate = new DateTime(int.Parse(DateTemp[0]), int.Parse(DateTemp[1]), int.Parse(DateTemp[2])); //Now load the users!!! Dictionary <string, string> UsersDOD = DOD.Load(ProjectDir + "/" + "Users.DOD"); //now we're going to load the root user RootUser = new User(UsersDOD[ProjectDOD["root"]], ProjectDir); //Now time to link the users LinkUsers(ref rootuser, ref UsersDOD, ProjectDir); //now let's add all the users AllUsers = rootuser.GetAllSubUsers(); //and that's it. }
//-[Internal Functions]------------------------------------------------------------------------------------------------ /// <summary>Loads a font from a filename</summary> /// <param name="Filename"></param> private void LoadFont(String Filename) { if (!File.Exists(Filename)) { MessageBox.Show("File Does not exist!", "BasicFont Editor", MessageBoxButtons.OK, MessageBoxIcon.Error); } FontBeingBuilt = DOD.Load(Filename); if (!FontBeingBuilt.ContainsKey("Name") | !FontBeingBuilt.ContainsKey("Author") | !FontBeingBuilt.ContainsKey("CharWidth") | !FontBeingBuilt.ContainsKey("CharHeight")) { MessageBox.Show("Provided font file is corrupt. It's missing certain details."); FontBeingBuilt = null; } NameBox.Text = FontBeingBuilt["Name"]; AuthorBox.Text = FontBeingBuilt["Author"]; this.Filename = Filename; LoadCharacters(""); MainTableLayout.Enabled = true; }
/// <summary>Handles the DictionaryOnDisk call to save the font to disk</summary> public void SaveFont() { DOD.Save(FontBeingBuilt, Filename); }
public void TestSingleKey() { Dictionary <string, string> Dict1 = DOD.Parse(DOD1); Assert.AreEqual("bar", Dict1["foo"]); }
/// <summary>Creates a BasicFont from a resource</summary> /// <param name="Resource"></param> /// <returns></returns> public static BasicFont LoadFromResource(Byte[] Resource) { return(new BasicFont(DOD.Parse(GraphicUtils.ResourceToStringArray(Resource)))); }
//-[Static methods]--------------------------------------------------------------------- /// <summary>Creates a BasicFont from a file</summary> /// <param name="Filename"></param> /// <returns></returns> public static BasicFont LoadFromFile(string Filename) { return(new BasicFont(DOD.Load(Filename))); }