Hi currently I'm working on a project and I'm wondering if anyone can help me, I have been set a task of creating a editor which I have done yes its basic and yes its from a book but I would like to add one more thing to it but I'm stuffed and cannot seem to get it to work.
basically I would like the output to be in hex rather than plain text, is this possible?
the code is
In my simplistic approach I am guessing that it is something to do with this lineCode:using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing.Printing; using System.Collections; using System.Windows.Forms; namespace Simple_ed { public partial class frmMain : Form { private string m_sfileName = ""; public frmMain() { InitializeComponent(); } private void clearFormText() { this.Text = "Simple Editor - [unnamed]"; } private void mnuFileExit_Click(object sender, System.EventArgs e) { // exit the application but query user if the text in the box has changed if (rtfMain.Modified == true) { if (MessageBox.Show("Abandon all changes? - All data will be LOST", "Confirm exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Application.Exit(); } } else { Application.Exit(); } } private void mnuFileNew_Click(object sender, EventArgs e) { // create new document with a check to see if the document has been altered if (rtfMain.Modified == true) { if (MessageBox.Show("Create new document? - All unsaved work will be LOST?", "New Document", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { rtfMain.Clear(); m_sfileName = ""; // clear the file name clearFormText(); // and reset the form caption } } else { rtfMain.Clear(); m_sfileName = ""; // clear the file name clearFormText(); // and reset the form caption } } private void setFormText(string sFile) { // create an instance of a FileInfo class and use // it to get the file's name without its path System.IO.FileInfo fInfo; fInfo = new System.IO.FileInfo(sFile); this.Text = "Simple Editor - [" + fInfo.Name + "]"; } private void mnuFileOpen_Click(object sender, EventArgs e) { bool bDoOpen = true; // show an Open File dialog and open the file, but // check that the current text has not changed first if (rtfMain.Modified == true) { if (MessageBox.Show("Text has changed - really open another document?", "Confirm file open", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) bDoOpen = false; } if (bDoOpen == true) { // get a file to open and open it dlgOpen.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; dlgOpen.FilterIndex = 1; if (dlgOpen.ShowDialog() == DialogResult.OK && dlgOpen.FileName.Length > 0) { rtfMain.LoadFile(dlgOpen.FileName, RichTextBoxStreamType.PlainText); rtfMain.Modified = false; m_sfileName = dlgOpen.FileName; setFormText(m_sfileName); } } } private void mnuFileSave_Click(object sender, EventArgs e) { // save the file if we have a filename for it if (m_sfileName != "") rtfMain.SaveFile(m_sfileName, RichTextBoxStreamType.PlainText); else mnuFileSaveAs_Click(sender, e); } private void saveFileDialog1_FileOk(object sender, CancelEventArgs e) { } private void mnuFileSaveAs_Click(object sender, EventArgs e) { // if we have a filename, use that in the dialog, otherwise use // a generic name if (m_sfileName != "") dlgSave.FileName = m_sfileName; else dlgSave.FileName = "SimpleEd1"; dlgSave.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; dlgSave.FilterIndex = 1; dlgSave.DefaultExt = "txt"; if (dlgSave.ShowDialog() == DialogResult.OK && dlgSave.FileName.Length > 0) { rtfMain.SaveFile(dlgSave.FileName, RichTextBoxStreamType.PlainText); rtfMain.Modified = false; m_sfileName = dlgSave.FileName; setFormText(m_sfileName); } } } }
but as I have found learning this language nothing is as simple as it seems.Code:rtfMain.LoadFile(dlgOpen.FileName, RichTextBoxStreamType.PlainText);
its just a starting point for me to learn really and i will be expanding it as much as i can as i learn ATM I'm just learning how to do the cut copy and paste.
I thank anyone in advance for the help they may offer
Sorry I forgot to say I'm using Microsoft visual studio 2010 c# if that makes a difference.



LinkBack URL
About LinkBacks


