Skip to content

Commit

Permalink
1.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
VashBaldeus committed Oct 21, 2021
1 parent bed272c commit 6eb05e8
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 76 deletions.
Binary file modified .vs/Screenshot_Editor/v16/.suo
Binary file not shown.
44 changes: 24 additions & 20 deletions GTAWorld Screenshot Editor/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Management;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Xml.Serialization;
Expand Down Expand Up @@ -231,6 +227,11 @@ public static string ReplaceAt(this string str, int index, string txt, bool spac
return !spaces ? $"{start}{txt}{end}" : $"{start} {txt} {end}";
}

/// <summary>
/// Get day suffix (i.e. 31st, 2nd, 3rd, 4th)
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
public static string GetDaySuffix(this DateTime date)
{
switch (date.Day)
Expand Down Expand Up @@ -451,7 +452,6 @@ public static void ForEach<T>(this ObservableCollection<T> source, List<Action<T
}
}


#region XML

public static class Xml
Expand Down Expand Up @@ -798,29 +798,33 @@ public static bool MetroShow(string text, string caption = "",

#region Check Another Instance

public static class DuplicateProcess
public static class DuplicateProgramInstance
{
public static bool Check()
/// <summary>
/// Checks for open duplicate instances of program,
/// notifies user if so.
/// </summary>
public static void Check(string applicationName = "")
{
#if !DEBUG
var currentProcess = Process.GetCurrentProcess();

var runningProcess = (from process in Process.GetProcesses()

where
process.Id != currentProcess.Id &&
process.ProcessName.Equals(
currentProcess.ProcessName,
StringComparison.Ordinal)
select process).FirstOrDefault();
var runningProcess =
(
from process in Process.GetProcesses()
where process.Id != currentProcess.Id &&
process.ProcessName.Equals(currentProcess.ProcessName, StringComparison.Ordinal)
select process
).FirstOrDefault();

if (runningProcess == null) return false;
if (runningProcess == null) return;

MessageBox.Show(
"Another instance of the application is already running, please close it before opening another.",
"Another instance found", MessageBoxButton.OK, MessageBoxImage.Information);

return true;
$"Another instance of {(string.IsNullOrEmpty(applicationName) ? "the application" : $"'{applicationName}'")} is already running, please close it before opening another.",
"Duplicate instance found...", MessageBoxButton.OK, MessageBoxImage.Information);

Environment.Exit(0);
#endif
}
}

Expand Down
4 changes: 2 additions & 2 deletions GTAWorld Screenshot Editor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.7.0")]
[assembly: AssemblyFileVersion("1.1.7.0")]
[assembly: AssemblyVersion("1.1.8.0")]
[assembly: AssemblyFileVersion("1.1.8.0")]
10 changes: 7 additions & 3 deletions GTAWorld Screenshot Editor/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,9 @@ public System.Windows.Controls.ListView NamesList

#region Private Methods

/// <summary>
/// Debugging method for testing and custom actions.
/// </summary>
private void DebugInit()
{
#if DEBUG
Expand Down Expand Up @@ -936,7 +939,7 @@ private void InitFilters()
{
Selected = true,
Name = "Items",
Filter = @"^You (gave|received) ([\p{L}]+)(?<AMOUNT>[\d.,]+){0,1}(\s){0,1}([\p{L}]+){0,1}(\s){0,1}(?<AMOUNT>[\d.,]+){0,1}\((?<AMOUNT>[\d.,]+)\) (to|from) ([\p{L}]+ [\p{L}]+).$"
Filter = @"^You (gave|received) (.* \((?<AMOUNT>[\d.,]+)\)|(?<AMOUNT>[\d.,]+) .*) (to|from) ([\p{L}]+ [\p{L}]+).$"
},

new Criteria
Expand Down Expand Up @@ -1131,6 +1134,7 @@ private void GenerateText()
//if string missing '.' at end, add it.
if (line.EndsWith("$xxxx")
|| !line.EndsWith(".") && !line.EndsWith("?") && !line.EndsWith("!") && !line.EndsWith("!?") &&
// ReSharper disable once PossibleNullReferenceException
!line.EndsWith("?!") && !Regex.IsMatch(line, ParserSettings.FirstOrDefault(fod => fod.Name.Equals("Action")).Filter))
str = $"{line.TrimEnd(' ')}.";

Expand All @@ -1147,14 +1151,14 @@ private void GenerateText()
// ReSharper disable once PossibleNullReferenceException
if (Regex.IsMatch(str, ParserSettings.FirstOrDefault(fod => fod.Name.Equals("Payments")).Filter))
{
str = Regex.Replace(str, @"(?<SYMBOL>[$]){1}(?<AMOUNT>[\d.,]+)", "$xxxx");
str = Regex.Replace(str, @"(?<SYMBOL>[$]){1}(?<AMOUNT>[\d,]+)", "$xxxx");
}

//replace given/received item amount with '(x)'
// ReSharper disable once PossibleNullReferenceException
if (Regex.IsMatch(str, ParserSettings.FirstOrDefault(fod => fod.Name.Equals("Items")).Filter))
{
str = Regex.Replace(str, @"\((?<AMOUNT>[\d.]+)\)", "(x)");
str = Regex.Replace(str, @"(\((?<AMOUNT>[\d]+)\)|(?<AMOUNT>[\d]+))", "(x)");
}

//check if line contains a player name that was chosen to remove
Expand Down
2 changes: 1 addition & 1 deletion GTAWorld Screenshot Editor/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mah:MetroWindow x:Class="GTAWorld_Screenshot_Editor.MainWindow"
<mah:MetroWindow x:Class="GTAWorld_Screenshot_Editor.Views.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Expand Down
61 changes: 27 additions & 34 deletions GTAWorld Screenshot Editor/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
Expand All @@ -14,11 +13,13 @@
using Microsoft.Win32;
using FileMode = System.IO.FileMode;

namespace GTAWorld_Screenshot_Editor
namespace GTAWorld_Screenshot_Editor.Views
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
// ReSharper disable once UnusedMember.Global
// ReSharper disable once RedundantExtendsListEntry
public partial class MainWindow : MetroWindow
{
private string _version;
Expand All @@ -27,6 +28,8 @@ public MainWindow()
{
InitializeComponent();

DuplicateProgramInstance.Check(this.Title);

CheckForUpdate();
}

Expand All @@ -38,7 +41,7 @@ private void CheckForUpdate()
{
try
{
AutoUpdater.AppTitle = "GTAWorld Screenshot Editor";
AutoUpdater.AppTitle = this.Title;

AutoUpdater.Synchronous = true;

Expand Down Expand Up @@ -71,9 +74,7 @@ private void CheckForUpdate()

AutoUpdater.CheckForUpdateEvent += delegate (UpdateInfoEventArgs args)
{
if (args == null) return;

if (!args.IsUpdateAvailable) return;
if (!(args is { IsUpdateAvailable: true })) return;

try
{
Expand Down Expand Up @@ -135,10 +136,6 @@ private void ScreenshotCanvas_OnMouseMove(object sender, MouseEventArgs e)
return;

dc.SelectedBlock.Margin = new Thickness(point.X, point.Y, 0, 0);

//ScreenshotTextControl.SetValue(Canvas.LeftProperty, point.X);
//ScreenshotTextControl.SetValue(Canvas.TopProperty, point.Y);
//TestButton.Margin = new Thickness(point.X, point.Y, 0, 0);
}
}

Expand All @@ -149,18 +146,20 @@ private void MainWindow_OnDrop(object sender, DragEventArgs e)
if (dc == null)
return;

if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
// Note that you can have more than one file.
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (!e.Data.GetDataPresent(DataFormats.FileDrop)) return;

if (files.Length > 1)
return;
// Note that you can have more than one file.
var files = (string[])e.Data.GetData(DataFormats.FileDrop);

// Assuming you have one file that you care about, pass it off to whatever
// handling code you have defined.
dc.DragDropCommand.Execute(files[0]);
}
if (files == null)
return;

if (files.Length > 1)
return;

// Assuming you have one file that you care about, pass it off to whatever
// handling code you have defined.
dc.DragDropCommand.Execute(files[0]);
}

private void ChatFilterExpander_OnExpanded(object sender, RoutedEventArgs e)
Expand All @@ -172,17 +171,17 @@ private void SaveLocally_OnClick(object sender, RoutedEventArgs e)
try
{
//get source button name
var control = (e.Source as Button).Name;
var control = (e.Source as Button)?.Name;

//picture canvas
var source = ScreenshotCanvas;

//variables for saving size
double Height, renderHeight, Width, renderWidth;
double renderHeight, renderWidth;

//assign sizes
Height = renderHeight = source.RenderSize.Height;
Width = renderWidth = source.RenderSize.Width;
var height = renderHeight = source.RenderSize.Height;
var width = renderWidth = source.RenderSize.Width;

//Specification for target bitmap like width/height pixel etc.
var renderTarget = new RenderTargetBitmap((int)renderWidth, (int)renderHeight, 96, 96, PixelFormats.Pbgra32);
Expand All @@ -195,7 +194,7 @@ private void SaveLocally_OnClick(object sender, RoutedEventArgs e)
using (var drawingContext = drawingVisual.RenderOpen())
{
//draws image of element
drawingContext.DrawRectangle(visualBrush, null, new Rect(new Point(0, 0), new Point(Width, Height)));
drawingContext.DrawRectangle(visualBrush, null, new Rect(new Point(0, 0), new Point(width, height)));
}

//renders image
Expand Down Expand Up @@ -228,10 +227,9 @@ private void SaveLocally_OnClick(object sender, RoutedEventArgs e)
return;

//save file locally
using (var stream = new FileStream(saveDialog.FileName, FileMode.Create, FileAccess.Write))
{
encoder.Save(stream);
}
using var stream = new FileStream(saveDialog.FileName, FileMode.Create, FileAccess.Write);

encoder.Save(stream);
}
}
catch (Exception ex)
Expand Down Expand Up @@ -270,10 +268,5 @@ private void MainWindow_OnClosed(object sender, EventArgs e)
var dir = new DirectoryInfo(dirPath);
dir.Delete(true);
}

private void AddNameToRemove_OnClick(object sender, RoutedEventArgs e)
{
NamesToRemoveList.SelectedIndex = -1;
}
}
}
Binary file not shown.
10 changes: 5 additions & 5 deletions GTAWorld Screenshot Editor/obj/Debug/Views/MainWindow.g.i.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma checksum "..\..\..\Views\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "B98FD79ED194A8A417CEF25A64FA79A5823A83E8904FD39E8AEAFD8A20910DAA"
#pragma checksum "..\..\..\Views\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "B4616A8DEDCEB6B660530BEDF54E50CC91330BCB665D9794E54806DD424A295F"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
Expand Down Expand Up @@ -65,7 +65,7 @@
using Xceed.Wpf.Toolkit.Zoombox;


namespace GTAWorld_Screenshot_Editor {
namespace GTAWorld_Screenshot_Editor.Views {


/// <summary>
Expand Down Expand Up @@ -258,19 +258,19 @@ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object
case 1:

#line 13 "..\..\..\Views\MainWindow.xaml"
((GTAWorld_Screenshot_Editor.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.MainWindow_OnLoaded);
((GTAWorld_Screenshot_Editor.Views.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.MainWindow_OnLoaded);

#line default
#line hidden

#line 16 "..\..\..\Views\MainWindow.xaml"
((GTAWorld_Screenshot_Editor.MainWindow)(target)).Drop += new System.Windows.DragEventHandler(this.MainWindow_OnDrop);
((GTAWorld_Screenshot_Editor.Views.MainWindow)(target)).Drop += new System.Windows.DragEventHandler(this.MainWindow_OnDrop);

#line default
#line hidden

#line 17 "..\..\..\Views\MainWindow.xaml"
((GTAWorld_Screenshot_Editor.MainWindow)(target)).Closed += new System.EventHandler(this.MainWindow_OnClosed);
((GTAWorld_Screenshot_Editor.Views.MainWindow)(target)).Closed += new System.EventHandler(this.MainWindow_OnClosed);

#line default
#line hidden
Expand Down
Binary file modified GTAWorld Screenshot Editor/obj/Release/App.baml
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ TRACE
C:\Users\xcast\Documents\GitHub\Screenshot_Editor\GTAWorld Screenshot Editor\App.xaml
11892971807

201112420633
2174687102
278-1408080405
Views\MainWindow.xaml;

Expand Down
Binary file modified GTAWorld Screenshot Editor/obj/Release/Views/MainWindow.baml
Binary file not shown.
10 changes: 5 additions & 5 deletions GTAWorld Screenshot Editor/obj/Release/Views/MainWindow.g.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma checksum "..\..\..\Views\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "B98FD79ED194A8A417CEF25A64FA79A5823A83E8904FD39E8AEAFD8A20910DAA"
#pragma checksum "..\..\..\Views\MainWindow.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "B4616A8DEDCEB6B660530BEDF54E50CC91330BCB665D9794E54806DD424A295F"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
Expand Down Expand Up @@ -65,7 +65,7 @@
using Xceed.Wpf.Toolkit.Zoombox;


namespace GTAWorld_Screenshot_Editor {
namespace GTAWorld_Screenshot_Editor.Views {


/// <summary>
Expand Down Expand Up @@ -258,19 +258,19 @@ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object
case 1:

#line 13 "..\..\..\Views\MainWindow.xaml"
((GTAWorld_Screenshot_Editor.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.MainWindow_OnLoaded);
((GTAWorld_Screenshot_Editor.Views.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.MainWindow_OnLoaded);

#line default
#line hidden

#line 16 "..\..\..\Views\MainWindow.xaml"
((GTAWorld_Screenshot_Editor.MainWindow)(target)).Drop += new System.Windows.DragEventHandler(this.MainWindow_OnDrop);
((GTAWorld_Screenshot_Editor.Views.MainWindow)(target)).Drop += new System.Windows.DragEventHandler(this.MainWindow_OnDrop);

#line default
#line hidden

#line 17 "..\..\..\Views\MainWindow.xaml"
((GTAWorld_Screenshot_Editor.MainWindow)(target)).Closed += new System.EventHandler(this.MainWindow_OnClosed);
((GTAWorld_Screenshot_Editor.Views.MainWindow)(target)).Closed += new System.EventHandler(this.MainWindow_OnClosed);

#line default
#line hidden
Expand Down
Loading

0 comments on commit 6eb05e8

Please sign in to comment.