コード例 #1
0
        private void LoadHistoryFile(FileInfo oldFile)
        {
            if (oldFile != null && oldFile.Exists)
            {
                lblFullOldFileName.Text = oldFile.FullName;
                lblOldMod.Text          = oldFile.LastWriteTime.ToString();
                lblOldSize.Text         = oldFile.Length.ToString() + " bytes";
                rbOld.ForeColor         = Color.Black;

                if ((oldFile.Extension.ToUpper() == ".RTF") || (oldFile.Extension.ToUpper() == ".DOC") || (oldFile.Extension.ToUpper() == ".DOCX"))
                {
                    rbOld.LoadFile(oldFile.FullName, RichTextBoxStreamType.RichText);
                }
                else
                {
                    rbOld.LoadFile(oldFile.FullName, RichTextBoxStreamType.PlainText);
                }

                currentHistoryFileName = oldFile.Name;

                RBHelper.DiffHighlighting(diffBuilder, rbNew, rbOld);
                RBHelper.HighlightText(rbOld);

                rbOld.Select();
                AddLineNumbers(false);
                rbOld.Select(0, 0);
            }
        }
コード例 #2
0
        private void LastChange_Load(object sender, EventArgs e)
        {
            btnNext.Enabled     = false;
            btnPrevious.Enabled = false;

            backupFolder = Config.ReadSetting(Config.FileTypePrefix() + label + Config.BackupSuffix);
            loading      = true;

            string   folder  = Config.ReadSetting(Config.FileTypePrefix() + label);
            FileInfo newFile = new FileInfo(folder + "\\" + fileName);

            if (newFile != null && newFile.Exists)
            {
                lblFullNewFileName.Text = newFile.FullName;
                lblNewMod.Text          = newFile.LastWriteTime.ToString();
                lblNewSize.Text         = newFile.Length.ToString() + " bytes";
                rbNew.ForeColor         = Color.Black;
                if ((newFile.Extension.ToUpper() == ".RTF") || (newFile.Extension.ToUpper() == ".DOC") || (newFile.Extension.ToUpper() == ".DOCX"))
                {
                    rbNew.LoadFile(newFile.FullName, RichTextBoxStreamType.RichText);
                }
                else
                {
                    rbNew.LoadFile(newFile.FullName, RichTextBoxStreamType.PlainText);
                }

                RBHelper.HighlightText(rbNew);

                string extension        = newFile.Extension;
                string withoutExtension = newFile.Name.Substring(0, newFile.Name.Length - extension.Length);
                searchString = withoutExtension + "-20" + "*" + extension;

                DirectoryInfo di    = new DirectoryInfo(backupFolder);
                FileInfo[]    files = di.GetFiles(searchString);
                //These will be ordered by name by default, so we want the last one.
                FileInfo oldFile = files.LastOrDefault();
                btnPrevious.Enabled = files.Count() > 1;
                LoadHistoryFile(oldFile);
            }
            loading = false;
            AddLineNumbers(true);
            rbNew.Select(0, 0);
        }