Skip to content

Commit

Permalink
Merge pull request #8 from haruki-taka8/working-branch-23.06
Browse files Browse the repository at this point in the history
23.06
  • Loading branch information
haruki-taka8 authored Jun 7, 2023
2 parents edda827 + d51e4d0 commit 03ef2f7
Show file tree
Hide file tree
Showing 88 changed files with 3,163 additions and 2,327 deletions.
120 changes: 30 additions & 90 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,57 +1,10 @@
[*.cs]
[*.{cs,vb}]

# CS8602: Dereference of a possibly null reference.
dotnet_diagnostic.CS8602.severity = suggestion
csharp_indent_labels = one_less_than_current
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = file_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_throw_expression = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
csharp_prefer_static_local_function = true:suggestion
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
csharp_style_conditional_delegate_call = true:suggestion
csharp_style_prefer_parameter_null_checking = true:suggestion
csharp_style_prefer_switch_expression = true:suggestion
csharp_style_prefer_pattern_matching = true:silent
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_prefer_not_pattern = true:suggestion
csharp_style_prefer_extended_property_pattern = true:suggestion
csharp_style_var_for_built_in_types = false:silent
csharp_style_var_when_type_is_apparent = false:silent
csharp_style_var_elsewhere = false:silent
csharp_style_prefer_top_level_statements = true:silent
dotnet_diagnostic.IDE0005.severity = suggestion
dotnet_diagnostic.IDE0063.severity = warning
dotnet_diagnostic.IDE0065.severity = warning
dotnet_diagnostic.CA1001.severity = warning
dotnet_diagnostic.CA1309.severity = silent
dotnet_diagnostic.CA1805.severity = warning
dotnet_diagnostic.IDE0036.severity = suggestion
dotnet_diagnostic.IDE0060.severity = warning
# IDE0017: Simplify object initialization
dotnet_diagnostic.IDE0017.severity = silent

# CA1416: Validate platform compatibility
dotnet_diagnostic.CA1416.severity = none

[*.{cs,vb}]
#### Naming styles ####
Expand All @@ -66,10 +19,6 @@ dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
Expand All @@ -80,10 +29,6 @@ dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
Expand All @@ -95,15 +40,6 @@ dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
Expand All @@ -119,23 +55,27 @@ dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_readonly_field = true:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_predefined_type_for_member_access = true:silent
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
dotnet_style_allow_multiple_blank_lines_experimental = true:silent
dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
dotnet_code_quality_unused_parameters = all:suggestion
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
dotnet_style_qualification_for_field = false:silent
dotnet_style_qualification_for_property = false:silent
dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_event = false:silent
dotnet_diagnostic.CA1000.severity = suggestion
dotnet_diagnostic.CA1036.severity = error
dotnet_diagnostic.CA1707.severity = suggestion
dotnet_diagnostic.CA1711.severity = suggestion
dotnet_diagnostic.CA1710.severity = warning
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf

[*.cs]
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_throw_expression = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_indent_labels = flush_left
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

# User-specific files
Internals*/

*.rsuser
*.suo
*.user
Expand Down
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
## 📌 rowsSharp
C#/WPF-based CSV filtering and editing tool. Rewritten from [Rows](https://github.com/haruki-taka8/rows).
C#/WPF-based CSV filtering and editing tool. Rewritten and enhanced from [Rows](https://github.com/haruki-taka8/rows).
<br><br>

## ✔️ Features

**Filtering**
* Display user-friendly aliases instead of raw data
* Display a preview image based on the selected row
* Conditional formatting support
* Regular expressions support
* Display an image based on the selected row
* Conditional formatting
* Regular expressions
<br>

**Editing**
* Add/remove rows
* Add/edit/remove rows and columns
* Add rows with a template
* Change existing rows
* Unlimited undo & redo
* Shortcut keys
<br>

## 🌎 Using
* [CsvHelper](https://joshclose.github.io/CsvHelper/)
* [Microsoft.Xaml.Behaviors.Wpf](https://github.com/microsoft/XamlBehaviorsWpf)
* [NLog](https://nlog-project.org/)
## 🌎 Dependencies
* [CsvHelper](https://joshclose.github.io/CsvHelper/) ([License](https://github.com/JoshClose/CsvHelper/blob/master/LICENSE.txt))
* [Material Symbols](https://github.com/marella/material-symbols/) ([License](https://github.com/marella/material-symbols/blob/main/LICENSE))
* Font was converted to `.otf` for WPF compatibility
* Font content is rotated and/or flipped inside the UI
* [Microsoft.Xaml.Behaviors.Wpf](https://github.com/microsoft/XamlBehaviorsWpf) ([License](https://github.com/microsoft/XamlBehaviorsWpf/blob/master/LICENSE))
* [NLog](https://nlog-project.org/) ([License](https://github.com/NLog/NLog/blob/dev/LICENSE.txt))
<br>

## 🧪 Building
Official binaries are built with Visual Studio 2022 and .NET 6, using the _release_ configuration.
Official binaries are built with Visual Studio 2022 and .NET 6 using the _release_ configuration.
18 changes: 15 additions & 3 deletions rowsSharp/App.xaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
<Application x:Class="rowsSharp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Internal/View/MainWindow.xaml">
StartupUri="View/MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<!-- Font -->
<FontFamily x:Key="Symbol">pack://application,,,/View/Font/#Material Symbols Outlined 48pt</FontFamily>

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/rowsSharp;component/Internal/View/Light.xaml"/>
<ResourceDictionary Source="/rowsSharp;component/Internal/View/Common.xaml"/>
<!-- Fallback Theme -->
<ResourceDictionary Source="/rowsSharp;component/View/Light.xaml"/>

<!-- Element Styling -->
<ResourceDictionary Source="/rowsSharp;component/View/ResourceDictionary/Button.xaml"/>
<ResourceDictionary Source="/rowsSharp;component/View/ResourceDictionary/DataGrid.xaml"/>
<ResourceDictionary Source="/rowsSharp;component/View/ResourceDictionary/OptionMark.xaml"/>
<ResourceDictionary Source="/rowsSharp;component/View/ResourceDictionary/Scrollbar.xaml"/>
<ResourceDictionary Source="/rowsSharp;component/View/ResourceDictionary/TextBlock.xaml"/>
<ResourceDictionary Source="/rowsSharp;component/View/ResourceDictionary/TextBox.xaml"/>
<ResourceDictionary Source="/rowsSharp;component/View/ResourceDictionary/ToggleButton.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Expand Down
8 changes: 3 additions & 5 deletions rowsSharp/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ namespace rowsSharp;

public partial class App : Application
{
internal static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
internal static NLog.Logger Logger => NLog.LogManager.GetCurrentClassLogger();

private App()
{
AppDomain.CurrentDomain.UnhandledException += new(Handler);
AppDomain.CurrentDomain.UnhandledException += Handler;
}

private void Handler(object sender, UnhandledExceptionEventArgs args)
{
var exception = (Exception)args.ExceptionObject;

MessageBox.Show(
"RowsSharp will close due to the following exception:\n\n" + exception.Message + "\n\n" + exception.StackTrace,
"RowsSharp will close due to the following error:\n\n" + args.ExceptionObject,
"RowsSharp",
MessageBoxButton.OK,
MessageBoxImage.Error
Expand Down
2 changes: 1 addition & 1 deletion rowsSharp/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
[assembly: AssemblyProduct("RowsSharp")]
[assembly: AssemblyCompany("haruki-taka8")]
[assembly: AssemblyCopyright("MIT License, see LICENSE file")]
[assembly: AssemblyVersion("22.12.*")]
[assembly: AssemblyVersion("23.06.*")]
37 changes: 24 additions & 13 deletions rowsSharp/Internal/Command.cs → rowsSharp/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,43 @@ public event EventHandler? CanExecuteChanged
}
}

public class DelegateCommand<T> : ICommand where T : class
/*
* The following constructors deliberately ALLOW the use of value type,
* despite Microsoft.Practices.Prism.Commands doing otherwise.
*
* It can be safely assumed that CanExecute(null) will not cause any
* issues.
*/

public class DelegateCommand<T> : ICommand
{
private readonly Predicate<T> _canExecute;
private readonly Func<T, bool> _canExecute;
private readonly Action<T> _execute;

internal DelegateCommand(Action<T> execute) : this(execute, (T obj) => true) { }

internal DelegateCommand(Action<T> execute, Predicate<T> canExecute)
internal DelegateCommand(Action<T> execute) : this(execute, (T parameter) => true) { }
internal DelegateCommand(Action<T> execute, Func<T, bool> canExecute)
{
_execute = execute;
_canExecute = canExecute;
}

public bool CanExecute(object? parameter) =>
_canExecute is not null
&& parameter is not null
&& _canExecute((T)parameter);
public bool CanExecute(object? parameter)
{
return parameter is T type
&& _canExecute.Invoke(type);
}

public void Execute(object? parameter)
{
if (parameter is not null) { _execute((T)parameter); }
if (parameter is T type)
{
_execute(type);
}
}

public event EventHandler? CanExecuteChanged;
public void RaiseCanExecuteChanged()
public event EventHandler? CanExecuteChanged
{
if (CanExecuteChanged is not null) { CanExecuteChanged(this, EventArgs.Empty); }
add => CommandManager.RequerySuggested += value;
remove => CommandManager.RequerySuggested -= value;
}
}
14 changes: 14 additions & 0 deletions rowsSharp/Domain/BaseDir.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace rowsSharp.Domain;

internal static class BaseDir
{
private const string Metavariable = "$baseDir";
private static readonly string BasePath = Environment.CurrentDirectory + "/Userdata/";

internal static string Expand(string path)
{
return path.Replace(Metavariable, BasePath);
}
}
53 changes: 53 additions & 0 deletions rowsSharp/Domain/Cell.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Controls;

namespace rowsSharp.Domain;

internal static class Cell
{
private static IEnumerable<DataGridCellInfo> WhereValid(this IList<DataGridCellInfo> cells)
{
return cells.Where(x => x.IsValid);
}

// Rows
internal static IEnumerable<ObservableCollection<string?>> Rows(this IList<DataGridCellInfo> cells)
{
return cells.WhereValid()
.Select(x => (ObservableCollection<string?>)x.Item)
.Distinct();
}

internal static IEnumerable<int> RowIndices(this IList<DataGridCellInfo> cells, IList<ObservableCollection<string?>> records)
{
return cells.Rows()
.Select(x => records.IndexOf(x));
}

// Columns
internal static IEnumerable<string> Columns(this IList<DataGridCellInfo> cells)
{
return cells.WhereValid()
.Select(x => (string)x.Column.Header)
.Distinct();
}

internal static IEnumerable<int> ColumnIndices(this IList<DataGridCellInfo> cells, IList<string> headers)
{
return cells.Columns()
.Select(x => headers.IndexOf(x));
}

// Cell
internal static int RowIndex(this DataGridCellInfo cell, IList<ObservableCollection<string?>> records)
{
return records.IndexOf((ObservableCollection<string?>)cell.Item);
}

internal static int ColumnIndex(this DataGridCellInfo cell, IList<string> headers)
{
return headers.IndexOf((string)cell.Column.Header);
}
}
Loading

0 comments on commit 03ef2f7

Please sign in to comment.