Skip to content

Commit

Permalink
v1.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriano committed Oct 17, 2019
1 parent 38be676 commit 2361c5c
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 62 deletions.
7 changes: 5 additions & 2 deletions src/AppWins/PetOptionsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ private void ForegroundWindowToggle_Toggled(object sender, RoutedEventArgs e)

private void VolumeSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
{
App.MyData.SetVolume(volumeSlider.Value);
volumeSlider.Header = (volumeSlider.Value * 100).ToString() + " %";
if ((int)(e.OldValue * 100) != (int)(e.NewValue * 100))
{
App.MyData.SetVolume(volumeSlider.Value);
volumeSlider.Header = ((int)(volumeSlider.Value * 100)).ToString() + " %";
}
}
}
}
87 changes: 62 additions & 25 deletions src/LocalData/Class1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class PetUpdate
}
public class Settings
{
public string Xml { get; set; } = "";
public double Volume { get; set; } = 0.3;
public bool WinForeGround { get; set; } = false;
public int AutostartPets { get; set; } = 1;
Expand All @@ -36,8 +35,10 @@ public class LocalData
static string Icon = "";
static bool Developer = false;
static string DeveloperPets = "";
static string Xml = "";

private FileSystemWatcher watcher = null;
private FileSystemWatcher watcherXml = null;
private FileSystemWatcher watcherJson = null;

private static readonly String GITHUB_FOLDER = "https://raw.githubusercontent.com/Adrianotiger/desktopPet/master";
public static readonly String GITHUB_PETDOCS = "https://adrianotiger.github.io/desktopPet/Pets/";
Expand All @@ -53,26 +54,31 @@ public LocalData(string StorageFolder, string exeFile)
if (!Directory.Exists(LocalFolder)) Directory.CreateDirectory(LocalFolder);
if (LocalSettings == null)
{
try
{
LocalSettings = JsonConvert.DeserializeObject<Settings>(File.ReadAllText(LocalFolder + "\\_settings_.json"));
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
if (LocalSettings == null)
{
LocalSettings = new Settings();
FirstBoot = true;
}
LoadSettings();

LoadXML();
LoadImages();
LoadIcon();
}
}

public void LoadSettings()
{
try
{
LocalSettings = JsonConvert.DeserializeObject<Settings>(File.ReadAllText(LocalFolder + "\\_settings_.json"));
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
if (LocalSettings == null)
{
LocalSettings = new Settings();
FirstBoot = true;
}
}

public bool IsFirstBoot()
{
return FirstBoot;
Expand Down Expand Up @@ -136,9 +142,9 @@ public int GetAutoStartPets()

public void SetXml(string newXml, string folder)
{
if (LocalSettings.Xml != newXml)
if (Xml != newXml)
{
LocalSettings.Xml = newXml;
Xml = newXml;

var buffer = Encoding.UTF8.GetBytes(newXml);
File.Delete(LocalFolder + "\\animations.xml");
Expand All @@ -159,7 +165,7 @@ public string GetCurrentPet()

public string GetXml()
{
return LocalSettings.Xml;
return Xml;
}

public void LoadXML()
Expand All @@ -170,13 +176,13 @@ public void LoadXML()
var fs = File.Create(LocalFolder + "\\animations.xml");
fs.Close();
}
LocalSettings.Xml = "";
Xml = "";
var f = File.OpenRead(LocalFolder + "\\animations.xml");
int bytesRead;
do
{
bytesRead = f.Read(buffer, 0, 1024 * 64);
LocalSettings.Xml += Encoding.UTF8.GetString(buffer, 0, bytesRead);
Xml += Encoding.UTF8.GetString(buffer, 0, bytesRead);
} while (bytesRead > 0);
f.Close();
}
Expand Down Expand Up @@ -297,9 +303,9 @@ public string GetPetXML(string petName)

public void ListenOnXMLChanged(MyFunction f)
{
if (watcher == null)
if (watcherXml == null)
{
watcher = new FileSystemWatcher
watcherXml = new FileSystemWatcher
{
Path = LocalFolder,
/* Watch for changes in LastAccess and LastWrite times, and
Expand All @@ -311,14 +317,40 @@ the renaming of files or directories. */
}
else
{
watcher.EnableRaisingEvents = false;
watcherXml.EnableRaisingEvents = false;
}

// Add event handlers.
watcherXml.Changed += new FileSystemEventHandler(f);

// Begin watching.
watcherXml.EnableRaisingEvents = true;
}

public void ListenOnOptionsChanged(MyFunction f)
{
if (watcherJson == null)
{
watcherJson = new FileSystemWatcher
{
Path = LocalFolder,
/* Watch for changes in LastAccess and LastWrite times, and
the renaming of files or directories. */
NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName,
// Only watch text files.
Filter = "_settings_.json"
};
}
else
{
watcherJson.EnableRaisingEvents = false;
}

// Add event handlers.
watcher.Changed += new FileSystemEventHandler(f);
watcherJson.Changed += new FileSystemEventHandler(f);

// Begin watching.
watcher.EnableRaisingEvents = true;
watcherJson.EnableRaisingEvents = true;
}

public void SetDeveloper(bool isDev)
Expand Down Expand Up @@ -369,13 +401,18 @@ private void SaveSettings()
{
try
{
if (watcherJson != null) watcherJson.EnableRaisingEvents = false;
var output = JsonConvert.SerializeObject(LocalSettings);
File.WriteAllText(LocalFolder + "\\_settings_.json", output);
}
catch(Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
finally
{
if (watcherJson != null) watcherJson.EnableRaisingEvents = true;
}
}
}

Expand Down
28 changes: 19 additions & 9 deletions src/Portable/LocalData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,27 @@ public LocalData()
AppConfiguration = ConfigurationManager.OpenMappedExeConfiguration(
new ExeConfigurationFileMap { ExeConfigFilename = "DesktopPet.config" }, ConfigurationUserLevel.None);
}
var settings = AppConfiguration.AppSettings.Settings;
foreach (SettingsProperty currentProperty in Properties.Settings.Default.Properties)
{
if (AppConfiguration.AppSettings.Settings[currentProperty.Name] == null)
{
AppConfiguration.AppSettings.Settings.Add(currentProperty.Name, currentProperty.DefaultValue.ToString());
}
}
AppSettings = AppConfiguration.AppSettings.Settings;
LoadSettings();
}
catch(Exception ex)
{
MessageBox.Show("Error opening settings: " + ex.Message, "Settings", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

public void LoadSettings()
{
var settings = AppConfiguration.AppSettings.Settings;
foreach (SettingsProperty currentProperty in Properties.Settings.Default.Properties)
{
if (AppConfiguration.AppSettings.Settings[currentProperty.Name] == null)
{
AppConfiguration.AppSettings.Settings.Add(currentProperty.Name, currentProperty.DefaultValue.ToString());
}
}
AppSettings = AppConfiguration.AppSettings.Settings;
}

public void SetVolume(double volume)
{
int iVolume = (int)(volume * 100);
Expand Down Expand Up @@ -196,6 +201,11 @@ public void ListenOnXMLChanged(MyFunction f)
// not implemented in the portable version
}

public void ListenOnOptionsChanged(MyFunction f)
{
// not implemented in the portable version
}

private void Save()
{
if (isInstalled)
Expand Down
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
// 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("2.2.3.0")]
[assembly: AssemblyFileVersion("2.2.3.0")]
[assembly: AssemblyVersion("2.2.5.0")]
[assembly: AssemblyFileVersion("2.2.5.0")]
[assembly: NeutralResourcesLanguage("en-GB")]

4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfoPortable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,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.2.4.0")]
[assembly: AssemblyFileVersion("1.2.4.0")]
[assembly: AssemblyVersion("1.2.5.0")]
[assembly: AssemblyFileVersion("1.2.5.0")]
2 changes: 1 addition & 1 deletion src/UWPSheep/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap mp rescap">
<Identity Name="6469Adriano.esheep" Publisher="CN=39092E3A-7130-410B-B315-09A9DDDBDEA9" Version="2.3.2.0" />
<Identity Name="6469Adriano.esheep" Publisher="CN=39092E3A-7130-410B-B315-09A9DDDBDEA9" Version="2.5.32.0" />
<Properties>
<DisplayName>esheep</DisplayName>
<PublisherDisplayName>Adriano</PublisherDisplayName>
Expand Down
2 changes: 1 addition & 1 deletion src/UWPSheep/UWPSheep.wapproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<PackageCertificateThumbprint>5F42B0C0AA58D9BF5C19EF0C2C270BE782F2AD18</PackageCertificateThumbprint>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxBundlePlatforms>x64</AppxBundlePlatforms>
<AppxBundlePlatforms>x86</AppxBundlePlatforms>
<AppInstallerUpdateFrequency>0</AppInstallerUpdateFrequency>
<AppInstallerCheckForUpdateFrequency>OnApplicationRun</AppInstallerCheckForUpdateFrequency>
<AppxPackageDir>D:\GitHub\desktopPet\src\UWPSheep\..\..\build\AppPackages\</AppxPackageDir>
Expand Down
5 changes: 4 additions & 1 deletion src/dotNet/Animations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ public TAnimation(string name, int id)
Border = false;
ID = id;
}

/// <summary>
/// Update the xml values to update them on multiscreen
/// </summary>
/// <param name="screenIndex">Set to screen id used for the calculation</param>
public void UpdateValues(int screenIndex = -1)
{
if (Sequence.Repeat.IsDynamic)
Expand Down
4 changes: 2 additions & 2 deletions src/dotNet/FormPet.Designer.cs

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

Loading

0 comments on commit 2361c5c

Please sign in to comment.