Skip to content

Commit

Permalink
Merge pull request RolandPheasant#174 from t0mburton/master
Browse files Browse the repository at this point in the history
Prevent app window jumping on start up.
  • Loading branch information
RolandPheasant authored May 22, 2017
2 parents e0ae1a3 + e2ca535 commit 1393260
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
19 changes: 19 additions & 0 deletions Source/TailBlazer.Fixtures/SettingsConversion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using TailBlazer.Domain.FileHandling.Recent;
using TailBlazer.Domain.Formatting;
using Xunit;
using TailBlazer.Views.Tail;
using TailBlazer.Domain.Settings;

namespace TailBlazer.Fixtures
{
Expand Down Expand Up @@ -38,6 +40,23 @@ public void GeneralOptionsWithCultureEnUs()
SerializeAndDeserializeWithCulture("en-Us");
}

[Fact]
public void EmptySearchShouldReturnDefault()
{
var converter = new SearchMetadataToStateConverter();
var state = converter.Convert(State.Empty);
state.ShouldAllBeEquivalentTo(converter.GetDefaultValue());
}

[Fact]
public void NullSearchShouldReturnDefault()
{
var converter = new SearchMetadataToStateConverter();
State nullState = null;
var state = converter.Convert(nullState);
state.ShouldAllBeEquivalentTo(converter.GetDefaultValue());
}

private void SerializeAndDeserializeWithCulture(string cultureName)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureName);
Expand Down
6 changes: 5 additions & 1 deletion Source/TailBlazer/BootStrap.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Reactive.Concurrency;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Threading;
Expand All @@ -7,6 +8,7 @@
using TailBlazer.Infrastucture.AppState;
using TailBlazer.Views.Layout;
using TailBlazer.Views.WindowManagement;
using TailBlazer.Domain.Infrastructure;

namespace TailBlazer
{
Expand Down Expand Up @@ -34,10 +36,12 @@ public static void Main(string[] args)
tempWindowToGetDispatcher.Close();

var layoutServce = container.GetInstance<ILayoutService>();
var scheduler = container.GetInstance<ISchedulerProvider>();
scheduler.MainThread.Schedule(window.Show);

var appStatePublisher = container.GetInstance<IApplicationStatePublisher>();
app.Exit += (sender, e) => appStatePublisher.Publish(ApplicationState.ShuttingDown);
window.Show();

app.Run();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/TailBlazer/Views/Layout/LayoutService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void Write()
}
catch (Exception ex)
{
_logger.Error(ex, "Problem loading layout");
_logger.Error(ex, "Problem saving layout");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ private static class Structure

public SearchState[] Convert(State state)
{
if (state == null || state == State.Empty)
return GetDefaultValue();

var doc = XDocument.Parse(state.Value);
var root = doc.Element(Structure.Root);

Expand Down Expand Up @@ -109,4 +112,4 @@ public SearchState[] GetDefaultValue()
return Enumerable.Empty<SearchState>().ToArray();
}
}
}
}

0 comments on commit 1393260

Please sign in to comment.