cleanup<*>: run vs code cleanup to format codestyle and remove unused references

This commit is contained in:
leo 2021-08-05 15:54:00 +08:00
parent 37559b60d4
commit 2cf7192ec4
41 changed files with 77 additions and 89 deletions

View file

@ -1,6 +1,5 @@
using System;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
namespace SourceGit {

View file

@ -45,7 +45,7 @@ namespace SourceGit.Commands {
var when = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(timestamp).ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
var blameLine = new Models.BlameLine() {
LineNumber = $"{data.Lines.Count+1}",
LineNumber = $"{data.Lines.Count + 1}",
CommitSHA = commit,
Author = author,
Time = when,

View file

@ -101,7 +101,7 @@ namespace SourceGit.Commands {
#endif
return;
}
if (string.IsNullOrEmpty(e.Data)) return;
if (TraitErrorAsOutput) OnReadline(e.Data);
@ -147,7 +147,7 @@ namespace SourceGit.Commands {
start.StandardErrorEncoding = Encoding.UTF8;
if (!string.IsNullOrEmpty(Cwd)) start.WorkingDirectory = Cwd;
var proc = new Process() { StartInfo = start };
try {
proc.Start();
@ -174,6 +174,6 @@ namespace SourceGit.Commands {
/// 调用Exec时的读取函数
/// </summary>
/// <param name="line"></param>
public virtual void OnReadline(string line) {}
public virtual void OnReadline(string line) { }
}
}

View file

@ -117,7 +117,7 @@ namespace SourceGit.Commands {
}
}
decorators.Sort((l, r) => {
decorators.Sort((l, r) => {
if (l.Type != r.Type) {
return (int)l.Type - (int)r.Type;
} else {

View file

@ -4,7 +4,7 @@ namespace SourceGit.Commands {
/// </summary>
public class Config : Command {
public Config() {}
public Config() { }
public Config(string repo) {
Cwd = repo;

View file

@ -71,7 +71,7 @@ namespace SourceGit.Commands {
}
}
}
private void ProcessChanges() {
if (deleted.Any()) {
if (added.Count == deleted.Count) {

View file

@ -12,7 +12,7 @@ namespace SourceGit.Commands {
this.repo = repo;
}
public void Whole() {
public void Whole() {
new Reset(repo, "HEAD", "--hard").Exec();
new Clean(repo).Exec();
}

View file

@ -69,7 +69,7 @@ namespace SourceGit.Commands {
private void OnTick(object o) {
var now = DateTime.Now.ToFileTime();
if (nextFetchPoint > now) return;
Models.Watcher.SetEnabled(cmd.Cwd, false);
cmd.Exec();
nextFetchPoint = DateTime.Now.AddMinutes(10).ToFileTime();

View file

@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
@ -54,7 +51,7 @@ namespace SourceGit.Models {
}
req.GetResponse();
} catch {}
} catch { }
}
}
}

View file

@ -25,7 +25,7 @@ namespace SourceGit.Models {
new MergeTool(5, "Beyond Compare 4", "BComp.exe", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\"", FindBCompare),
new MergeTool(6, "WinMerge", "WinMergeU.exe", "-u -e \"$REMOTE\" \"$LOCAL\" \"$MERGED\"", "-u -e \"$LOCAL\" \"$REMOTE\"", FindWinMerge),
};
public MergeTool(int type, string name, string exec, string cmd, string diffCmd, Func<string> finder) {
Type = type;
Name = name;

View file

@ -43,7 +43,7 @@ namespace SourceGit.Models {
}
}
public Line() {}
public Line() { }
public Line(LineMode mode, string content, string oldLine, string newLine) {
Mode = mode;

View file

@ -2,10 +2,10 @@ using System;
using System.Net;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace SourceGit.Models {

View file

@ -101,7 +101,7 @@ namespace SourceGit.Models {
/// </summary>
/// <param name="commit"></param>
public void NavigateTo(string commit) {
Navigate?.Invoke(commit);
Navigate?.Invoke(commit);
}
/// <summary>
@ -140,7 +140,7 @@ namespace SourceGit.Models {
repoWatcher.Renamed += OnRepositoryChanged;
repoWatcher.Changed += OnRepositoryChanged;
repoWatcher.Deleted += OnRepositoryChanged;
repoWatcher.EnableRaisingEvents = true;
repoWatcher.EnableRaisingEvents = true;
timer = new Timer(Tick, null, 100, 100);
}
@ -176,7 +176,7 @@ namespace SourceGit.Models {
} else if (e.Name.StartsWith("refs\\stash", StringComparison.Ordinal)) {
updateStashes = DateTime.Now.AddSeconds(.5).ToFileTime();
} else if (e.Name.Equals("HEAD", StringComparison.Ordinal) ||
e.Name.StartsWith("refs\\heads\\", StringComparison.Ordinal) ||
e.Name.StartsWith("refs\\heads\\", StringComparison.Ordinal) ||
e.Name.StartsWith("refs\\remotes\\", StringComparison.Ordinal) ||
e.Name.StartsWith("worktrees\\")) {
updateBranch = DateTime.Now.AddSeconds(.5).ToFileTime();

View file

@ -41,9 +41,9 @@ namespace SourceGit.Views.Controls {
/// 邮件属性定义
/// </summary>
public static readonly DependencyProperty EmailProperty = DependencyProperty.Register(
"Email",
"Email",
typeof(string),
typeof(Avatar),
typeof(Avatar),
new PropertyMetadata(null, OnEmailChanged));
/// <summary>

View file

@ -1,6 +1,5 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace SourceGit.Views.Controls {

View file

@ -1,8 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
@ -67,7 +62,7 @@ namespace SourceGit.Views.Controls {
return;
}
if (!mark.IsNewPage) {
if (!mark.IsNewPage) {
if (mark.Color == 0) {
mark.icon.SetResourceReference(Path.FillProperty, "Brush.FG1");
mark.icon.Data = mark.FindResource("Icon.Git") as Geometry;

View file

@ -10,9 +10,9 @@ namespace SourceGit.Views.Controls {
class ChangeStatusIcon : FrameworkElement {
public static readonly DependencyProperty ChangeProperty = DependencyProperty.Register(
"Change",
typeof(Models.Change),
typeof(ChangeStatusIcon),
"Change",
typeof(Models.Change),
typeof(ChangeStatusIcon),
new PropertyMetadata(null, ForceDirty));
public Models.Change Change {
@ -21,9 +21,9 @@ namespace SourceGit.Views.Controls {
}
public static readonly DependencyProperty IsLocalChangeProperty = DependencyProperty.Register(
"IsLocalChange",
typeof(bool),
typeof(ChangeStatusIcon),
"IsLocalChange",
typeof(bool),
typeof(ChangeStatusIcon),
new PropertyMetadata(false, ForceDirty));
public bool IsLocalChange {
@ -76,7 +76,7 @@ namespace SourceGit.Views.Controls {
FlowDirection.LeftToRight,
new Typeface(new FontFamily("Microsoft YaHei UI"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal),
icon.Width * 0.8,
new SolidColorBrush(Color.FromRgb(241,241,241)),
new SolidColorBrush(Color.FromRgb(241, 241, 241)),
VisualTreeHelper.GetDpi(icon).PixelsPerDip);
icon.InvalidateVisual();

View file

@ -269,7 +269,7 @@ namespace SourceGit.Views.Controls {
dc.DrawEllipse(dotFill, PENS[dot.Color], dot.Center, 3, 3);
}
}
private void DrawCurves(DrawingContext dc, double top, double bottom) {
foreach (var line in data.Paths) {
var last = line.Points[0];

View file

@ -84,7 +84,7 @@ namespace SourceGit.Views.Controls {
if (result != IntPtr.Zero) {
IntPtr pathPtr = Marshal.AllocHGlobal(260 * Marshal.SystemDefaultCharSize);
Shell32.SHGetPathFromIDList(result, pathPtr);
if (pathPtr != IntPtr.Zero) {
SelectedPath = Marshal.PtrToStringAuto(pathPtr);
ok = true;

View file

@ -1,7 +1,7 @@
using System.Windows;
using System.Windows.Media;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
namespace SourceGit.Views.Controls {
/// <summary>
@ -15,9 +15,9 @@ namespace SourceGit.Views.Controls {
private static readonly Brush HL_DELETED = new SolidColorBrush(Color.FromArgb(128, 255, 0, 0));
public static readonly DependencyProperty DataProperty = DependencyProperty.Register(
"Data",
"Data",
typeof(Models.TextChanges.Line),
typeof(HighlightableTextBlock),
typeof(HighlightableTextBlock),
new PropertyMetadata(null, OnContentChanged));
public Models.TextChanges.Line Data {

View file

@ -10,9 +10,9 @@ namespace SourceGit.Views.Controls {
public class IconButton : Button {
public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
"Icon",
typeof(Geometry),
typeof(IconButton),
"Icon",
typeof(Geometry),
typeof(IconButton),
new PropertyMetadata(null));
public Geometry Icon {
@ -21,9 +21,9 @@ namespace SourceGit.Views.Controls {
}
public static readonly DependencyProperty HoverBackgroundProperty = DependencyProperty.Register(
"HoverBackground",
typeof(Brush),
typeof(IconButton),
"HoverBackground",
typeof(Brush),
typeof(IconButton),
new PropertyMetadata(Brushes.Transparent));
public Brush HoverBackground {

View file

@ -14,9 +14,9 @@ namespace SourceGit.Views.Controls {
private Path icon = null;
public static readonly DependencyProperty IsAnimatingProperty = DependencyProperty.Register(
"IsAnimating",
typeof(bool),
typeof(Loading),
"IsAnimating",
typeof(bool),
typeof(Loading),
new PropertyMetadata(false, OnIsAnimatingChanged));
public bool IsAnimating {

View file

@ -14,7 +14,7 @@ namespace SourceGit.Views.Controls {
public static readonly DependencyProperty PlaceholderProperty = DependencyProperty.Register(
"Placeholder",
typeof(string),
typeof(string),
typeof(TextEdit),
new PropertyMetadata(""));
@ -24,9 +24,9 @@ namespace SourceGit.Views.Controls {
}
public static readonly DependencyProperty PlaceholderBaselineProperty = DependencyProperty.Register(
"PlaceholderBaseline",
typeof(AlignmentY),
typeof(TextEdit),
"PlaceholderBaseline",
typeof(AlignmentY),
typeof(TextEdit),
new PropertyMetadata(AlignmentY.Center));
public AlignmentY PlaceholderBaseline {

View file

@ -13,9 +13,9 @@ namespace SourceGit.Views.Controls {
/// </summary>
public class Tree : TreeView {
public static readonly DependencyProperty MultiSelectionProperty = DependencyProperty.Register(
"MultiSelection",
typeof(bool),
typeof(Tree),
"MultiSelection",
typeof(bool),
typeof(Tree),
new PropertyMetadata(false));
public bool MultiSelection {
@ -90,7 +90,7 @@ namespace SourceGit.Views.Controls {
protected override void OnItemsSourceChanged(IEnumerable oldValue, IEnumerable newValue) {
base.OnItemsSourceChanged(oldValue, newValue);
if (Selected.Count > 0) {
Selected.Clear();
RaiseEvent(new RoutedEventArgs(SelectionChangedEvent));

View file

@ -9,9 +9,9 @@ namespace SourceGit.Views.Controls {
public class TreeItem : TreeViewItem {
public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register(
"IsChecked",
typeof(bool),
typeof(TreeItem),
"IsChecked",
typeof(bool),
typeof(TreeItem),
new PropertyMetadata(false));
public bool IsChecked {

View file

@ -7,7 +7,7 @@ namespace SourceGit.Views.Popups {
/// 应用补丁
/// </summary>
public partial class Apply : Controls.PopupWidget {
private string repo = null;
private string repo = null;
public string File { get; set; }
public Apply(string repo) {

View file

@ -7,7 +7,7 @@ namespace SourceGit.Views.Popups {
/// </summary>
public partial class Fetch : Controls.PopupWidget {
private string repo = null;
public Fetch(Models.Repository repo, string preferRemote) {
this.repo = repo.Path;
InitializeComponent();

View file

@ -22,7 +22,7 @@ namespace SourceGit.Views.Popups {
name = branch.Substring(repo.GitFlow.Feature.Length);
break;
case Models.GitFlowBranchType.Release:
txtPrefix.Text = App.Text("GitFlow.Release");
txtPrefix.Text = App.Text("GitFlow.Release");
name = branch.Substring(repo.GitFlow.Release.Length);
break;
case Models.GitFlowBranchType.Hotfix:

View file

@ -39,11 +39,11 @@ namespace SourceGit.Views.Popups {
return Task.Run(() => {
Models.Watcher.SetEnabled(repo.Path, false);
var succ = new Commands.Push(
repo.Path,
localBranch.Name,
remoteBranch.Remote,
remoteBranch.Name.Replace(" (new)", ""),
withTags,
repo.Path,
localBranch.Name,
remoteBranch.Remote,
remoteBranch.Name.Replace(" (new)", ""),
withTags,
force,
track,
UpdateProgress).Exec();

View file

@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
namespace SourceGit.Views.Popups {

View file

@ -5,8 +5,8 @@ using System.Windows.Controls;
namespace SourceGit.Views.Validations {
public class CloneDir : ValidationRule {
public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
return Directory.Exists(value as string)
? ValidationResult.ValidResult
return Directory.Exists(value as string)
? ValidationResult.ValidResult
: new ValidationResult(false, App.Text("BadCloneFolder"));
}
}

View file

@ -5,8 +5,8 @@ namespace SourceGit.Views.Validations {
public class CommitMessage : ValidationRule {
public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
var subject = value as string;
return string.IsNullOrWhiteSpace(subject)
? new ValidationResult(false, App.Text("EmptyCommitMessage"))
return string.IsNullOrWhiteSpace(subject)
? new ValidationResult(false, App.Text("EmptyCommitMessage"))
: ValidationResult.ValidResult;
}
}

View file

@ -5,8 +5,8 @@ namespace SourceGit.Views.Validations {
public class Required : ValidationRule {
public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
var path = value as string;
return string.IsNullOrEmpty(path) ?
new ValidationResult(false, App.Text("Required")) :
return string.IsNullOrEmpty(path) ?
new ValidationResult(false, App.Text("Required")) :
ValidationResult.ValidResult;
}
}

View file

@ -337,7 +337,7 @@ namespace SourceGit.Views.Widgets {
var row = sender as DataGridRow;
if (row == null) return;
var change = row.Item as Models.Change;
var change = row.Item as Models.Change;
if (change == null) return;
OpenChangeContextMenu(change);

View file

@ -454,7 +454,7 @@ namespace SourceGit.Views.Widgets {
private void OpenNewBranch(object sender, RoutedEventArgs e) {
var current = repo.Branches.Find(x => x.IsCurrent);
if (current != null) {
if (current != null) {
new Popups.CreateBranch(repo, current).Show();
} else {
Models.Exception.Raise(App.Text("CreateBranch.Idle"));
@ -815,7 +815,7 @@ namespace SourceGit.Views.Widgets {
Clipboard.SetText(branch.Remote + "/" + branch.Name);
e.Handled = true;
};
menu.Items.Add(delete);
menu.Items.Add(new Separator());
menu.Items.Add(createBranch);

View file

@ -170,7 +170,7 @@ namespace SourceGit.Views.Widgets {
if (dummy != seq) return;
loading.Visibility = Visibility.Collapsed;
mask.Visibility = Visibility.Collapsed;
mask.Visibility = Visibility.Collapsed;
toolbarOptions.Visibility = Visibility.Collapsed;
noChange.Visibility = Visibility.Visible;
});
@ -226,7 +226,7 @@ namespace SourceGit.Views.Widgets {
}
foreach (var s in splitters) s.Visibility = Visibility.Visible;
editor.Columns[0].Width = new DataGridLength(lineNumberWidth, DataGridLengthUnitType.Pixel);
editor.Columns[1].Width = new DataGridLength(lineNumberWidth, DataGridLengthUnitType.Pixel);
editor.Columns[2].MinWidth = minWidth;

View file

@ -242,7 +242,7 @@ namespace SourceGit.Views.Widgets {
mask.Visibility = Visibility.Visible;
txtCounter.Text = App.Text("Histories.Selected", selected.Count);
} else {
mask.Visibility = Visibility.Visible;
mask.Visibility = Visibility.Visible;
txtCounter.Text = App.Text("Histories.Guide");
}
}

View file

@ -44,7 +44,7 @@ namespace SourceGit.Views.Widgets {
public void ShowAndStart(Controls.PopupWidget widget) {
if (locked) return;
Show(widget);
Sure(null, null);
Sure(null, null);
}
public void UpdateProgress(string message) {

View file

@ -200,7 +200,7 @@ namespace SourceGit.Views.Widgets {
}
private void OnTreeDragOver(object sender, DragEventArgs e) {
if (!e.Data.GetDataPresent(DataFormats.FileDrop) && !e.Data.GetDataPresent(typeof(Node))) return;
if (!e.Data.GetDataPresent(DataFormats.FileDrop) && !e.Data.GetDataPresent(typeof(Node))) return;
var item = tree.FindItem(e.OriginalSource as DependencyObject);
if (item == null) return;

View file

@ -30,7 +30,7 @@ namespace SourceGit.Views.Widgets {
List<Models.Change> stagedChanges = new List<Models.Change>();
foreach (var c in changes) {
if (c.Index == Models.Change.Status.Modified
if (c.Index == Models.Change.Status.Modified
|| c.Index == Models.Change.Status.Added
|| c.Index == Models.Change.Status.Deleted
|| c.Index == Models.Change.Status.Renamed) {

View file

@ -344,7 +344,7 @@ namespace SourceGit.Views.Widgets {
explore.IsEnabled = File.Exists(path) || Directory.Exists(path);
explore.Header = App.Text("RevealFile");
explore.Click += (o, e) => {
if (node.IsFolder) Process.Start("explorer", path);
if (node.IsFolder) Process.Start("explorer", path);
else Process.Start("explorer", $"/select,{path}");
e.Handled = true;
};