Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
1 Star 0 Fork 122

松竹/DevelopAssistant

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
Tags (3)
master
V5.0.2
V4.8.32
V4.3.31
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
The license selected for the repository is subject to the license used by the main branch of the repository.
master
Branches (1)
Tags (3)
master
V5.0.2
V4.8.32
V4.3.31
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
Tags (3)
master
V5.0.2
V4.8.32
V4.3.31
MainForm.cs 19.88 KB
Copy Edit Raw Blame History
新无止竞 authored 2020年09月07日 11:13 +08:00 . 修复文件内容对比报格式转换错误的问题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
using DevelopAssistant.AddIn.Diffplex.Properties;
using DevelopAssistant.Service;
using DiffPlex;
using DiffPlex.DiffBuilder;
using DiffPlex.DiffBuilder.Model;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.WinFormsUI.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace DevelopAssistant.AddIn.Diffplex
{
public partial class MainForm : ICSharpCode.WinFormsUI.Docking.DockContent
{
private Form mainForm = null;
int ScrollType = 0; //0竖向滚动条 1横向滚动条
int currentIndex = -1;
int currentVScrollBarValue = 0;
int currentHScrollBarValue = 0;
int lastVScrollBarValue = 0;
int lastHScrollBarValue = 0;
string currentTheme = string.Empty;
string HighlightingName = "Text";
Color red = Color.FromArgb(045, 000, 000);
Color yellow = Color.FromArgb(153, 153, 0);
Color green = Color.FromArgb(038, 094, 077);
string sourceContentText = string.Empty;
string targetContentText = string.Empty;
System.Windows.Forms.Timer timer = null;
List<CodeLine> deffenrence_lines = new List<CodeLine>();
ToolTip tooltip = new ToolTip();
OpenFileDialog openFile = new OpenFileDialog();
ISideBySideDiffBuilder diffBuilder = null;
public MainForm()
{
InitializeComponent();
InitializeControls();
}
public MainForm(Form owner,string theme, AddInBase addin)
: this()
{
mainForm = owner;
currentTheme = theme;
diffBuilder = new DiffPlex.DiffBuilder.SideBySideDiffBuilder(new Differ());
switch (currentTheme)
{
case "Black":
red = Color.FromArgb(045, 000, 000);
yellow = Color.FromArgb(153, 153, 0);
green = Color.FromArgb(038, 094, 077);
break;
case "Default":
red = Color.FromArgb(255, 204, 204);
yellow = Color.FromArgb(255, 255, 204);
green = Color.FromArgb(102, 255, 102);
break;
}
this.SourceTextControl.SetHighlighting(theme, HighlightingName);
this.TargetTextControl.SetHighlighting(theme, HighlightingName);
}
private void InitializeControls()
{
this.lblSourceFile.Text = "原内容";
this.lblTargetFile.Text = "新内容";
tooltip.SetToolTip(this.lblSourceFile, "原内容");
tooltip.SetToolTip(this.lblTargetFile, "新内容");
this.btnPrevDifferent.ToolTipText = "上一处";
this.btnNextDifferent.ToolTipText = "下一处";
this.btnStartCompare.ToolTipText = "开始比较";
this.btnPrevDifferent.IconImage= Resources.navigate_prev;
this.btnNextDifferent.IconImage = Resources.navigate_next;
this.btnStartCompare.IconImage = Resources.compare;
this.panel3.BorderStyle = NBorderStyle.All;
this.panel1.BorderColor = SystemColors.ControlLight;
this.panel2.BorderStyle = NBorderStyle.Bottom;
this.panel3.BorderStyle = NBorderStyle.Bottom;
this.panel2.BorderColor = SystemColors.ControlLight;
this.panel3.BorderColor = SystemColors.ControlLight;
this.SourceTextControl.ComparisonState = true;
this.TargetTextControl.ComparisonState = true;
this.SourceTextControl.EnableFolding = false;
this.TargetTextControl.EnableFolding = false;
this.SourceTextControl.ShowGuidelines = true;
this.TargetTextControl.ShowGuidelines = true;
this.SourceTextControl.ActiveTextAreaControl.VScrollBar.ValueChanged += VScrollBar_ValueChanged;
this.TargetTextControl.ActiveTextAreaControl.VScrollBar.ValueChanged += VScrollBar_ValueChanged;
this.SourceTextControl.ActiveTextAreaControl.HScrollBar.ValueChanged += HScrollBar_ValueChanged;
this.TargetTextControl.ActiveTextAreaControl.HScrollBar.ValueChanged += HScrollBar_ValueChanged;
}
protected override void OnFormClosed(FormClosedEventArgs e)
{
timer.Enabled = false;
timer.Dispose();
GC.Collect(0);
GC.SuppressFinalize(this);
base.OnFormClosed(e);
}
private void MainForm_Load(object sender, EventArgs e)
{
this.comboFontName.SelectedIndex = 0;
this.splitContainer1.SplitterDistance = this.splitContainer1.Width / 2;
this.openFile.Filter = "记事本|*.txt|SQL|*.sql|C Sharp|*.cs|HTML|*.html|XML|.xml|CSS|*.css|JS|*.js|Json|*.json|其他格式|*.*";
timer = new System.Windows.Forms.Timer();
timer.Enabled = true;
timer.Interval = 120;
timer.Tick += Timer_Tick;
OnThemeChanged(new EventArgs());
}
private void CurrentLightName(string filetype)
{
HighlightingName = "Text";
switch (filetype.ToUpper())
{
case ".XML":
HighlightingName = "XML";
break;
case ".CONFIG":
HighlightingName = "XML";
break;
case ".CSPROJ":
HighlightingName = "XML";
break;
case ".CS":
HighlightingName = "C#";
break;
case ".JAVA":
HighlightingName = "Java";
break;
case ".JSON":
HighlightingName = "JavaScript";
break;
case ".JS":
HighlightingName = "JavaScript";
break;
case ".SQL":
HighlightingName = "TSQL";
break;
case ".HTML":
HighlightingName = "HTML";
break;
case ".HTM":
HighlightingName = "HTML";
break;
case ".CSHTML":
HighlightingName = "CSHTML";
break;
case ".ASPX":
HighlightingName = "ASP/XHTML";
break;
case ".CSS":
HighlightingName = "CssStyle";
break;
case ".LESS":
HighlightingName = "CssStyle";
break;
case ".TXT":
HighlightingName = "Text";
break;
case ".ADDIN":
HighlightingName = "XML";
break;
}
}
private void SynchronScrollbar()
{
if (ScrollType == 0 &&
lastVScrollBarValue == currentVScrollBarValue)
return;
if (ScrollType == 1 &&
lastHScrollBarValue == currentHScrollBarValue)
return;
if (ScrollType == 0)
{
TargetTextControl.ActiveTextAreaControl.VScrollBar.Value = currentVScrollBarValue;
SourceTextControl.ActiveTextAreaControl.VScrollBar.Value = currentVScrollBarValue;
lastVScrollBarValue = currentVScrollBarValue;
}
if (ScrollType == 1)
{
TargetTextControl.ActiveTextAreaControl.HScrollBar.Value = currentHScrollBarValue;
SourceTextControl.ActiveTextAreaControl.HScrollBar.Value = currentHScrollBarValue;
lastHScrollBarValue = currentHScrollBarValue;
}
TargetTextControl.ActiveTextAreaControl.UpdateVirtualTop();
SourceTextControl.ActiveTextAreaControl.UpdateVirtualTop();
////文件对比模式则等待其它事件都完成保证同步滚动
//Application.DoEvents();
}
private string GetContent(string path)
{
using (System.IO.StreamReader sr = new System.IO.StreamReader(path, Encoding.Default))
{
return sr.ReadToEnd();
}
}
private string TrimEnd(string text,string trim)
{
if (text.EndsWith(trim))
{
text = text.Replace(trim, "\n");
int trimIndex = text.LastIndexOf('\n');
text = text.Substring(0, trimIndex);
}
if(text.StartsWith(trim))
{
text = text.Replace(trim, "\n");
int trimIndex = text.IndexOf('\n');
text = text.Substring(trimIndex);
}
return text;
}
public void OpenFile(string file)
{
openFile.FileName = file;
if (openFile.ShowDialog(this).Equals(DialogResult.OK))
{
if (!string.IsNullOrEmpty(openFile.FileName))
{
string context = GetContent(openFile.FileName);
}
}
}
private void Timer_Tick(object sender, EventArgs e)
{
SynchronScrollbar();
}
private void VScrollBar_ValueChanged(object sender, EventArgs e)
{
ScrollType = 0;
currentVScrollBarValue = ((TextEditorVScrollBar)sender).Value;
}
private void HScrollBar_ValueChanged(object sender, EventArgs e)
{
ScrollType = 1;
currentHScrollBarValue = ((TextEditorHScrollBar)sender).Value;
}
private void SelectOpenFile(object sender, EventArgs e)
{
if (openFile.ShowDialog(this).Equals(DialogResult.OK))
{
if (!string.IsNullOrEmpty(openFile.FileName))
{
string fileType = openFile.FileName;
fileType = fileType.Substring(fileType.LastIndexOf("."));
CurrentLightName(fileType);
string fileName= openFile.FileName;
fileName = fileName.Substring(fileName.LastIndexOf("\\") + 1);
Control control = (Control)sender;
string context = GetContent(openFile.FileName);
switch (control.Name)
{
case "lblFile1":
SourceTextControl.Text = context;
lblSourceFile.Text = "文件一:" + fileName;
tooltip.SetToolTip(lblSourceFile, openFile.FileName);
break;
case "lblFile2":
TargetTextControl.Text = context;
lblTargetFile.Text = "文件二:" + fileName;
tooltip.SetToolTip(lblTargetFile, openFile.FileName);
break;
}
this.SourceTextControl.ActiveTextAreaControl.LineCustomColorsClear();
this.TargetTextControl.ActiveTextAreaControl.LineCustomColorsClear();
this.SourceTextControl.SetHighlighting(currentTheme, HighlightingName);
this.TargetTextControl.SetHighlighting(currentTheme, HighlightingName);
}
}
}
private void comboFontName_SelectedIndexChanged(object sender, EventArgs e)
{
var item = ((NComboBox)sender).SelectedItem;
SourceTextControl.Font = new Font(item + "", 12.0f);
TargetTextControl.Font = new Font(item + "", 12.0f);
}
private void btnApply_Click(object sender, EventArgs e)
{
sourceContentText = SourceTextControl.Text;
targetContentText = TargetTextControl.Text;
DiffPlexViewer(diffBuilder.BuildDiffModel(sourceContentText, targetContentText));
}
private void btnNextDifferent_Click(object sender, EventArgs e)
{
if (deffenrence_lines.Count == 0)
return;
currentIndex = currentIndex + 1;
if (currentIndex > deffenrence_lines.Count - 1)
{
currentIndex = deffenrence_lines.Count - 1;
}
int lineNumber = deffenrence_lines[currentIndex].LineNumber;
SourceTextControl.ActiveTextAreaControl.JumpTo(lineNumber);
TargetTextControl.ActiveTextAreaControl.JumpTo(lineNumber);
}
private void btnPrevDifferent_Click(object sender, EventArgs e)
{
if (deffenrence_lines.Count == 0)
return;
currentIndex = currentIndex - 1;
if (currentIndex <= 0)
{
currentIndex = 0;
}
int lineNumber = deffenrence_lines[currentIndex].LineNumber;
SourceTextControl.ActiveTextAreaControl.JumpTo(lineNumber);
TargetTextControl.ActiveTextAreaControl.JumpTo(lineNumber);
}
private void DiffPlexViewer(SideBySideDiffModel diff)
{
currentIndex = 0;
deffenrence_lines.Clear();
SourceTextControl.ActiveTextAreaControl.LineCustomColorsClear();
TargetTextControl.ActiveTextAreaControl.LineCustomColorsClear();
if (diff != null)
{
StringBuilder sourceStringBuilder = new StringBuilder();
StringBuilder targetStringBuilder = new StringBuilder();
List<DifferenceLine> sourceDifferenceLines = new List<DifferenceLine>();
List<DifferenceLine> targetDifferenceLines = new List<DifferenceLine>();
int lineCount = diff.OldText.Lines.Count;
if (diff.NewText.Lines.Count > lineCount)
{
lineCount = diff.NewText.Lines.Count;
}
for (int i = 0; i < lineCount; i++)
{
ChangeType sourceType = diff.OldText.Lines[i].Type;
ChangeType targetType = diff.NewText.Lines[i].Type;
if (sourceType == ChangeType.Inserted)
{
DifferenceLine lline = new DifferenceLine(i, green, "Inserted");
sourceDifferenceLines.Add(lline);
}
if (sourceType == ChangeType.Modified)
{
DifferenceLine lline = new DifferenceLine(i, red, "Modified");
sourceDifferenceLines.Add(lline);
}
if (sourceType == ChangeType.Deleted)
{
DifferenceLine lline = new DifferenceLine(i, yellow, "Deleted");
sourceDifferenceLines.Add(lline);
}
if (targetType == ChangeType.Inserted)
{
DifferenceLine lline = new DifferenceLine(i, green, "Inserted");
targetDifferenceLines.Add(lline);
}
if (targetType == ChangeType.Modified)
{
DifferenceLine lline = new DifferenceLine(i, red, "Modified");
targetDifferenceLines.Add(lline);
}
if (targetType == ChangeType.Deleted)
{
DifferenceLine lline = new DifferenceLine(i, yellow, "Deleted");
targetDifferenceLines.Add(lline);
}
if (sourceType != ChangeType.Unchanged || targetType != ChangeType.Unchanged)
{
deffenrence_lines.Add(new CodeLine(i));
}
sourceStringBuilder.AppendLine(diff.OldText.Lines[i].Text);
targetStringBuilder.AppendLine(diff.NewText.Lines[i].Text);
}
//SourceTextControl.Text = sourceStringBuilder.ToString().TrimEnd(System.Environment.NewLine.ToCharArray());
//TargetTextControl.Text = targetStringBuilder.ToString().TrimEnd(System.Environment.NewLine.ToCharArray());
SourceTextControl.Text = TrimEnd(sourceStringBuilder.ToString(), System.Environment.NewLine);
TargetTextControl.Text = TrimEnd(targetStringBuilder.ToString(), System.Environment.NewLine);
foreach (var line in sourceDifferenceLines)
{
SourceTextControl.ActiveTextAreaControl.AddLineCustomColor(new CustomLineColor(Color.Empty, line.LineBackgroundColor,line.Type), line.LineNumber);
}
foreach (var line in targetDifferenceLines)
{
TargetTextControl.ActiveTextAreaControl.AddLineCustomColor(new CustomLineColor(Color.Empty, line.LineBackgroundColor, line.Type), line.LineNumber);
}
}
}
public override void OnThemeChanged(EventArgs e)
{
Color foreColor = SystemColors.WindowText;
Color backColor = SystemColors.Control;
Color linkColor = System.Drawing.Color.Blue;
Color toolBackColor = SystemColors.ControlLight;
Color textColor = SystemColors.Window;
Color gridLineColor = SystemColors.ControlLight;
string themeName = AppSettings.EditorSettings.TSQLEditorTheme;
switch (themeName)
{
case "Default":
foreColor = SystemColors.WindowText;
backColor = SystemColors.Control;
linkColor = System.Drawing.Color.Blue;
toolBackColor = Color.FromArgb(246, 248, 250);
textColor = SystemColors.Window;
gridLineColor = SystemColors.ControlLight;
break;
case "Black":
foreColor = Color.FromArgb(240, 240, 240);
backColor = Color.FromArgb(045, 045, 048);
linkColor = Color.FromArgb(051, 153, 153);
toolBackColor = Color.FromArgb(030, 030, 030);
textColor = Color.FromArgb(030, 030, 030);
gridLineColor = SystemColors.ControlDark;
break;
}
panel5.ForeColor = foreColor;
panel5.BackColor = backColor;
SourceTextControl.SetHighlighting(themeName, HighlightingName);
TargetTextControl.SetHighlighting(themeName, HighlightingName);
groupBox1.BackColor = backColor;
groupBox1.GridLineColor = gridLineColor;
panel2.ForeColor = foreColor;
panel3.BackColor = toolBackColor;
panel3.ForeColor = foreColor;
panel2.BackColor = toolBackColor;
lblFile1.ForeColor = linkColor;
lblFile1.BackColor = toolBackColor;
lblFile2.ForeColor = linkColor;
lblFile2.BackColor = toolBackColor;
lblSourceFile.ForeColor = foreColor;
lblSourceFile.BackColor = toolBackColor;
lblTargetFile.ForeColor = foreColor;
lblTargetFile.BackColor = toolBackColor;
comboFontName.ForeColor = foreColor;
comboFontName.BackColor = textColor;
}
}
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

开发助手是一款面向开发人员的辅助助手,它集数据库管理(目前支持sqlserver,sqlite,mysql,postgresql),代码生成(支持从数据库生成实体映射类,数据库操作DAL中间层),数据库文档生成,代码收藏夹(支持C#,SQL,Javascrip,Html,XML,Python语法高亮),富文本编辑,插件管理等功能模块。自2015年到如今,它已经历过4个重大版本的升级,径过不断修复和完善,目前已成为一款堪称得心应手的开发辅助工具。
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/Jason2004/DevelopAssistant.git
git@gitee.com:Jason2004/DevelopAssistant.git
Jason2004
DevelopAssistant
DevelopAssistant
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /