Skip to content

Commit

Permalink
Merge pull request #56 from StefanKert/develop
Browse files Browse the repository at this point in the history
Merge for 2.1.1
  • Loading branch information
StefanKert authored Feb 3, 2018
2 parents 811d976 + 3c07561 commit a2c5700
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 126 deletions.
226 changes: 113 additions & 113 deletions BuildVision.UI/Settings/Models/BuildMessagesSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,138 +4,138 @@

namespace BuildVision.UI.Settings.Models
{
public class BuildMessagesSettings : SettingsBase
{
private BuildMajorMessageFormat _majorMessageFormat = BuildMajorMessageFormat.Entire;
private string _buildBeginMajorMessageStringFormat = "{0} ...";
private string _buildDoneMajorMessageStringFormat = "{0}";
private bool _showSolutionName = true;
private bool _showProjectName = true;
private string _dateTimeFormat = "HH:mm:ss";
private string _timeSpanFormat = @"mm\:ss";
private bool _showExtraMessage = true;
private BuildExtraMessageFormat _extraMessageFormat = BuildExtraMessageFormat.Custom;
private string _extraMessageStringFormat = " ({0})";
private int _extraMessageDelay = 5;

public BuildMajorMessageFormat MajorMessageFormat
public class BuildMessagesSettings : SettingsBase
{
get => _majorMessageFormat;
set => SetProperty(ref _majorMessageFormat, value);
}

public bool ShowSolutionName
{
get => _showSolutionName;
set => SetProperty(ref _showSolutionName, value);
}

public bool ShowProjectName
{
get => _showProjectName;
set => SetProperty(ref _showProjectName, value);
}

public string DateTimeFormat
{
get => _dateTimeFormat;
set
{
if (_dateTimeFormat != value)
private BuildMajorMessageFormat _majorMessageFormat = BuildMajorMessageFormat.Entire;
private string _buildBeginMajorMessageStringFormat = "{0} ...";
private string _buildDoneMajorMessageStringFormat = "{0}";
private bool _showSolutionName = true;
private bool _showProjectName = true;
private string _dateTimeFormat = "HH:mm:ss";
private string _timeSpanFormat = @"mm\:ss";
private bool _showExtraMessage = true;
private BuildExtraMessageFormat _extraMessageFormat = BuildExtraMessageFormat.Custom;
private string _extraMessageStringFormat = " ({0})";
private int _extraMessageDelay = 5;

public BuildMajorMessageFormat MajorMessageFormat
{
_dateTimeFormat = value;
OnPropertyChanged("DateTimeFormat");

var tmp = DateTime.Now.ToString(value);
get => _majorMessageFormat;
set => SetProperty(ref _majorMessageFormat, value);
}
}
}

public string BuildBeginMajorMessageStringFormat
{
get => _buildBeginMajorMessageStringFormat;
set
{
if (_buildBeginMajorMessageStringFormat != value)
public BuildExtraMessageFormat ExtraMessageFormat
{
_buildBeginMajorMessageStringFormat = value;
OnPropertyChanged("BuildBeginMajorMessageStringFormat");

if (!value.Contains("{0}"))
throw new FormatException("Format must contain '{0}' argument.");

string tmp = string.Format(value, "test");
get => _extraMessageFormat;
set => SetProperty(ref _extraMessageFormat, value);
}
}
}

public string BuildDoneMajorMessageStringFormat
{
get => _buildDoneMajorMessageStringFormat;
set
{
if (_buildDoneMajorMessageStringFormat != value)
public bool ShowSolutionName
{
_buildDoneMajorMessageStringFormat = value;
OnPropertyChanged("BuildDoneMajorMessageStringFormat");

if (!value.Contains("{0}"))
throw new FormatException("Format must contain '{0}' argument.");

string tmp = string.Format(value, "test");
get => _showSolutionName;
set => SetProperty(ref _showSolutionName, value);
}
}
}

public bool ShowExtraMessage
{
get => _showExtraMessage;
set => SetProperty(ref _showExtraMessage, value);
}
public bool ShowProjectName
{
get => _showProjectName;
set => SetProperty(ref _showProjectName, value);
}

public int ExtraMessageDelay
{
get => _extraMessageDelay;
set => SetProperty(ref _extraMessageDelay, value);
}
public bool ShowExtraMessage
{
get => _showExtraMessage;
set => SetProperty(ref _showExtraMessage, value);
}

public BuildExtraMessageFormat ExtraMessageFormat
{
get => _extraMessageFormat;
set => SetProperty(ref _extraMessageFormat, value);
}
public int ExtraMessageDelay
{
get => _extraMessageDelay;
set => SetProperty(ref _extraMessageDelay, value);
}

public string TimeSpanFormat
{
get => _timeSpanFormat;
set
{
if (_timeSpanFormat != value)
public string BuildBeginMajorMessageStringFormat
{
_timeSpanFormat = value;
OnPropertyChanged("TimeSpanFormat");
get => _buildBeginMajorMessageStringFormat;
set
{
if (_buildBeginMajorMessageStringFormat != value)
{
_buildBeginMajorMessageStringFormat = value;
OnPropertyChanged(nameof(BuildBeginMajorMessageStringFormat));

if (!value.Contains("{0}"))
throw new FormatException("Format must contain '{0}' argument.");

string tmp = string.Format(value, "test");
}
}
}

var tmp = TimeSpan.MaxValue.ToString(value);
public string BuildDoneMajorMessageStringFormat
{
get => _buildDoneMajorMessageStringFormat;
set
{
if (_buildDoneMajorMessageStringFormat != value)
{
_buildDoneMajorMessageStringFormat = value;
OnPropertyChanged(nameof(BuildDoneMajorMessageStringFormat));

if (!value.Contains("{0}"))
throw new FormatException("Format must contain '{0}' argument.");

string tmp = string.Format(value, "test");
}
}
}
}
}

public string ExtraMessageStringFormat
{
get => _extraMessageStringFormat;
set
{
if (_extraMessageStringFormat != value)
public string DateTimeFormat
{
_extraMessageStringFormat = value;
OnPropertyChanged("ExtraMessageStringFormat");
get => _dateTimeFormat;
set
{
if (_dateTimeFormat != value)
{
_dateTimeFormat = value;
OnPropertyChanged(nameof(DateTimeFormat));

var tmp = DateTime.Now.ToString(value);
}
}
}

if (!value.Contains("{0}"))
throw new FormatException("Format must contain '{0}' argument.");
public string TimeSpanFormat
{
get => _timeSpanFormat;
set
{
if (_timeSpanFormat != value)
{
_timeSpanFormat = value;
OnPropertyChanged(nameof(TimeSpanFormat));

var tmp = TimeSpan.MaxValue.ToString(value);
}
}
}

var tmp = string.Format(value, "test");
public string ExtraMessageStringFormat
{
get => _extraMessageStringFormat;
set
{
if (_extraMessageStringFormat != value)
{
_extraMessageStringFormat = value;
OnPropertyChanged(nameof(ExtraMessageStringFormat));

if (!value.Contains("{0}"))
throw new FormatException("Format must contain '{0}' argument.");

var tmp = string.Format(value, "test");
}
}
}
}
}
}
}
}
21 changes: 15 additions & 6 deletions BuildVision/Core/BuildVisionPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using BuildVision.UI.ViewModels;
using BuildVision.Tool;
using BuildVision.UI.Common.Logging;
using System.Windows;

namespace BuildVision.Core
{
Expand Down Expand Up @@ -69,12 +70,20 @@ private ToolWindowPane GetWindowPane(Type windowType)

private static ControlSettings LoadSettings(IServiceProvider serviceProvider)
{
var store = GetWritableSettingsStore(serviceProvider);
if (store.PropertyExists(SettingsCategoryName, SettingsPropertyName))
try
{
var store = GetWritableSettingsStore(serviceProvider);
if (store.PropertyExists(SettingsCategoryName, SettingsPropertyName))
{
var legacySerialized = new LegacyConfigurationSerializer<ControlSettings>();
string value = store.GetString(SettingsCategoryName, SettingsPropertyName);
return legacySerialized.Deserialize(value);
}
}
catch (Exception ex)
{
var legacySerialized = new LegacyConfigurationSerializer<ControlSettings>();
string value = store.GetString(SettingsCategoryName, SettingsPropertyName);
return legacySerialized.Deserialize(value);
ex.Trace("Error when trying to load settings: " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
MessageBox.Show("An error occurred when trying to load current settings. To make sure everything is still working the settings are set to default.");
}

return new ControlSettings();
Expand Down Expand Up @@ -103,4 +112,4 @@ private static WritableSettingsStore GetWritableSettingsStore(IServiceProvider s

public event Action<ControlSettings> ControlSettingsChanged = delegate { };
}
}
}
3 changes: 2 additions & 1 deletion BuildVision/Tool/Tool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ private void BuildEvents_OnBuildProjectBegin(object sender, BuildProjectEventArg

if (!_viewModel.ProjectsList.Contains(currentProject))
_viewModel.ProjectsList.Add(currentProject);

else if (_viewModel.ControlSettings.GeneralSettings.FillProjectListOnBuildBegin)
_viewModel.OnPropertyChanged(nameof(ControlViewModel.GroupedProjectsList));
_viewModel.CurrentProject = currentProject;
}
catch (Exception ex)
Expand Down
8 changes: 4 additions & 4 deletions BuildVision/Tool/ToolWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected override void Initialize()
// This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,
// we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on
// the object returned by the Content property.
Content = CreateMyControl();
Content = CreateControlView();
_controlCreatedSuccessfully = true;

base.Initialize();
Expand All @@ -76,7 +76,7 @@ protected override void OnClose()
base.OnClose();
}

private ControlView CreateMyControl()
private ControlView CreateControlView()
{
var packageContext = (IPackageContext)Package;
var viewModel = new ControlViewModel(new ControlModel(), packageContext.ControlSettings);
Expand All @@ -103,8 +103,8 @@ private void SaveControlSettings()

public static ControlViewModel GetViewModel(ToolWindowPane toolWindow)
{
var myControlView = (ControlView)toolWindow.Content;
return (ControlViewModel)myControlView.DataContext;
var controlView = (ControlView)toolWindow.Content;
return (ControlViewModel)controlView.DataContext;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ protected override BuildMessagesSettings Settings
set { ControlSettings.BuildMessagesSettings = value; }
}
}
}
}
3 changes: 2 additions & 1 deletion BuildVision/Tool/Views/Settings/SettingsDialogPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ protected override void OnApply(PageApplyEventArgs args)
protected override void OnClosed(EventArgs e)
{
_editSettings = null;
_ctrl.DataContext = null;
if(_ctrl != null)
_ctrl.DataContext = null;

if (_notifySettingsChangedOnce)
{
Expand Down

0 comments on commit a2c5700

Please sign in to comment.