创建编辑器(确实需要帮助!) [英] Creating an editor (realy need help!!)

查看:73
本文介绍了创建编辑器(确实需要帮助!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,专家,

让我解释一下我的问题:
想象一下MS-WORD(包含许多页面)
好的,现在我想创建一个Windows窗体!我的意思是我的表单应该包含许多单独的"页面,
那么,如何创建此页面(第1页,第2页,第3页,...,第200页,..第500页!)?

请注意,我的页面应具有以下功能:

1.页面应包含图片和文字!(但是如何?)
例如,应该有这种可能性,我可以在运行时以其他方式将MS-WORD文档中的文本(包括图片)复制并粘贴到我的表单页面中!
2.用户应该能够将自己的文档保存并加载到.rtf之类的文件中! (但是如何?)
我的意思是将他所有的页面保存到一个文件中! (例如MS-WORD!)

........
现在我该如何解决我的问题?
RichTextBox是否可以使用多达页面?我的意思是每页RichTextBox
有什么有效的方法吗? (由于页面数.例如400页!)
我会很高兴您的帮助.我真的需要它!
非常感谢,请原谅我的英语不好.

Hi experts,

Let me explain my problem:
Imagine the MS-WORD(it contains many pages)
ok, now I want to create a windows form like this! I mean my form should contains many "Separate" pages,
So, how could I create this pages (page 1, page 2, page 3, ..., page 200, .. page 500 ! )?

Please note that my pages should have this abilitys:

1.The pages should contain picture in addition of text!( but how? )
for example it should have this possibility that I copy and paste text (include pictures) from MS-WORD document to my form pages in runtime, or any way else !

2.The user should be able to SAVE and LOAD his/her own document to a file such as .rtf ! ( but how? )
I mean save all his pages into one file ! ( like MS-WORD ! )

........
Now how could I solve my problem?
Is it possible to use RichTextBox as many as pages? I mean a RichTextBox per a page !
Is there any efficient way for it? (because of the amount of pages. for example 400 pages !)
I''ll be glad for your help. i realy need it!
Thanks alot and excuse my bad english.

推荐答案

你好,穆罕默德

1.您可以使用一些用户控件.例如Dev Express XtraRichEdit.观看演示
2. Word女士将所有页面保存到单独的文件中.如果要将页面数据保存在自己的文件中(例如ms word),请为页面类提供一个属性

Hello Mohamad

1. you can use some user controls. For example Dev Express XtraRichEdit. See it''s Demo
2. Ms Word saves all pages to separated files. If you want to save data of a page in it''s own file, (like ms word) have a property for your page class

private string myFilePath;
public string FilePath 
{
   get
   {
      return myFilePath;
   } 
   set
   {
      myFilePath = value;
      Load(myFilePath);
   }
}

private void Save()
{
   //Saving code and using FilePath
}



加载新文件后,创建页面的新实例并初始化它的属性.

例如:



After loading a new file, create a new instance of your page and initialize it''s property.

for example:

private void Load(string myPath)
{ 
  if (!System.IO.File.Exists(myPath))
      return;

  if(!IsBlank(this))
   {         
      WordPage wordPage = new WordPage();      
      wordPage.FilePath = myPath;
      this.FilePath = string.Empty();
      wordPage.Show();
      return;
   }

   //Loading code  
}

private bool IsBlank(WordPage wordPage)
{
   //code for checking if this page is a blank page or not!
}



而且,您可以使用静态字典来防止在2个Windows中加载文件.



And you can use a static Dictinary to prevent loading a file in 2 Windows.

public static Dictionary<string, WordPage> dictionary = new Dictionary<string. WordPage>();


并且:


And:

if(dictionay.ContainsKey("C:\\MyFile.txt"))
{
  //Requiered code ...

   return;
}



并在FormClosed事件中:



And in FormClosed event:

private void myWordPage_FormClosed(object sender, FormClosedEventArgs e)
{
    dictionay.Remove(this.FilePath);
}



希望对您有帮助.



I hope it will help you.


这篇关于创建编辑器(确实需要帮助!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆