//合并文字资源
        public void combine(TextsManager src_Manager)
        {

            for (int i = 0; i < src_Manager.getElementCount(); i++)
            {
                TextElement srcElement = src_Manager.getElement(i);
                TextElement newElement = null;
                //寻找重复
                for (int j = 0; j < getElementCount(); j++)
                {
                    TextElement localElement = getElement(j);
                    if (localElement.getValue().Equals(srcElement.getValue()))
                    {
                        newElement = localElement;
                        break;
                    }
                }
                if (newElement == null)
                {
                    newElement=new TextElement(this);
                    newElement.setValue(srcElement.getValue());
                    addElement(newElement);
                }
            }
            //将显示容器置空
            this.listBox = null;
            this.listBoxAide = null;
            Console.WriteLine(this.GetHashCode());
        }
 //编辑所选文字
 public TextElement editTextElement(TextElement element)
 {
     if (element != null)
     {
         listBox_Texts.SelectedIndex = element.getID();
     }
     this.ShowDialog();
     if (closedByUser && textsManager != null)
     {
         TextElement returnElement = textsManager.getElement(listBox_Texts.SelectedIndex);
         return returnElement;
     }
     return null;
 }
 //串行化输入与输出===================================================================
 //串行读入
 public void ReadObject(Stream s)
 {
     int textsLen = IOUtil.readInt(s);
     if (textsLen <= 0)
     {
         return;
     }
     objList.Clear();
     for (int i = 0; i < textsLen; i++)
     {
         TextElement txtElement = new TextElement(this);
         txtElement.ReadObject(s);
         addElement(txtElement);//增加到列表
         //Consts.loadingDialog.setStep(40 + i * 10 / textsLen, "载入文字:" + txtElement.getValue());
     }
 }
 public override ObjectElement clone()
 {
     TextElement newInstance = new TextElement((TextsManager)parent);
     newInstance.setValue(text + "");
     return newInstance;
 }
 //根据单元返回索引
 public int getElementIndx(TextElement textElement)
 {
     return objList.IndexOf(textElement);
 }
Example #6
0
 //根据单元返回索引
 public int getElementIndx(TextElement textElement)
 {
     return(objList.IndexOf(textElement));
 }
 private void button_add_Click(object sender, EventArgs e)
 {
     TextElement newText = new TextElement(textsManager);
     newText.setValue("新添加的文本");
     textsManager.addElement(newText);
     refreshUsedTime();
 }
 private void button_Inseart_Click(object sender, EventArgs e)
 {
     TextElement newText = new TextElement(textsManager);
     newText.setValue("新插入的文本");
     textsManager.insertElement(newText, listBox_Texts.SelectedIndex);
     refreshUsedTime();
 }
 private void 插入文本ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     TextElement newText = new TextElement(textsManager);
     newText.setValue("新插入的文本");
     textsManager.insertElement(newText, listBox_Texts.SelectedIndex);
     refreshUsedTime();
 }
 private void 添加文字ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     TextElement newText = new TextElement(textsManager);
     newText.setValue("新添加的文本");
     textsManager.addElement(newText);
     refreshUsedTime();
 }