Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
TimeTravelPenguin committed Dec 22, 2019
1 parent a16077f commit 3705f1e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
34 changes: 13 additions & 21 deletions Project/EveryoneIsJohnTracker/ViewModels/ExportChartViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// File Name: ExportChartViewModel.cs
//
// Current Data:
// 2019-12-22 11:16 AM
// 2019-12-22 12:05 PM
//
// Creation Date:
// 2019-12-22 11:05 AM
Expand Down Expand Up @@ -38,8 +38,6 @@ internal class ExportChartViewModel : PropertyChangedBase
{
private BitmapImage _bitmapImage = new BitmapImage();
private ChartModel _chartModel = new ChartModel();
private double _defaultHeight = 419;
private double _defaultWidth = 448;
private string _hexColourValue = "#FFFFFF";
private double _imageZoom = 1;

Expand All @@ -50,6 +48,8 @@ internal class ExportChartViewModel : PropertyChangedBase
private int _renderWidth = 1080;
private bool _saveEnabled;
private double _windowHeight = 419;
private double _windowMinHeight = 419;
private double _windowMinWidth = 448;
private double _windowWidth = 448;

public bool SaveEnabled
Expand All @@ -73,20 +73,20 @@ public double WindowWidth
public double ImageZoom
{
get => _imageZoom;
set => SetValue(ref _imageZoom, value);
private set => SetValue(ref _imageZoom, value);
}

public BitmapImage BitmapImage
{
get => _bitmapImage;
set
private set
{
ImageZoom = 1;
SetValue(ref _bitmapImage, value);
}
}

public ChartModel ChartModel
private ChartModel ChartModel
{
get => _chartModel;
set => SetValue(ref _chartModel, value);
Expand Down Expand Up @@ -123,16 +123,16 @@ public string OutputPath
public ActionCommand CommandSaveImage { get; }
public ActionCommand CommandMouseWheel { get; }

public double DefaultWidth
public double WindowMinWidth
{
get => _defaultWidth;
set => SetValue(ref _defaultWidth, value);
get => _windowMinWidth;
set => SetValue(ref _windowMinWidth, value);
}

public double DefaultHeight
public double WindowMinHeight
{
get => _defaultHeight;
set => SetValue(ref _defaultHeight, value);
get => _windowMinHeight;
set => SetValue(ref _windowMinHeight, value);
}

public ExportChartViewModel()
Expand Down Expand Up @@ -160,7 +160,7 @@ private void MouseWheel(object obj)
? Math.Min(_imageZoom + 0.1, 4)
: Math.Max(_imageZoom - 0.1, 0.01);

ImageZoom = zoom.LimitToRange(0.01, 4);
ImageZoom = zoom.LimitToRange(0.1, 4);

if (_imageZoom.IsInfinity())
{
Expand Down Expand Up @@ -218,8 +218,6 @@ private Chart GenerateChart()
// TODO: Make process run on own thread
private void RenderImage()
{
ResetWindowSize();

// Creates a new chart
var newChart = GenerateChart();

Expand Down Expand Up @@ -256,12 +254,6 @@ private void RenderImage()
SaveEnabled = true;
}

private void ResetWindowSize()
{
WindowWidth = DefaultWidth;
WindowHeight = DefaultHeight;
}

private void ChangeOutput()
{
if (BitmapImage is null)
Expand Down
15 changes: 9 additions & 6 deletions Project/EveryoneIsJohnTracker/Views/ExportChartView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
Icon="/EveryoneIsJohnTracker;component/Images/Icon.ico"
Title="Export Chart"
SizeToContent="WidthAndHeight"
ResizeMode="CanResize"
MinWidth="{Binding DefaultWidth}"
MinHeight="{Binding DefaultHeight}">
ResizeMode="NoResize"
Width="{Binding WindowWidth}"
Height="{Binding WindowHeight}"
MinWidth="{Binding WindowMinWidth}"
MinHeight="{Binding WindowMinHeight}"
MaxWidth="1280"
MaxHeight="720">

<Window.DataContext>
<viewModels:ExportChartViewModel />
Expand Down Expand Up @@ -173,14 +177,13 @@
</i:Interaction.Triggers>

<Image.LayoutTransform>
<ScaleTransform ScaleX="{Binding ImageZoom, Mode=OneWay}"
ScaleY="{Binding ImageZoom, Mode=OneWay}" />
<ScaleTransform ScaleX="{Binding ImageZoom}"
ScaleY="{Binding ImageZoom}" />
</Image.LayoutTransform>

</Image>

</ScrollViewer>

</Grid>
</Grid>
</Window>

0 comments on commit 3705f1e

Please sign in to comment.