如何制作页面列表 [英] How do I make page list
问题描述
我想制作Textviewer。这个节目有两页。喜欢预订!!
所以我想知道。如何制作页面(string []数组或列表)。
我希望使用graphics.drawstring或textrenderer。不是文本框控件。
因为我已经使用了文本框。但加载和调整大小太慢。
i这里有一个很好的目标책보는프로그램 - 별북(1.5식식)::제이드민
i希望它可以打开10个字节或更大的文件。
让我知道你的专有技术。
我尝试过:
i已经做到了但这很慢。我使用了文本框控件。
当我调整wordwrap时,
是更改所有文本。并且必须使页面重新索引所有文本。
它需要这么长时间。
给我一个提示。
好吧我觉得我的问题很糟糕。
i希望这段代码很快
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;
//find max lines
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();
}
推荐答案
试试TXTextControl
文本控制 - 面向Windows,Web和移动应用程序(TX文本控制)开发人员的.NET报告和文字处理组件www.textcontrol.com [ ^ ]
Try TXTextControl
Text Control - .NET Reporting and Word Processing Components for Developers of Windows, Web and Mobile Applications (TX Text Control) | www.textcontrol.com[^]
你应该详细解释你想做什么,因为
You should explain in detail what you want to do because
我希望它可以打开10mbytes或更大的文件。
i wish it can open 10mbytes or bigger files.
是不现实的。
任何带有这样文件的东西都是懒散的。
is unrealistic.
Anything with such a file will be sloooow.
这篇关于如何制作页面列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!