Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full customizability on column/row dimension constraints #30

Merged
merged 2 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rowsSharp/Model/Preferences/ColumnStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public class ColumnStyle
/// <summary>
/// The minimum width of the column
/// </summary>
public double MinWidth { get; set; } = 32;
public double MinWidth { get; set; }

/// <summary>
/// The default maximum width of the column
/// </summary>
public double MaxWidth { get; set; } = double.PositiveInfinity;
public double MaxWidth { get; set; }

/// <summary>
/// The template of the column.
Expand Down
21 changes: 21 additions & 0 deletions rowsSharp/Model/Preferences/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public class Editor
/// </summary>
public double DefaultRowHeight { get; set; } = 33;

/// <summary>
/// Fallback minimum height of a row.
/// </summary>
public double DefaultMinRowHeight { get; set; }

/// <summary>
/// Fallback width of a column.
/// </summary>
Expand All @@ -54,6 +59,22 @@ public class Editor
/// </remarks>
public double DefaultColumnWidth { get; set; } = 50;

/// <summary>
/// Fallback minimum width of a column.
/// </summary>
/// <remarks>
/// ColumnStyles can override this value on a column-to-column basis.
/// </remarks>
public double DefaultMinColumnWidth { get; set; } = 25;

/// <summary>
/// Fallback maximum width of a column.
/// </summary>
/// <remarks>
/// ColumnStyles can override this value on a column-to-column basis.
/// </remarks>
public double DefaultMaxColumnWidth { get; set; }

/// <summary>
/// Whether scrolling only occurs after the scrollbar has finished moving.
/// This saves computing resources at an expense of less responsiveness.
Expand Down
5 changes: 4 additions & 1 deletion rowsSharp/Userdata/Configurations/Configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
"IsAutosaveEnabled": true,
"AutosaveInterval": 60000,
"FrozenColumn": 0,
"DefaultRowHeight": 33,
"DefaultMinRowHeight": 28,
"DefaultRowHeight": 34,
"DefaultMinColumnWidth": 16,
"DefaultMaxColumnWidth": 256,
"DefaultColumnWidth": 128,
"IsDeferredScrollingEnabled": false,
"ColumnStyles": [
Expand Down
4 changes: 2 additions & 2 deletions rowsSharp/View/DataGridColumn/DataGridColumnFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ internal static DataGridColumn CreateColumn(int columnIndex, ColumnStyle style,
column.Binding = binding;
column.Header = style.Column;
column.Width = style.Width > 0 ? style.Width : column.Width;
column.MinWidth = style.MinWidth;
column.MaxWidth = style.MaxWidth;
if (style.MinWidth > 0) { column.MinWidth = style.MinWidth; }
if (style.MaxWidth > 0) { column.MaxWidth = style.MaxWidth; }
column.CellStyle = ColumnStyleHelper.GetConditionalFormatting(style.ConditionalFormatting);

return column;
Expand Down
9 changes: 8 additions & 1 deletion rowsSharp/View/Editor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,19 @@
VerticalGridLinesBrush="{StaticResource Rows.DataGrid.Grid.Vertical}"
HorizontalGridLinesBrush="{StaticResource Rows.DataGrid.Grid.Horizontal}"
ScrollViewer.IsDeferredScrollingEnabled="{Binding Preferences.Editor.IsDeferredScrollingEnabled, Mode=OneWay}"
MinColumnWidth="{Binding Preferences.Editor.DefaultMinColumnWidth, Mode=OneTime}"
MaxColumnWidth="{Binding Preferences.Editor.DefaultMaxColumnWidth, Mode=OneTime}"
MinRowHeight="{Binding Preferences.Editor.DefaultMinRowHeight, Mode=OneTime}"
ColumnWidth="{Binding Preferences.Editor.DefaultColumnWidth, Mode=OneTime}" RowHeaderWidth="8"
RowHeight="{Binding Preferences.Editor.DefaultRowHeight, Mode=OneTime}"
CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="{Binding Preferences.Editor.CanEdit, Converter={StaticResource InvertBooleanConverter}, Mode=OneWay}"
SelectionMode="Extended" SelectionUnit="CellOrRowHeader"
FrozenColumnCount="{Binding Preferences.Editor.FrozenColumn, Mode=OneTime}"
CanUserReorderColumns="{Binding Preferences.Editor.CanEdit, Mode=OneWay}"
EnableColumnVirtualization="True" EnableRowVirtualization="True" VirtualizingPanel.ScrollUnit="Pixel">
EnableColumnVirtualization="True" EnableRowVirtualization="True"
VirtualizingPanel.VirtualizationMode="Recycling"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.ScrollUnit="Pixel">
<DataGrid.ContextMenu>
<ContextMenu DataContext="{Binding PlacementTarget, RelativeSource={x:Static RelativeSource.Self}}">
<MenuItem Command="{Binding DataContext.CopyPreview, Mode=OneTime}" Header="Copy image" InputGestureText="Ctrl+Shift+C"/>
Expand Down