/// <summary> /// Text message: UserId, UserMessage, MessageType /// Event : EventKey, WXEvent, MessageType /// </summary> /// <param name="uId"></param> /// <param name="uMsg"></param> /// <param name="msgType"></param> public MessageService(string uId, string uMsg, string msgType) { toFile = new ToFile(); switch (msgType) { case "text": userId = uId; msg = uMsg.ToLower(); if (msg.Length > 0) { Parameters = new List <string>(); InitParameters(); vc = new ValidCheck(uId, Parameters); cg = new category(Parameters); } break; case "event": toFile.WriteTxt("Write data to event"); msg = uMsg.ToLower(); break; } }
public static UserDifficulty SuggestingDifficulty(string userName) { ToFile objnew = SaveToFile.DeserializeLastTest(userName); UserDifficulty userDifficulty = UserDifficulty.Easy; Console.WriteLine($"Last time you did the test on {objnew.UserDifficulty} level and got {objnew.TotalScore}/{objnew.NumberOfQuestions}"); double decimalScore = (double)objnew.TotalScore / (double)objnew.NumberOfQuestions; if (objnew.UserDifficulty == UserDifficulty.Easy) { if (decimalScore <= 0.7) { Console.WriteLine($"You should stay on Easy difficulty"); userDifficulty = UserDifficulty.Easy; } else { Console.WriteLine($"Easy difficulty seems to easy for you💪! You should go up to Normal difficulty"); userDifficulty = UserDifficulty.Normal; } } else if (objnew.UserDifficulty == UserDifficulty.Normal) { if (decimalScore <= 0.3) { Console.WriteLine($"Normal difficulty seems to be to hard for you☹️. You should go down to Easy difficulty"); userDifficulty = UserDifficulty.Easy; } else if ((decimalScore > 0.3) && (decimalScore <= 0.7)) { Console.WriteLine($"You should stay on Normal difficulty"); userDifficulty = UserDifficulty.Normal; } else { Console.WriteLine($"Normal difficulty seems to easy for you💪! You should go up to Hard difficulty"); userDifficulty = UserDifficulty.Hard; } } else if (objnew.UserDifficulty == UserDifficulty.Hard) { if (decimalScore <= 0.3) { Console.WriteLine($"Hard difficulty seems to hard for you☹️. You should go down to Normal difficulty"); userDifficulty = UserDifficulty.Normal; } else if ((decimalScore > 0.3) && (decimalScore <= 0.8)) { Console.WriteLine($"You should stay on Hard difficulty"); userDifficulty = UserDifficulty.Hard; } else { Console.WriteLine($"You are a maths Genius🥳! Sadly this is the hardest level"); userDifficulty = UserDifficulty.Hard; } } return(userDifficulty); }
public YouDao(List <string> p) { toFile = new ToFile(); for (int i = 1; i < p.Count; i++) { transTxt += p[i] + " "; } }
public static void SerializeLastTest(int numberOfQuestions, int totalScore, UserDifficulty userDifficulty, string userName, double totalEasyQuestion, double totalEasyScore, double totalNormalQuestion, double totalNormalScore, double totalHardQuestion, double totalHardScore, double easyTests, double normalTests, double hardTests, int twoPlayerChallengeScore, int allTimeCorrectAnswers) { ToFile obj = new ToFile(numberOfQuestions, userDifficulty, totalScore, totalEasyQuestion, totalEasyScore, totalNormalQuestion, totalNormalScore, totalHardQuestion, totalHardScore, easyTests, normalTests, hardTests, twoPlayerChallengeScore, allTimeCorrectAnswers); IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(FileUtils.GetUserFileName(userName), FileMode.Create, FileAccess.Write); formatter.Serialize(stream, obj); stream.Close(); }
public static ToFile DeserializeLastTest(string userName) { Stream stream = new FileStream(FileUtils.GetUserFileName(userName), FileMode.Open, FileAccess.Read); IFormatter formatter = new BinaryFormatter(); ToFile objnew = (ToFile)formatter.Deserialize(stream); stream.Close(); return(objnew); }
public static void SerializeLastTest(int numberOfQuestions, int totalScore, UserDifficulty userDifficulty, string userName, double totalEasyQuestion, double totalEasyScore, double totalNormalQuestion, double totalNormalScore, double totalHardQuestion, double totalHardScore, double easyTests, double normalTests, double hardTests) { ToFile obj = new ToFile(numberOfQuestions, userDifficulty, totalScore, totalEasyQuestion, totalEasyScore, totalNormalQuestion, totalNormalScore, totalHardQuestion, totalHardScore, easyTests, normalTests, hardTests); IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream($"{userName}.txt", FileMode.Create, FileAccess.Write); formatter.Serialize(stream, obj); stream.Close(); }
public StandardSimulation() { _random = new Random(); _simulationEngine = new Simul(_random); _inclusionsEngine = new InclusionsEngine(_random, _simulationEngine); _bitmapEngine = new Core.Bitma(_simulationEngine); _CAEngine = new CA(_random, _simulationEngine); _MCEngine = new MC(_random, _simulationEngine); _fileEngine = new ToFile(_simulationEngine); _recrystallizationEngine = new Recrystal(_random, _simulationEngine); }
public ChinaBank(List <string> Params) { tofile = new ToFile(); //default this is AUD country = "aus"; if (Params.Count > 1) { country = Params[1].ToLower(); CountryCode = GetCountryCode(country); } }
public static void ScoreDisplay(int numberOfQuestions, Calculation.OperationQuestionScore score, UserDifficulty userDifficulty, string userName) { if (File.Exists(FileUtils.GetUserFileName(userName))) { ToFile objnew = SaveToFile.DeserializeLastTest(userName); score.TotalEasyQuestion = objnew.TotalEasyQuestion; score.TotalEasyScore = objnew.TotalEasyScore; score.TotalNormalQuestion = objnew.TotalNormalQuestion; score.TotalNormalScore = objnew.TotalNormalScore; score.TotalHardQuestion = objnew.TotalHardQuestion; score.TotalHardScore = objnew.TotalHardScore; score.EasyTests = objnew.EasyTests; score.NormalTests = objnew.NormalTests; score.HardTests = objnew.HardTests; score.TwoPlayerChallengeScore = objnew.TwoPlayerChallengeScore; score.AllTimeCorrectAnswers = objnew.AllTimeCorrectAnswers; } if (userDifficulty == UserDifficulty.Easy) { Console.WriteLine($"Addition score: {score.AdditionScore} of {score.AdditionQuestion}"); Console.WriteLine($"Subtraction score: {score.SubtractionScore} of {score.SubtractionQuestion}"); Console.WriteLine($"Multiplication score: {score.MultiplicationScore} of {score.MultiplicationQuestion}"); score.EasyTests++; score.TotalEasyQuestion += numberOfQuestions; score.TotalEasyScore = Math.Round((score.TotalEasyScore + (double)(score.TotalScore / (double)numberOfQuestions) * 100) / score.EasyTests, 2); } else if (userDifficulty == UserDifficulty.Normal) { Console.WriteLine($"Addition score: {score.AdditionScore} of {score.AdditionQuestion}"); Console.WriteLine($"Subtraction score: {score.SubtractionScore} of {score.SubtractionQuestion}"); Console.WriteLine($"Multiplication score: {score.MultiplicationScore} of {score.MultiplicationQuestion}"); Console.WriteLine($"Division score: {score.DivisionScore} of {score.DivisionQuestion}"); score.NormalTests++; score.TotalNormalQuestion += numberOfQuestions; score.TotalNormalScore = Math.Round((score.TotalNormalScore + (double)(score.TotalScore / (double)numberOfQuestions) * 100) / score.NormalTests, 2); } else if (userDifficulty == UserDifficulty.Hard) { Console.WriteLine($"Multipication score: {score.MultiplicationScore} of {score.MultiplicationQuestion}"); Console.WriteLine($"Division score: {score.DivisionScore} of {score.DivisionQuestion}"); Console.WriteLine($"Power score: {score.PowerScore} of {score.PowerQuestion}"); Console.WriteLine($"Squareroot score: {score.SquareRootScore} of {score.SquareRootQuestion}"); score.HardTests++; score.TotalHardQuestion += numberOfQuestions; score.TotalHardScore = Math.Round((score.TotalHardScore + (double)(score.TotalScore / (double)numberOfQuestions) * 100) / score.HardTests, 2); } score.AllTimeCorrectAnswers += score.TotalScore; Console.WriteLine("\n"); }
//exstract file from EDIfact files public void ExtractEDIFIle(string EDIfilepatch, string outputFolder) { BinRipper BinRip = new BinRipper(); ToFile Tofil = new ToFile(); EDIfileInfo EDIinf = new EDIfileInfo(); List <string> extensions = EDIinf.GetextensionOffile(EDIfilepatch); List <string> fileName = EDIinf.GetFileName(EDIfilepatch); List <byte[]> binarydata = BinRip.ExstractBinFromEDI(EDIfilepatch); for (int i = 0; i < extensions.Count; i++) { Tofil.Base64ToImageEDI(binarydata[i], extensions[i], fileName[i], outputFolder); } }
private void Form1_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { if ((pointsTemp.Count() > 1)) { Graphics gTemp = Graphics.FromImage(frameMain); prevShape.Points(points.ToArray()); gTemp = prevShape.DrawS(gTemp); g.DrawImage(frameMain, 0, 0); if (record) { RecordDrawMain.Add((Shape)Activator.CreateInstance(prevShape.GetType(), prevShape)); } else { ShapesUndo.Add((Shape)Activator.CreateInstance(prevShape.GetType(), prevShape)); } points = new List <Point>(); pointsTemp = new List <Point>(); gTemp.Dispose(); } } if (e.Control && e.KeyCode == Keys.S) { ToFile.PerformClick(); } if (e.Control && e.KeyCode == Keys.Z) { Undo.PerformClick(); } if (e.Control && e.KeyCode == Keys.Y) { Redo.PerformClick(); } }
public SaveSuggestions() { tofile = new ToFile(); }
public YahooWeather() { toFile = new ToFile(); }
public ExtractMarker(Dictionary <PatchContentType, CheckBox> fileBoxes, Dictionary <PatchContentType, CheckBox> dbBoxes) { ToFile = fileBoxes.Where(cb => cb.Value.Checked).Select(cb => cb.Key).ToList(); ToDatabase = dbBoxes.Where(cb => cb.Value.Checked).Select(cb => cb.Key).ToList(); Overall = ToFile.Union(ToDatabase).ToList(); }
public override string ToString() { return($"{FromFile.ToString().ToLower()}{FromRank.ToString().Replace("_", "")}" + $"-{ToFile.ToString().ToLower()}{ToRank.ToString().Replace("_", "")}"); }
public static void Main(string[] args) { Console.WriteLine("To Login Type 1, To Create a new account Type 2"); int LogInOrSignUp; do { int.TryParse(Console.ReadLine(), out LogInOrSignUp); } while (LogInOrSignUp != 1 && LogInOrSignUp != 2); var filePath = Path.Combine(AppContext.BaseDirectory, "AccountDetails.txt"); var userName = ""; var password = ""; var successfull = false; var userDetails = Users.DeserializeAccountDetails(filePath); if (userDetails is null) { userDetails = new Users(); } while (!successfull) { if (LogInOrSignUp == 1) { Console.WriteLine("Write your username:"******"Enter your password:"******"You have logged in successfully!"); successfull = true; break; } else { Console.WriteLine("Your username or password is incorect, try again!"); } } else { Console.WriteLine("Enter a username:"******"The username is taken. Try another one."); } else { Console.WriteLine("Enter a password:"******"A new account for {userName} has been created!"); } } } ToFile objnew = SaveToFile.DeserializeLastTest(userName); double totalEasyQuestion = objnew.TotalEasyQuestion; double totalEasyScore = objnew.TotalEasyScore; double totalNormalQuestion = objnew.TotalNormalQuestion; double totalNormalScore = objnew.TotalNormalScore; double totalHardQuestion = objnew.TotalHardQuestion; double totalHardScore = objnew.TotalHardScore; double easyTests = objnew.EasyTests; double normalTests = objnew.NormalTests; double hardTests = objnew.HardTests; UserDifficulty userSuggestingDifficulty = UserDifficulty.Easy; if (File.Exists($"{userName}.txt")) { userSuggestingDifficulty = CanUseManyTimes.SuggestingDifficulty(userName); } var(userDifficulty, numberOfQuestions, autoDifficultyInput, numberOfSeconds) = UserInputs(); if (LogInOrSignUp == 1) { if (autoDifficultyInput == "Y") { userDifficulty = userSuggestingDifficulty; } } var score = RunTest(numberOfQuestions, userDifficulty, numberOfSeconds); Console.WriteLine($"Total score: {score.TotalScore} of {numberOfQuestions}"); if (userDifficulty == UserDifficulty.Easy) { Console.WriteLine($"Addition score: {score.AdditionScore} of {score.AdditionQuestion}"); Console.WriteLine($"Subtraction score: {score.SubtractionScore} of {score.SubtractionQuestion}"); Console.WriteLine($"Multiplication score: {score.MultiplicationScore} of {score.MultiplicationQuestion}"); easyTests++; totalEasyQuestion = totalEasyQuestion + numberOfQuestions; totalEasyScore = Math.Round((totalEasyScore + ((double)score.TotalScore / (double)numberOfQuestions) * 100) / easyTests, 2); } else if (userDifficulty == UserDifficulty.Normal) { Console.WriteLine($"Addition score: {score.AdditionScore} of {score.AdditionQuestion}"); Console.WriteLine($"Subtraction score: {score.SubtractionScore} of {score.SubtractionQuestion}"); Console.WriteLine($"Multiplication score: {score.MultiplicationScore} of {score.MultiplicationQuestion}"); Console.WriteLine($"Division score: {score.DivisionScore} of {score.DivisionQuestion}"); normalTests++; totalNormalQuestion = totalNormalQuestion + numberOfQuestions; totalNormalScore = Math.Round((totalNormalScore + ((double)score.TotalScore / (double)numberOfQuestions) * 100) / normalTests, 2); } else if (userDifficulty == UserDifficulty.Hard) { Console.WriteLine($"Multipication score: {score.MultiplicationScore} of {score.MultiplicationQuestion}"); Console.WriteLine($"Division score: {score.DivisionScore} of {score.DivisionQuestion}"); Console.WriteLine($"Power score: {score.PowerScore} of {score.PowerQuestion}"); Console.WriteLine($"Squareroot score: {score.SquareRootScore} of {score.SquareRootQuestion}"); hardTests++; totalHardQuestion = totalHardQuestion + numberOfQuestions; totalHardScore = Math.Round((totalHardScore + ((double)score.TotalScore / (double)numberOfQuestions) * 100) / hardTests, 2); } string statisticsDisplay; do { Console.WriteLine("Would you like to see your all time statistics? Please type 'Y' or 'N'"); statisticsDisplay = Console.ReadLine(); } while (statisticsDisplay != "Y" && statisticsDisplay != "N"); if (statisticsDisplay == "Y") { Console.WriteLine($"You have answered {totalEasyQuestion} easy questions so far with an average score of {totalEasyScore}%"); Console.WriteLine($"You have answered {totalNormalQuestion} normal questions so far with an average score of {totalNormalScore}%"); Console.WriteLine($"You have answered {totalHardQuestion} hard questions so far with an average score of {totalHardScore}%"); } SaveToFile.SerializeLastTest(numberOfQuestions, score.TotalScore, userDifficulty, userName, totalEasyQuestion, totalEasyScore, totalNormalQuestion, totalNormalScore, totalHardQuestion, totalHardScore, easyTests, normalTests, hardTests); }
public DataService() { tofile = new ToFile(); }