Skip to content

Commit

Permalink
v0.7.0.2 - added Restore UI (profiles and Steam config), added LastPl…
Browse files Browse the repository at this point in the history
…ayed info for games

Depressurizer profile is now backed up automatically like the Steam config.  There are three backup files of both.  Use the Restore menu option to view and restore backups.
  • Loading branch information
EnemyWithin authored and Theo47 committed Feb 23, 2016
1 parent f090f23 commit f46fae7
Show file tree
Hide file tree
Showing 12 changed files with 1,364 additions and 399 deletions.
12 changes: 12 additions & 0 deletions Depressurizer/Depressurizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@
<Compile Include="DlgClose.Designer.cs">
<DependentUpon>DlgClose.cs</DependentUpon>
</Compile>
<Compile Include="DlgRestore.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="DlgRestore.Designer.cs">
<DependentUpon>DlgRestore.cs</DependentUpon>
</Compile>
<Compile Include="GameBanners.cs" />
<Compile Include="Filter.cs" />
<Compile Include="Lib\ExtListView.cs">
Expand Down Expand Up @@ -386,6 +392,12 @@
<EmbeddedResource Include="DlgClose.resx">
<DependentUpon>DlgClose.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="DlgRestore.es.resx">
<DependentUpon>DlgRestore.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="DlgRestore.resx">
<DependentUpon>DlgRestore.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GlobalStrings.es.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>GlobalStrings.es.Designer.cs</LastGenOutput>
Expand Down
132 changes: 132 additions & 0 deletions Depressurizer/DlgRestore.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

118 changes: 118 additions & 0 deletions Depressurizer/DlgRestore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
This file is part of Depressurizer.
Copyright 2011, 2012, 2013 Steve Labbe.
Depressurizer is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Depressurizer is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Depressurizer. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.IO;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Linq;

namespace Depressurizer {
public partial class DlgRestore : Form {

public bool Restored;

public DlgRestore(string path) {
InitializeComponent();

var files = Directory.EnumerateFiles(path, "*.*", SearchOption.TopDirectoryOnly).
Where(s => s.EndsWith(".bak_1") || s.EndsWith(".bak_2") || s.EndsWith(".bak_3"));

foreach (string f in files)
{

cboRestore.Items.Add(new ComboItem(Path.GetFileName(f), f));
}

}

private void cboRestore_SelectedIndexChanged(object sender, EventArgs e)
{

if (File.Exists(((ComboItem)cboRestore.SelectedItem).Path))
{
rtbRestore.Text = "";
string path = ((ComboItem)cboRestore.SelectedItem).Path;
rtbRestore.Text = File.ReadAllText(path);
DateTime dt = File.GetLastWriteTime(path);
long length = new FileInfo(path).Length;
length = length / 1024;
lblDateStamp.Text = dt.ToString();
lblSize.Text = length.ToString() + " KB";
btnRestore.Enabled = true;
}
else
{
btnRestore.Enabled = false;
}
}

private void btnRestore_Click(object sender, EventArgs e)
{
string name = ((ComboItem)cboRestore.SelectedItem).Name;
string message = name.Contains("vdf") ? String.Format(GlobalStrings.DlgRestore_ConfigConfirm, name) : String.Format(GlobalStrings.DlgRestore_ProfileConfirm, name);
DialogResult result = MessageBox.Show(message, GlobalStrings.MainForm_Overwrite, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

if (result == DialogResult.Yes)
{
if (((ComboItem)cboRestore.SelectedItem).Restore())
{
Restored = true;
this.Close();
}
}
}

private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
}

class ComboItem
{
public string Name { get; set; }
public string Path { get; set; }

public ComboItem(string name, string path)
{
Name = name; Path = path;
}

public override string ToString()
{
return Name;
}

public bool Restore()
{
string file = System.IO.Path.GetFileNameWithoutExtension(Path);
string path = System.IO.Path.GetDirectoryName(Path);
file = System.IO.Path.Combine(path, file);
try
{
File.Copy(Path, file, true);
return true;
}
catch
{
return false;
}

}
}
}
Loading

0 comments on commit f46fae7

Please sign in to comment.