i want to make Textviewer. this show Two pages. like book!!
so i want to know. how to make page (string[] array or list).
and i wish to use graphics.drawstring or textrenderer. not textbox control.
because i already make it use with textbox. but it is too slow loading and resizing.
i have a good target here
책보는 프로그램 - 별북 ( 1.5 정식 ) :: 제이드민
i wish it can open 10mbytes or bigger files.
let me know your knowhow.
What I have tried:
i already make this but it is slow. i used textbox control.
when i resize wordwrap is Change all text. and have to make page reindex all text.
it takes so long.
give me a tip.
ok i think my question is bad.
i wish this code be Fast
string filetxt = string.Empty;
private void toolStripButton2_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Textfile|*.txt";
string filename = string.Empty;
if (DialogResult.OK == ofd.ShowDialog())
{
filename = ofd.FileName;
filetxt = File.ReadAllText(filename, System.Text.Encoding.GetEncoding(51949));
Graphics aa = CreateGraphics();
SizeF sizefl = new SizeF(panel1.Width - 20, panel1.Height - 20);
StringFormat stf = new StringFormat(StringFormatFlags.LineLimit);
int charactersfitted;
int linesfilled;
string bbb = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
SizeF sf = aa.MeasureString(bbb, new Font("굴림", 12), sizefl, stf, out charactersfitted, out linesfilled);
int maxlines = linesfilled;
charactersfitted = 0;
linesfilled = 0;
int indexofchar = 0;
int page = 0;
while (true)
{
if (indexofchar < filetxt.Length - 10000)
{
string aaa = filetxt.Substring(indexofchar, 10000);
SizeF sfefs = aa.MeasureString(aaa, new Font("굴림", 12), sizefl, stf, out charactersfitted, out linesfilled);
indexofchar += charactersfitted;
pages[page] = aaa.Substring(0, charactersfitted);
page++;
}
else {
break;
}
}
hScrollBar1.Maximum = page;
Invalidate();
Refresh();
}
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
Rectangle rect = new Rectangle(10, 10, panel1.Width - 20, panel1.Height - 20);
e.Graphics.DrawRectangle(new Pen(Color.Black), rect);
StringFormat stf = new StringFormat(StringFormatFlags.LineLimit);
e.Graphics.DrawString(pages[pagesval], new Font("굴림", 12), new SolidBrush(Color.Black), rect, stf);
}
string[] pages = new string[100000];
int pagesval = 0;
private void hScrollBar1_ValueChanged(object sender, EventArgs e)
{
pagesval = hScrollBar1.Value;
Invalidate();
Refresh();
}