/// <summary> /// Flushes the Queue to the physical log file /// </summary> private async Task FlushLog() { try { if (this.IsFlushing) { Console.WriteLine("(AlreadyFlushing?)"); return; } this.IsFlushing = true; long LastQCnt = this.logQueue.Count; if (this.logQueue.Count > 0) { //Console.WriteLine("LogWriter:FlushLog: Flushing " & logQueue.Count & " items on thread " & Thread.CurrentThread.ManagedThreadId & ", Secs since last flush: " & (Now - LastFlushed).TotalSeconds & "...", , , False) Stopwatch sw = Stopwatch.StartNew(); using (IOFile FileWriter = new IOFile(this.LogFile)) { FileWriter.WriteQueue = this.logQueue; await FileWriter.WriteFile(); this.LastLogWrittenTime = FileWriter.LastLogWriteTime; } sw.Stop(); if (sw.ElapsedMilliseconds >= 1000) { Console.WriteLine($"LogWriter:FlushLog: DONE Flushing in {sw.ElapsedMilliseconds}ms, LogQueue: {LastQCnt} items, File: {this.LogFile}"); } } this.LastLogFlushedTimeUTC = DateTime.UtcNow; } catch (Exception ex) { Console.WriteLine("Error: " + ex.Msg()); } finally { this.IsFlushing = false; this.LastLogFlushedTimeUTC = DateTime.UtcNow; } this.FlushRightAway = false; }
//Меню - новый. private void новыйToolStripMenuItem_Click(object sender, EventArgs e) { //Временная строка Text txt = new Text(); //Если имя файла уже есть if (file.GetName() != "") { //Открываем текущий файл txt.Set(file.ReadFile()); } //Проверяем был ли изменен текущий файл if (richTextBox1.Text + "\n" != txt.Get() && richTextBox1.Text != txt.Get()) { //Если изменён //Спрашиваем сохранить или нет DialogResult result = MessageBox.Show("Сохранить?", "Создание нового файла", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); //Если требуется сохранить файл if (result == DialogResult.OK) { //Сохраняем txt.Set(richTextBox1.Text); file.WriteFile(txt); } } //Выводим форму для создания файла NewFile nf = new NewFile(); nf.ShowDialog(); //Получаем от нее имя нового файла file.SetName("Files/" + nf.name + ".vb"); txt.Set(""); //Создаем его file.WriteFile(txt); //очищаем текстовое поле richTextBox1.Text = txt.Get(); }
/// <summary>Saves the lists in a file in csv format.</summary> /// <param name="filename">The filename.</param> public void SaveListsInFile(string filename) { string s = "COLOR SPACE;A;B;C"; IOFile.WriteFile(filename, s); s = "HSB max;"; double[] d = MaxValues[(int)ColorSpaceEnum.HSB]; IOFile.WriteLine( filename, 1, s + d[0] + ";" + d[1] + ";" + d[2] + ";", true); s = "HSB min;"; d = MinValues[(int)ColorSpaceEnum.HSB]; IOFile.WriteLine( filename, 2, s + d[0] + ";" + d[1] + ";" + d[2] + ";", true); s = "HSL max;"; d = MaxValues[(int)ColorSpaceEnum.HSL]; IOFile.WriteLine( filename, 3, s + d[0] + ";" + d[1] + ";" + d[2] + ";", true); s = "HSL min;"; d = MinValues[(int)ColorSpaceEnum.HSL]; IOFile.WriteLine( filename, 4, s + d[0] + ";" + d[1] + ";" + d[2] + ";", true); s = "LAB max;"; d = MaxValues[(int)ColorSpaceEnum.LAB]; IOFile.WriteLine( filename, 5, s + d[0] + ";" + d[1] + ";" + d[2] + ";", true); s = "LAB min;"; d = MinValues[(int)ColorSpaceEnum.LAB]; IOFile.WriteLine( filename, 6, s + d[0] + ";" + d[1] + ";" + d[2] + ";", true); s = "LCH max;"; d = MaxValues[(int)ColorSpaceEnum.LCH]; IOFile.WriteLine( filename, 7, s + d[0] + ";" + d[1] + ";" + d[2] + ";", true); s = "LCH min;"; d = MinValues[(int)ColorSpaceEnum.LCH]; IOFile.WriteLine( filename, 8, s + d[0] + ";" + d[1] + ";" + d[2] + ";", true); s = "LUV max;"; d = MaxValues[(int)ColorSpaceEnum.LUV]; IOFile.WriteLine( filename, 9, s + d[0] + ";" + d[1] + ";" + d[2] + ";", true); s = "LUV min;"; d = MinValues[(int)ColorSpaceEnum.LUV]; IOFile.WriteLine( filename, 10, s + d[0] + ";" + d[1] + ";" + d[2] + ";", true); s = "RGB max;"; d = MaxValues[(int)ColorSpaceEnum.RGB]; IOFile.WriteLine( filename, 11, s + d[0] + ";" + d[1] + ";" + d[2] + ";", true); s = "RGB min;"; d = MinValues[(int)ColorSpaceEnum.RGB]; IOFile.WriteLine( filename, 12, s + d[0] + ";" + d[1] + ";" + d[2] + ";", true); s = "SRGB max;"; d = MaxValues[(int)ColorSpaceEnum.SRGB]; IOFile.WriteLine( filename, 13, s + d[0] + ";" + d[1] + ";" + d[2] + ";", true); s = "SRGB min;"; d = MinValues[(int)ColorSpaceEnum.SRGB]; IOFile.WriteLine( filename, 14, s + d[0] + ";" + d[1] + ";" + d[2] + ";", true); s = "XYZ max;"; d = MaxValues[(int)ColorSpaceEnum.XYZ]; IOFile.WriteLine( filename, 15, s + d[0] + ";" + d[1] + ";" + d[2] + ";", true); s = "XYZ min;"; d = MinValues[(int)ColorSpaceEnum.XYZ]; IOFile.WriteLine( filename, 16, s + d[0] + ";" + d[1] + ";" + d[2] + ";", true); }