Exemple #1
0
        public bool MyComparer(string sorceHtml, string newHtml)
        {
            myThread <char> dinamicPrograming = new myThread <char>(null, new System.Threading.ManualResetEvent(false));
            EditHtml        editHtml;
            Stopwatch       sw = Stopwatch.StartNew();

            editHtml = new EditHtml(sorceHtml, newHtml);
            List <char> res = dinamicPrograming.Hirschberge(editHtml.EditeSourse.ToList(), editHtml.EditeNewHtml.ToList());
            List <int>  arr = Diff <char> .GetDiff(res, editHtml.EditeNewHtml.ToList());

            int i = 0;

            for (; i < arr.Count && (i == 0 || arr[i] != 0); i++)
            {
                arr[i] = editHtml.Arr[arr[i]];
            }
            if (arr.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void OnFileSave()
        {
            Debug.WriteLine("OnFileSave");

            if (_textChanged && _currentExplorerNode != null)
            {
                Debug.WriteLine("File Save..");

                try
                {
                    Messenger.Default.Send(new CustomMessage(
                                               CustomMessage.MessageType.BEFORE_FILE_SAVE));

                    string text = "";
                    if (HtmlMode)
                    {
                        string html_header = "<!DOCTYPE html>\n" +
                                             "<head><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\" /></head>\n" +
                                             "<body>\n";
                        if (EditHtml != null && EditHtml.IndexOf("<!DOCTYPE html") < 0)
                        {
                            text = html_header + EditHtml;
                        }
                        else
                        {
                            text = EditHtml;
                        }
                    }
                    else
                    {
                        text = EditText;
                    }

                    //Debug.WriteLine("Saving.." + text);

                    string descfile = ExplorerNode.GetDescFileName(_currentExplorerNode);
                    string path;
                    if (descfile != null)
                    {
                        if (_currentExplorerNode.ExplorerType == ExplorerType.Folder)
                        {
                            path = _currentExplorerNode.Path + "\\" + descfile;
                        }
                        else
                        {
                            path = System.IO.Path.GetDirectoryName(_currentExplorerNode.Path) + "\\" + descfile;
                        }
                    }
                    else
                    {
                        path = _currentExplorerNode.Path;
                    }

                    // all text
                    System.IO.File.WriteAllText(path, text);

                    // save last write time
                    _lastWriteTime = File.GetLastWriteTime(path);

                    // save old text
                    _editTextOld = text;

                    Messenger.Default.Send(new CustomMessage(
                                               CustomMessage.MessageType.AFTER_FILE_SAVE));
                }
                catch (System.IO.IOException e)
                {
                    MessageBoxShow(e.Message);
                    return;
                }
            }

            _textChanged = false;
        }