Skip to content

Commit

Permalink
Merge pull request #4 from luxuia/deepsource-fix-fdc67365
Browse files Browse the repository at this point in the history
Use pattern matching to check and perform type conversion
  • Loading branch information
luxuia authored Feb 20, 2023
2 parents 650602d + ba2fb3b commit ed9b40f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
5 changes: 2 additions & 3 deletions ExcelMerge/CellTemplateSelector.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -25,8 +25,7 @@ public CellTemplateSelector(string binder, int columnID, string tag) {
public string tag;

public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container) {
ExcelData rowdata = item as ExcelData;
if (rowdata != null) {
if (item is ExcelData rowdata) {

Brush bg = Brushes.White;
var rowdiff = rowdata.diffstatus;
Expand Down
6 changes: 2 additions & 4 deletions ExcelMerge/DirectoryGridControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
Expand Down Expand Up @@ -79,9 +79,7 @@ private void FileGrid_ScrollChanged(object sender, ScrollChangedEventArgs e) {

private void FileGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) {
if (e.AddedItems.Count > 0) {
// chang selected row
var row = e.AddedItems[0] as ExcelData;
if (row != null) {
if (e.AddedItems[0] is ExcelData row) {
// 新行 NewRowItem 类
DirectoryDifferWindow.instance.OnSelectGridRow(Tag as string, row.rowId);
}
Expand Down
9 changes: 3 additions & 6 deletions ExcelMerge/ExcelGridControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
Expand Down Expand Up @@ -352,9 +352,8 @@ private void ExcelGrid_Drop(object sender, DragEventArgs e) {
private void ExcelGrid_LoadingRow(object sender, DataGridRowEventArgs e) {
var row = e.Row;
var index = row.GetIndex();
var item = row.Item as ExcelData;

if (item != null) {
if (row.Item is ExcelData item) {
row.Header = (item.rowId+1).ToString();
row.Height = item.maxLineCount * 15+5;
}
Expand All @@ -370,9 +369,7 @@ private void ExcelGrid_ScrollChanged(object sender, ScrollChangedEventArgs e) {

private void ExcelGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) {
if (e.AddedItems.Count > 0) {
// chang selected row
var row = e.AddedItems[0] as ExcelData;
if (row != null) {
if (e.AddedItems[0] is ExcelData row) {
// 新行 NewRowItem 类
//MainWindow.instance.OnSelectGridRow(Tag as string, row.rowId);
}
Expand Down
3 changes: 1 addition & 2 deletions ExcelMerge/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,7 @@ private void SortKeyCombo_SelectionChanged(object sender, SelectionChangedEventA
var sheetdata = sheetsDiff[src_sheet];

if (e.AddedItems.Count > 0) {
var sortkey = e.AddedItems[0] as SheetSortKeyCombo;
if (sortkey != null && sheetdata.sortKey != sortkey.ID) {
if (e.AddedItems[0] is SheetSortKeyCombo sortkey && sheetdata.sortKey != sortkey.ID) {
sheetdata.sortKey = sortkey.ID;

ReDiffCurSheet();
Expand Down

0 comments on commit ed9b40f

Please sign in to comment.