private void Retrieve_Click(object sender, EventArgs e) { //declare the action here Action <RichTextBox, string> RetrieveWithoutError; //define the action, = method body RetrieveWithoutError = delegate(RichTextBox GC, string FC) { try { GC.AppendText(File.ReadAllText(".\\GraficConsole.txt")); } catch (Exception) { using (StreamWriter w = File.AppendText(FC)) { ; } } }; GraficConsole.AppendText(Environment.NewLine + "using the Retrive Action here ..." + Environment.NewLine); //call the action here RetrieveWithoutError(GraficConsole, AppFiles.ConsoleTextFile.TheFileComplete); }
private void Clear_Click(object sender, EventArgs e) { //copied from blankout for sake of better coding ! MessageBox.Show("Blank out will delete everything from a file. Do you want to continue?" , "Blank Out", MessageBoxButtons.OK , MessageBoxIcon.Information); System.IO.File.WriteAllText(".\\GraficConsole.txt", string.Empty); GraficConsole.DoubleClick += delegate //we can make a custom made method ans add it on the fly ! { GraficConsole.AppendText(Environment.NewLine + " A EVENT MANAGER ON THE FLY HAS BEEN ADDED TO THE CONSOLE!" + Environment.NewLine); MessageBox.Show("SHOULD WE CONTINUE?" , "APPENDED A DELEGATE", MessageBoxButtons.OK , MessageBoxIcon.Information); }; //further processing // TakeSafetyMeasures ConsoleSafetyMeasure = delegate { GraficConsole.Text = string.Empty; }; TakeSafetyMeasures ConsoleSafetyMeasure = new TakeSafetyMeasures(FileSafetyMeasure); ConsoleSafetyMeasure(); GraficConsole.Text = string.Empty; GraficConsole.DoubleClick -= Clear_Click; }
private void GraficConsole_DoubleClick(object sender, EventArgs e) { GraficConsole.AppendText("We have just dbl clicked the grafic console" + Environment.NewLine); return; // we pre empt the calls below /* * //here, i want to call a button event * //i choose to call Save * //way # 1 of doing it! * //repeat the method entirely !!!! * System.IO.File.AppendAllText(AppFiles.ConsoleTextFile.TheFileComplete, GraficConsole.Text); * // the disaDVANTAGE IS , TOO MANY COPIES TOP BE MADE * * //SO,METHOD 2 * //call it * Save_Click( sender, e); * //nothing look wrong here * //but, the stattement is hard coded here */ }
private void Save_Click(object sender, EventArgs e) { //please explore the combine command for better app creation //string TheFileComplete = System.IO.Path.Combine(AppFiles.ConsoleTextFile.Path, AppFiles.ConsoleTextFile.Name); //we define the lambda expression/functio here ... BulkTextWriter AppendBulkText = (string FileNameAndPath, string targetBlock) => { GraficConsole.AppendText(Environment.NewLine + "We have just added \'save\' to the grafic console" + Environment.NewLine); System.IO.File.AppendAllText(FileNameAndPath, targetBlock); }; GraficConsole.AppendText(Environment.NewLine + "using the Save Lambda here ..." + Environment.NewLine); //call the lambda expression/functio here, immediately! AppendBulkText(AppFiles.ConsoleTextFile.TheFileComplete, GraficConsole.Text); GraficConsole.DoubleClick += Clear_Click; //next time onwards ! }
private void Highlight_Click(object sender, EventArgs e) { GraficConsole.Focus(); GraficConsole.SelectAll(); }
private void btn_Edit_Click(object sender, EventArgs e) { //GraficConsole.l GraficConsole.Focus(); }