Skip to content

Commit

Permalink
Merge pull request #312 from vain0/feature/auto_select_archive_path
Browse files Browse the repository at this point in the history
Add `AutoSelectArchivePath` to settings
  • Loading branch information
mjdescy committed May 2, 2016
2 parents 7d3a740 + b3c70a2 commit b2d2fa1
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Client/Controls/Options.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="23"/>
<RowDefinition Height="46"/>
<RowDefinition Height="55"/>
<RowDefinition Height="23"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
Expand All @@ -31,7 +31,10 @@
<Label Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" Content="Archive File" />
<TextBox Grid.Row="0" Grid.Column="1" Name="tbArchiveFile" />
<Button Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right" Content="Select..." Name="button1" Click="button1_Click" />
<CheckBox Grid.Row="1" Grid.Column="1" Content="Automatically archive completed tasks" Name="cbAutoArchive" />
<StackPanel Grid.Row="1" Grid.Column="1">
<CheckBox Content="Automatically archive completed tasks" Name="cbAutoArchive" />
<CheckBox Content="Automatically select archive path" Name="cbAutoSelectArchivePath" />
</StackPanel>
<Label Grid.Row="2" Grid.Column="0" Content="Current Font" />
<TextBox Grid.Row="2" Grid.Column="1" Name="currentFontDisplay" IsUndoEnabled="False" IsReadOnly="True" />
<Button Grid.Row="2" Grid.Column="2" HorizontalAlignment="Right" Content="Select Font..." Name="selectFonts" Click="selectFonts_Click" />
Expand Down
1 change: 1 addition & 0 deletions Client/Controls/Options.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public Options(FontInfo taskFont)

tbArchiveFile.Text = User.Default.ArchiveFilePath;
cbAutoArchive.IsChecked = User.Default.AutoArchive;
cbAutoSelectArchivePath.IsChecked = User.Default.AutoSelectArchivePath;
cbAutoRefresh.IsChecked = User.Default.AutoRefresh;
cbCaseSensitiveFilter.IsChecked = User.Default.FilterCaseSensitive;
cbIntellisenseCaseSensitive.IsChecked = User.Default.IntellisenseCaseSensitive;
Expand Down
7 changes: 4 additions & 3 deletions Client/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,12 +1212,12 @@ public void OpenFile()

public void ArchiveCompleted()
{
if (!File.Exists(User.Default.ArchiveFilePath))
if (!File.Exists(User.Default.SelectedArchiveFilePath))
{
ShowOptionsDialog();
}

if (!File.Exists(User.Default.ArchiveFilePath))
if (!File.Exists(User.Default.SelectedArchiveFilePath))
{
return;
}
Expand All @@ -1226,7 +1226,7 @@ public void ArchiveCompleted()

DisableFileChangeObserver();

var archiveList = new TaskList(User.Default.ArchiveFilePath, User.Default.PreserveWhiteSpace);
var archiveList = new TaskList(User.Default.SelectedArchiveFilePath, User.Default.PreserveWhiteSpace);
var completed = TaskList.Tasks.Where(t => t.Completed);

// Make sure we are working with the latest version of the file.
Expand Down Expand Up @@ -1275,6 +1275,7 @@ public void ShowOptionsDialog()

User.Default.ArchiveFilePath = o.tbArchiveFile.Text;
User.Default.AutoArchive = o.cbAutoArchive.IsChecked.Value;
User.Default.AutoSelectArchivePath = o.cbAutoSelectArchivePath.IsChecked.Value;
User.Default.MoveFocusToTaskListAfterAddingNewTask = o.cbMoveFocusToTaskListAfterAddingNewTask.IsChecked.Value;
User.Default.AutoRefresh = o.cbAutoRefresh.IsChecked.Value;
User.Default.FilterCaseSensitive = o.cbCaseSensitiveFilter.IsChecked.Value;
Expand Down
12 changes: 12 additions & 0 deletions Client/User.Designer.cs

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

15 changes: 14 additions & 1 deletion Client/User.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Client
using System.IO;

namespace Client
{
// This class allows you to handle specific events on the settings class:
// The SettingChanging event is raised before a setting's value is changed.
Expand Down Expand Up @@ -26,5 +28,16 @@ private void SettingsSavingEventHandler(object sender, System.ComponentModel.Can
{
// Add code to handle the SettingsSaving event here.
}

public string SelectedArchiveFilePath
{
get
{
return
AutoSelectArchivePath
? Path.Combine(Path.GetDirectoryName(FilePath), "done.txt")
: ArchiveFilePath;
}
}
}
}
3 changes: 3 additions & 0 deletions Client/User.settings
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,8 @@
<Setting Name="IntellisenseCaseSensitive" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="AutoSelectArchivePath" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
3 changes: 3 additions & 0 deletions Client/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@
<setting name="IntellisenseCaseSensitive" serializeAs="String">
<value>False</value>
</setting>
<setting name="AutoSelectArchivePath" serializeAs="String">
<value>False</value>
</setting>
</Client.User>
</userSettings>
</configuration>

0 comments on commit b2d2fa1

Please sign in to comment.