Esempio n. 1
0
        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]);
            }
        }
Esempio n. 2
0
        //-[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");
        }
Esempio n. 3
0
        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"]);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
 /// <summary>Handles the DictionaryOnDisk call to save the font to disk</summary>
 public void SaveFont()
 {
     DOD.Save(FontBeingBuilt, Filename);
 }