Skip to content

Commit

Permalink
modified theme folder locations
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonyCorbett committed Sep 20, 2018
1 parent 37a8f6c commit fcb6b4a
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Installer/OnlyVSetup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Source: "bin\Release\Serilog.Sinks.RollingFile.dll"; DestDir: "{app}"; Flags: ig
Source: "bin\Release\System.ValueTuple.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "bin\Release\System.Windows.Interactivity.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\OnlyVThemeCreator\bin\Release\Xceed.Wpf.Toolkit.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\ReleaseThemes\*"; DestDir: "{userdocs}\OnlyV\ThemeFiles"; Flags: ignoreversion createallsubdirs recursesubdirs
Source: "..\ReleaseThemes\*"; DestDir: "{commonappdata}\OnlyV\ThemeFiles"; Flags: ignoreversion createallsubdirs recursesubdirs

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Expand Down
17 changes: 16 additions & 1 deletion OnlyV/Helpers/FileUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ public static string GetEpubFolder()
return folder;
}

public static string GetThemeFolder()
public static string GetStandardThemeFolder()
{
var folder = Path.Combine(GetOnlyVCommonAppDataFolder(), @"ThemeFiles");
return !Directory.Exists(folder) ? null : folder;
}

public static string GetPrivateThemeFolder()
{
string folder = Path.Combine(GetOnlyVMyDocsFolder(), @"ThemeFiles");
CreateDirectory(folder);
Expand Down Expand Up @@ -86,6 +92,15 @@ public static string GetOnlyVMyDocsFolder()
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), AppNamePathSegment);
}

/// <summary>
/// Gets the application's common appData folder.
/// </summary>
/// <returns>Folder path</returns>
public static string GetOnlyVCommonAppDataFolder()
{
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), AppNamePathSegment);
}

/// <summary>
/// Gets the file path for storing the user options
/// </summary>
Expand Down
12 changes: 10 additions & 2 deletions OnlyV/ViewModel/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,18 @@ private IReadOnlyCollection<EpubFileItem> GetBibleEpubFiles()
private IReadOnlyCollection<ThemeFileItem> GetThemeFiles()
{
var result = new List<ThemeFileItem>();

var allThemes = new List<string>();

var files = Directory.GetFiles(FileUtils.GetThemeFolder(), $"*{ThemeFile.ThemeFileExtension}").ToList();
var stdThemeFolder = FileUtils.GetStandardThemeFolder();
if (stdThemeFolder != null)
{
allThemes.AddRange(Directory.GetFiles(stdThemeFolder, $"*{ThemeFile.ThemeFileExtension}"));
}

foreach (var file in files)
allThemes.AddRange(Directory.GetFiles(FileUtils.GetPrivateThemeFolder(), $"*{ThemeFile.ThemeFileExtension}"));

foreach (var file in allThemes)
{
result.Add(new ThemeFileItem
{
Expand Down
7 changes: 3 additions & 4 deletions OnlyVThemeCreator/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System.IO;
using OnlyVThemeCreator.Helpers;

namespace OnlyVThemeCreator
namespace OnlyVThemeCreator
{
using System.IO;
using System.Threading;
using System.Windows;
using GalaSoft.MvvmLight.Threading;
using Helpers;
using Serilog;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion OnlyVThemeCreator/Dialogs/ShouldSaveDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<Grid>
<StackPanel Orientation="Vertical">
<TextBlock Style="{StaticResource MaterialDesignDisplay1TextBlock}"
Text="Save Project?"
Text="Save Theme?"
Margin="0,0,0,20"/>

<Grid Margin="0,0,0,40">
Expand Down
2 changes: 1 addition & 1 deletion OnlyVThemeCreator/Helpers/FileUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static bool DirectoryIsAvailable(string dir)
return true;
}

public static string GetThemeFolder()
public static string GetPrivateThemeFolder()
{
string folder = Path.Combine(GetOnlyVMyDocsFolder(), @"ThemeFiles");
CreateDirectory(folder);
Expand Down
4 changes: 2 additions & 2 deletions OnlyVThemeCreator/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ private void SaveAsFile()
d.OverwritePrompt = true;
d.AlwaysAppendDefaultExtension = true;
d.IsExpandedMode = true;
d.DefaultDirectory = _defaultFileSaveFolder ?? FileUtils.GetThemeFolder();
d.DefaultDirectory = _defaultFileSaveFolder ?? FileUtils.GetPrivateThemeFolder();
d.DefaultExtension = ThemeFile.ThemeFileExtension;
d.Filters.Add(new CommonFileDialogFilter(Properties.Resources.THEME_FILE, $"*{ThemeFile.ThemeFileExtension}"));
d.Title = Properties.Resources.SAVE_THEME;
Expand Down Expand Up @@ -1128,7 +1128,7 @@ private async void OpenFile()

using (var d = new CommonOpenFileDialog())
{
d.DefaultDirectory = _defaultFileOpenFolder ?? FileUtils.GetThemeFolder();
d.DefaultDirectory = _defaultFileOpenFolder ?? FileUtils.GetPrivateThemeFolder();
d.DefaultExtension = ThemeFile.ThemeFileExtension;
d.Filters.Add(new CommonFileDialogFilter(Properties.Resources.THEME_FILE, $"*{ThemeFile.ThemeFileExtension}"));
d.Title = Properties.Resources.OPEN_THEME;
Expand Down
2 changes: 1 addition & 1 deletion SolutionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("1.0.0.5")]
[assembly: AssemblyVersion("1.0.0.6")]

0 comments on commit fcb6b4a

Please sign in to comment.