예제 #1
0
        public void SelectSentenses(ListView list, bool left)
        {
            string currentPath;

            if (left)
            {
                currentPath = CurrentPath1;
            }
            else
            {
                currentPath = CurrentPath2;
            }
            string content = " ";

            if (list.SelectedItems.Count > 0)
            {
                foreach (int i in list.SelectedIndices)
                {
                    if (list.Items[i].ImageIndex == 0)
                    {
                        continue;
                    }
                    else
                    {
                        string     curP = list.Items[i].Text;
                        CommonFile cf   = new CommonFile(currentPath + "\\" + list.Items[i].Text);
                        if (curP.Substring(curP.LastIndexOf(".") + 1) == "txt")
                        {
                            string sent = cf.GetText(new TxtFile(currentPath + "\\" + list.Items[i].Text));
                            content += Presenter.threeSentenses(sent);
                        }
                        else if (curP.Substring(curP.LastIndexOf(".") + 1) == "xml")
                        {
                            string sent = cf.GetText(new XmlFile(currentPath + "\\" + list.Items[i].Text));
                            content += Presenter.threeSentenses(sent);
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
                Clipboard.SetText(content);
            }
        }
예제 #2
0
        public void Merging(ListView list, bool left)
        {
            if (contentForMerging == "")
            {
                MessageBox.Show("Please select html file", "Oops..");
                return;
            }
            string path = list.SelectedItems[0].Text;
            string currentPath;

            if (left)
            {
                currentPath = String.Format(@"{0}\\{1}", currentPath1, path);
            }
            else
            {
                currentPath = String.Format(@"{0}\\{1}", currentPath2, path);
            }
            if (list.SelectedItems[0].ImageIndex == 0)
            {
                MessageBox.Show("You haven`t chosen a html1 file", "Oops...");
            }
            else
            {
                try
                {
                    CommonFile commonFile = new CommonFile(currentPath);
                    if (currentPath.Substring(currentPath.LastIndexOf(".") + 1) == "html")
                    {
                        filesToCopy.Clear();
                        string content = commonFile.GetText(new HtmlFile(currentPath));
                        if (GetPathesOfImg(content) && GetPathesOfImg(contentForMerging))
                        {
                            ProcessMerging(currentPath);
                            File.AppendAllText(currentPath, contentForMerging);
                        }
                        else
                        {
                            contentForMerging = "";
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("You haven`t chosen a html file", "Oops...");
                    }
                }
                catch (Exception error)
                {
                    contentForMerging = "";
                    MessageBox.Show(error.Message.ToString(), "Error");
                }
            }
            MessageBox.Show("Merging complete", "Result");
            contentForMerging = "";
        }
예제 #3
0
        static public void OpenResult(ListView list)
        {
            string currentpath = pathes[0].Substring(0, pathes[0].LastIndexOf('\\') + 1);
            string path        = list.SelectedItems[0].Text;

            currentpath = currentpath + path;
            CommonFile commonFile = new CommonFile(currentpath);
            string     content;

            content = commonFile.GetText(new HtmlFile(currentpath));
            TextEditorForm HEdit = new TextEditorForm(content, currentpath, true);

            HEdit.ShowDialog();
        }
예제 #4
0
        public bool StartSearch(string path, string key)
        {
            CommonFile commonFile = new CommonFile(path);
            string     content    = commonFile.GetText(new HtmlFile(path));

            content = content.ToLower();
            key     = key.ToLower();
            MatchCollection matches = Regex.Matches(content, @"(<\s*title[^>]*>(.*?)<\s*\/\s*title>)");

            foreach (var match in matches)
            {
                if (match.ToString().Contains(key))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #5
0
        public void Select(ListView list, bool left)
        {
            string path = list.SelectedItems[0].Text;
            string currentPath;

            if (left)
            {
                currentPath = String.Format(@"{0}\\{1}", currentPath1, path);
            }
            else
            {
                currentPath = String.Format(@"{0}\\{1}", currentPath2, path);
            }
            if (list.SelectedItems[0].ImageIndex == 0)
            {
                MessageBox.Show("You haven`t chosen a html1 file", "Oops...");
            }
            else
            {
                try
                {
                    CommonFile cf = new CommonFile(currentPath);
                    if (currentPath.Substring(currentPath.LastIndexOf(".") + 1) == "html")
                    {
                        contentForMerging = cf.GetText(new HtmlFile(currentPath));
                    }
                    else
                    {
                        MessageBox.Show("You haven`t chosen a html file", "Oops...");
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show(error.Message.ToString(), "Error");
                }
            }
        }
예제 #6
0
        public void WordsIncludesInFile(ListView list, bool left)
        {
            string currentPath;

            if (left)
            {
                currentPath = CurrentPath1;
            }
            else
            {
                currentPath = CurrentPath2;
            }
            if (list.SelectedItems.Count > 0)
            {
                foreach (int i in list.SelectedIndices)
                {
                    if (list.Items[i].ImageIndex == 0)
                    {
                        continue;
                    }
                    else
                    {
                        string     currentPosition = list.Items[i].Text;
                        CommonFile commonFile      = new CommonFile(currentPath + "\\" + list.Items[i].Text);
                        if (currentPosition.Substring(currentPosition.LastIndexOf(".") + 1) == "txt")
                        {
                            string sent = commonFile.GetText(new TxtFile(currentPath + "\\" + list.Items[i].Text));
                            Presenter.SearchWordIncludes(sent);
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
            }
        }
예제 #7
0
        public void openItem(ListView list, bool left)
        {
            string path = list.SelectedItems[0].Text;
            string currentPath;

            if (left)
            {
                currentPath = String.Format(@"{0}\\{1}", currentPath1, path);
            }
            else
            {
                currentPath = String.Format(@"{0}\\{1}", currentPath2, path);
            }
            if (list.SelectedItems[0].ImageIndex == 0)
            {
                try
                {
                    refresh(list, currentPath);
                    if (left)
                    {
                        currentPath1 = currentPath;
                    }
                    else
                    {
                        currentPath2 = currentPath;
                    }
                }
                catch (IOException ex)
                {
                    refresh(list, currentPath1);
                }
                catch (UnauthorizedAccessException ex)
                {
                    MessageBox.Show("В доступі відказано", "ERROR");
                }
            }
            else
            {
                try
                {
                    CommonFile cf = new CommonFile(currentPath);
                    string     content;
                    if (currentPath.Substring(currentPath.LastIndexOf(".") + 1) == "txt")
                    {
                        content = cf.GetText(new TxtFile(currentPath));
                        TextEditor TEdit = new TextEditor(content, currentPath);
                        TEdit.ShowDialog();
                    }
                    else if (currentPath.Substring(currentPath.LastIndexOf(".") + 1) == "xml")
                    {
                        content = cf.GetText(new XmlFile(currentPath));
                        TextEditor TEdit = new TextEditor(content, currentPath);
                        TEdit.ShowDialog();
                    }
                    else
                    {
                        Process.Start(currentPath);
                    }
                }
                catch
                {
                    MessageBox.Show("В доступі до файлу відказано");
                }
            }
        }
예제 #8
0
        public void OpenItem(ListView list, bool left)
        {
            string path = list.SelectedItems[0].Text;
            string currentPath;

            if (left)
            {
                currentPath = String.Format(@"{0}\\{1}", currentPath1, path);
            }
            else
            {
                currentPath = String.Format(@"{0}\\{1}", currentPath2, path);
            }
            if (list.SelectedItems[0].ImageIndex == 0)
            {
                try
                {
                    Refresh(list, currentPath);
                    if (left)
                    {
                        currentPath1 = currentPath;
                    }
                    else
                    {
                        currentPath2 = currentPath;
                    }
                }
                catch (IOException ex)
                {
                    Refresh(list, currentPath1);
                }
                catch (UnauthorizedAccessException ex)
                {
                    MessageBox.Show("You haven`t access", "Error");
                }
                director.OpenReport(currentPath);
                director.BuildReport();
                reports.Add(director.GetReportItem());
            }
            else
            {
                try
                {
                    CommonFile cf = new CommonFile(currentPath);
                    string     content;
                    if (currentPath.Substring(currentPath.LastIndexOf(".") + 1) == "txt")
                    {
                        content = cf.GetText(new TxtFile(currentPath));
                        TextEditorForm TEdit = new TextEditorForm(content, currentPath, false);
                        TEdit.ShowDialog();
                    }
                    else if (currentPath.Substring(currentPath.LastIndexOf(".") + 1) == "html")
                    {
                        content = cf.GetText(new HtmlFile(currentPath));
                        TextEditorForm HEdit = new TextEditorForm(content, currentPath, false);
                        HEdit.ShowDialog();
                    }
                    else
                    {
                        Process.Start(currentPath);
                    }
                    director.OpenReport(path);
                    director.BuildReport();
                    reports.Add(director.GetReportItem());
                }
                catch (InvalidOperationException ex)
                {
                    MessageBox.Show("You haven`t access", "Error");
                }
            }
        }