private void buttonMultiplicationTextToClipboard_Click(object sender, EventArgs e)
 {
     if (SelectArticleItem != null)
     {
         ArusSoft.Library.StringReproduction UnicTree;
         if ((SelectArticleItem.Tag as Article).UnicTree != null && !textEditor.Modified)
             UnicTree = (ArusSoft.Library.StringReproduction)(SelectArticleItem.Tag as Article).UnicTree;
         else
         {
             UnicTree = new ArusSoft.Library.ParseText(textEditor.Text).Parse();
             (SelectArticleItem.Tag as Article).UnicTree = UnicTree;
         }
         Clipboard.SetText(UnicTree.ToString());
     }
 }
        private void buttonMultiplicationTextRun_Click(object sender, EventArgs e)
        {
            if (SelectArticleItem != null)
            {
                Article art = (SelectArticleItem.Tag as Article);
                buttonMultiplicationTextRun.Text = "";
                buttonMultiplicationTextRun.Enabled = false;

                int iteration = 0;
                int countText = 0;
                int countThreads = Environment.ProcessorCount * 4;
                Task<string>[] works = new Task<string>[countThreads];

                ArusSoft.Library.Shingle UnicTextes = new ArusSoft.Library.Shingle((int)numMultiplicationTextShingleLenght.Value, (int)numMultiplicationTextSimilarPercent.Value);
                ArusSoft.Library.StringReproduction UnicTree;
                if (art.UnicTree != null && !textEditor.Modified)
                    UnicTree = (ArusSoft.Library.StringReproduction)art.UnicTree;
                else
                {
                    UnicTree = new ArusSoft.Library.ParseText(textEditor.Text).Parse();
                    (SelectArticleItem.Tag as Article).UnicTree = UnicTree;
                }

                while ((iteration < numMultiplicationTextIteration.Value) && (countText < numMultiplicationTextCountText.Value))
                {
                    for (int i = 0; i < countThreads; i++)
                        works[i] = Task.Factory.StartNew<string>(() => UnicTree.ToString());
                    Task.WaitAll(works);
                    for (int i = 0; i < countThreads; i++)
                    {
                        if (UnicTextes.Add(works[i].Result))
                        {
                            countText++;
                            buttonMultiplicationTextRun.Text = "Running (Iteration: " + iteration.ToString() + " Texts: " + countText.ToString();
                            if (countText >= numMultiplicationTextCountText.Value) break;
                        }
                        iteration++;
                        buttonMultiplicationTextRun.Text = "Running (Iteration: " + iteration.ToString() + " Texts: " + countText.ToString();
                        if (iteration >= numMultiplicationTextIteration.Value) break;
                    }
                }
                ArrayList tmpTexts = UnicTextes.GetTexts();
                if (radioMultiplicationTextSaveInternalDB.Checked)
                {
                    foreach (ArusSoft.Library.MultiplicationText txt in tmpTexts)
                        art.MultiplicationTextList.Add(new MultiplicationText() { Article = art, Body = txt.Text });
                    UpdateMultiplicationText();
                }
                else
                {
                    StringBuilder tmp = new StringBuilder();
                    foreach (ArusSoft.Library.MultiplicationText txt in tmpTexts)
                        tmp.AppendLine(textMultiplicationTextSavePlainTextSeparatorBefor.Text + txt.Text + textMultiplicationTextSavePlainTextSeparatorAfter.Text + Environment.NewLine);
                    Clipboard.SetText(tmp.ToString());
                }

                buttonMultiplicationTextRun.Text = "Run";
                buttonMultiplicationTextRun.Enabled = true;
            }
        }