From 8da396c518af4374658d76ce1e49e21997606323 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 19 Feb 2016 11:13:09 +0000 Subject: [PATCH 1/5] fixed code that crashes mono compiler. --- src/Perspex.Controls/Utils/UndoRedoHelper.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Perspex.Controls/Utils/UndoRedoHelper.cs b/src/Perspex.Controls/Utils/UndoRedoHelper.cs index 9de2ca9b35..70e5921d8d 100644 --- a/src/Perspex.Controls/Utils/UndoRedoHelper.cs +++ b/src/Perspex.Controls/Utils/UndoRedoHelper.cs @@ -37,7 +37,12 @@ namespace Perspex.Controls.Utils public void Undo() { - _host.UndoRedoState= (_currentNode = _currentNode?.Previous ?? _currentNode).Value; + if (_currentNode != null) + { + _currentNode = _currentNode.Previous; + } + + _host.UndoRedoState = _currentNode?.Value; } public bool IsLastState => _currentNode.Next == null; @@ -62,8 +67,12 @@ namespace Perspex.Controls.Utils } public void Redo() - { - _host.UndoRedoState = (_currentNode = _currentNode?.Next ?? _currentNode).Value; + { + if (_currentNode != null) { + _currentNode = _currentNode.Next; + } + + _host.UndoRedoState = _currentNode?.Value; } public void Snapshot() From dc3c4d79d61bd544376e51cf754336a9442c2fb9 Mon Sep 17 00:00:00 2001 From: danwalmsley Date: Fri, 19 Feb 2016 11:29:11 +0000 Subject: [PATCH 2/5] Added open file and open folder dialogs to test app. --- .../ViewModels/MainWindowViewModel.cs | 22 +++++++++++++++++++ .../Views/MainWindow.paml | 6 +++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/samples/XamlTestApplicationPcl/ViewModels/MainWindowViewModel.cs b/samples/XamlTestApplicationPcl/ViewModels/MainWindowViewModel.cs index 9ac24a622e..3ae72e138c 100644 --- a/samples/XamlTestApplicationPcl/ViewModels/MainWindowViewModel.cs +++ b/samples/XamlTestApplicationPcl/ViewModels/MainWindowViewModel.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using ReactiveUI; +using Perspex.Controls; namespace XamlTestApplication.ViewModels { @@ -59,6 +60,23 @@ namespace XamlTestApplication.ViewModels CollapseNodesCommand.Subscribe(_ => ExpandNodes(false)); ExpandNodesCommand = ReactiveCommand.Create(); ExpandNodesCommand.Subscribe(_ => ExpandNodes(true)); + + OpenFileCommand = ReactiveCommand.Create(); + OpenFileCommand.Subscribe(_ => + { + var ofd = new OpenFileDialog(); + + ofd.ShowAsync(); + }); + + OpenFolderCommand = ReactiveCommand.Create(); + OpenFolderCommand.Subscribe(_ => + { + var ofd = new OpenFolderDialog(); + + ofd.ShowAsync(); + }); + } public List Items { get; } @@ -68,6 +86,10 @@ namespace XamlTestApplication.ViewModels public ReactiveCommand ExpandNodesCommand { get; } + public ReactiveCommand OpenFileCommand { get; } + + public ReactiveCommand OpenFolderCommand { get; } + public void ExpandNodes(bool expanded) { foreach (var node in Nodes) diff --git a/samples/XamlTestApplicationPcl/Views/MainWindow.paml b/samples/XamlTestApplicationPcl/Views/MainWindow.paml index cadb70edac..e5155b0b95 100644 --- a/samples/XamlTestApplicationPcl/Views/MainWindow.paml +++ b/samples/XamlTestApplicationPcl/Views/MainWindow.paml @@ -6,11 +6,13 @@ Title="Perspex Test Application" Width="800" Height="600"> - + + + - + From 08ef760431821a0982e34eb1f4f29f5da80dbd0a Mon Sep 17 00:00:00 2001 From: danwalmsley Date: Fri, 19 Feb 2016 11:33:48 +0000 Subject: [PATCH 3/5] fixed undo redo helper. --- src/Perspex.Controls/Utils/UndoRedoHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Perspex.Controls/Utils/UndoRedoHelper.cs b/src/Perspex.Controls/Utils/UndoRedoHelper.cs index 70e5921d8d..60b6839dad 100644 --- a/src/Perspex.Controls/Utils/UndoRedoHelper.cs +++ b/src/Perspex.Controls/Utils/UndoRedoHelper.cs @@ -42,7 +42,7 @@ namespace Perspex.Controls.Utils _currentNode = _currentNode.Previous; } - _host.UndoRedoState = _currentNode?.Value; + _host.UndoRedoState = _currentNode.Value; } public bool IsLastState => _currentNode.Next == null; @@ -72,7 +72,7 @@ namespace Perspex.Controls.Utils _currentNode = _currentNode.Next; } - _host.UndoRedoState = _currentNode?.Value; + _host.UndoRedoState = _currentNode.Value; } public void Snapshot() From b845680b2e270c4028cc53eda71c17b277779390 Mon Sep 17 00:00:00 2001 From: danwalmsley Date: Fri, 19 Feb 2016 13:27:42 +0000 Subject: [PATCH 4/5] Font scaling on linux, and FolderBrowse implementation for linux. --- .../ViewModels/MainWindowViewModel.cs | 22 +++++++++++++ .../Views/MainWindow.paml | 6 ++-- .../Perspex.Cairo/Media/FormattedTextImpl.cs | 9 ++++-- src/Gtk/Perspex.Gtk/SystemDialogImpl.cs | 32 +++++++++++++++++-- src/Perspex.Controls/Utils/UndoRedoHelper.cs | 15 +++++++-- 5 files changed, 74 insertions(+), 10 deletions(-) diff --git a/samples/XamlTestApplicationPcl/ViewModels/MainWindowViewModel.cs b/samples/XamlTestApplicationPcl/ViewModels/MainWindowViewModel.cs index 9ac24a622e..3ae72e138c 100644 --- a/samples/XamlTestApplicationPcl/ViewModels/MainWindowViewModel.cs +++ b/samples/XamlTestApplicationPcl/ViewModels/MainWindowViewModel.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using ReactiveUI; +using Perspex.Controls; namespace XamlTestApplication.ViewModels { @@ -59,6 +60,23 @@ namespace XamlTestApplication.ViewModels CollapseNodesCommand.Subscribe(_ => ExpandNodes(false)); ExpandNodesCommand = ReactiveCommand.Create(); ExpandNodesCommand.Subscribe(_ => ExpandNodes(true)); + + OpenFileCommand = ReactiveCommand.Create(); + OpenFileCommand.Subscribe(_ => + { + var ofd = new OpenFileDialog(); + + ofd.ShowAsync(); + }); + + OpenFolderCommand = ReactiveCommand.Create(); + OpenFolderCommand.Subscribe(_ => + { + var ofd = new OpenFolderDialog(); + + ofd.ShowAsync(); + }); + } public List Items { get; } @@ -68,6 +86,10 @@ namespace XamlTestApplication.ViewModels public ReactiveCommand ExpandNodesCommand { get; } + public ReactiveCommand OpenFileCommand { get; } + + public ReactiveCommand OpenFolderCommand { get; } + public void ExpandNodes(bool expanded) { foreach (var node in Nodes) diff --git a/samples/XamlTestApplicationPcl/Views/MainWindow.paml b/samples/XamlTestApplicationPcl/Views/MainWindow.paml index cadb70edac..e5155b0b95 100644 --- a/samples/XamlTestApplicationPcl/Views/MainWindow.paml +++ b/samples/XamlTestApplicationPcl/Views/MainWindow.paml @@ -6,11 +6,13 @@ Title="Perspex Test Application" Width="800" Height="600"> - + + + - + diff --git a/src/Gtk/Perspex.Cairo/Media/FormattedTextImpl.cs b/src/Gtk/Perspex.Cairo/Media/FormattedTextImpl.cs index 956a522002..e8fc9bc924 100644 --- a/src/Gtk/Perspex.Cairo/Media/FormattedTextImpl.cs +++ b/src/Gtk/Perspex.Cairo/Media/FormattedTextImpl.cs @@ -15,6 +15,11 @@ namespace Perspex.Cairo.Media private Size _size; private readonly string _text; + static double CorrectScale(double input) + { + return input * 0.75; + } + public FormattedTextImpl( Pango.Context context, string text, @@ -25,14 +30,14 @@ namespace Perspex.Cairo.Media FontWeight fontWeight) { Contract.Requires(context != null); - Contract.Requires (text != null); + Contract.Requires(text != null); Layout = new Pango.Layout(context); _text = text; Layout.SetText(text); Layout.FontDescription = new Pango.FontDescription { Family = fontFamily, - Size = Pango.Units.FromDouble(fontSize), + Size = Pango.Units.FromDouble(CorrectScale(fontSize)), Style = (Pango.Style)fontStyle, Weight = fontWeight.ToCairo() }; diff --git a/src/Gtk/Perspex.Gtk/SystemDialogImpl.cs b/src/Gtk/Perspex.Gtk/SystemDialogImpl.cs index 304de86fc3..9789beb7c7 100644 --- a/src/Gtk/Perspex.Gtk/SystemDialogImpl.cs +++ b/src/Gtk/Perspex.Gtk/SystemDialogImpl.cs @@ -15,7 +15,7 @@ namespace Perspex.Gtk public Task ShowFileDialogAsync(FileDialog dialog, IWindowImpl parent) { var tcs = new TaskCompletionSource(); - var dlg = new global::Gtk.FileChooserDialog(dialog.Title, ((WindowImpl) parent), + var dlg = new global::Gtk.FileChooserDialog(dialog.Title, ((WindowImpl)parent), dialog is OpenFileDialog ? FileChooserAction.Open : FileChooserAction.Save, @@ -44,7 +44,7 @@ namespace Perspex.Gtk dlg.Hide(); dlg.Dispose(); }; - + dlg.Close += delegate { tcs.TrySetResult(null); @@ -56,7 +56,33 @@ namespace Perspex.Gtk public Task ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent) { - throw new NotImplementedException(); + var tcs = new TaskCompletionSource(); + var dlg = new global::Gtk.FileChooserDialog(dialog.Title, ((WindowImpl)parent), + FileChooserAction.SelectFolder, + "Cancel", ResponseType.Cancel, + "Select Folder", ResponseType.Accept) + { + + }; + + dlg.Modal = true; + + dlg.Response += (_, args) => + { + if (args.ResponseId == ResponseType.Accept) + tcs.TrySetResult(dlg.Filename); + + dlg.Hide(); + dlg.Dispose(); + }; + + dlg.Close += delegate + { + tcs.TrySetResult(null); + dlg.Dispose(); + }; + dlg.Show(); + return tcs.Task; } } } diff --git a/src/Perspex.Controls/Utils/UndoRedoHelper.cs b/src/Perspex.Controls/Utils/UndoRedoHelper.cs index 9de2ca9b35..60b6839dad 100644 --- a/src/Perspex.Controls/Utils/UndoRedoHelper.cs +++ b/src/Perspex.Controls/Utils/UndoRedoHelper.cs @@ -37,7 +37,12 @@ namespace Perspex.Controls.Utils public void Undo() { - _host.UndoRedoState= (_currentNode = _currentNode?.Previous ?? _currentNode).Value; + if (_currentNode != null) + { + _currentNode = _currentNode.Previous; + } + + _host.UndoRedoState = _currentNode.Value; } public bool IsLastState => _currentNode.Next == null; @@ -62,8 +67,12 @@ namespace Perspex.Controls.Utils } public void Redo() - { - _host.UndoRedoState = (_currentNode = _currentNode?.Next ?? _currentNode).Value; + { + if (_currentNode != null) { + _currentNode = _currentNode.Next; + } + + _host.UndoRedoState = _currentNode.Value; } public void Snapshot() From 2e3fb75ed63653ecf0cd220f4e34be8c26f69afa Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 20 Feb 2016 11:23:53 +0100 Subject: [PATCH 5/5] Updated OmniXAML. Added some missing namespace definition attributes as now OmniXaml uses them properly. --- src/Markup/Perspex.Markup.Xaml/OmniXAML | 2 +- src/Perspex.Controls/Properties/AssemblyInfo.cs | 3 ++- src/Perspex.SceneGraph/Properties/AssemblyInfo.cs | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Markup/Perspex.Markup.Xaml/OmniXAML b/src/Markup/Perspex.Markup.Xaml/OmniXAML index 27005c8b4d..5209a3f262 160000 --- a/src/Markup/Perspex.Markup.Xaml/OmniXAML +++ b/src/Markup/Perspex.Markup.Xaml/OmniXAML @@ -1 +1 @@ -Subproject commit 27005c8b4d41f2a6d3b85da7eb6ed994b57e0138 +Subproject commit 5209a3f26268fc55b82fbf8a05fbedce160e230f diff --git a/src/Perspex.Controls/Properties/AssemblyInfo.cs b/src/Perspex.Controls/Properties/AssemblyInfo.cs index 7c0a189889..898bc92b87 100644 --- a/src/Perspex.Controls/Properties/AssemblyInfo.cs +++ b/src/Perspex.Controls/Properties/AssemblyInfo.cs @@ -11,4 +11,5 @@ using Perspex.Metadata; [assembly: XmlnsDefinition("https://github.com/perspex", "Perspex.Controls")] [assembly: XmlnsDefinition("https://github.com/perspex", "Perspex.Controls.Presenters")] [assembly: XmlnsDefinition("https://github.com/perspex", "Perspex.Controls.Primitives")] -[assembly: XmlnsDefinition("https://github.com/perspex", "Perspex.Controls.Shapes")] \ No newline at end of file +[assembly: XmlnsDefinition("https://github.com/perspex", "Perspex.Controls.Shapes")] +[assembly: XmlnsDefinition("https://github.com/perspex", "Perspex.Controls.Templates")] \ No newline at end of file diff --git a/src/Perspex.SceneGraph/Properties/AssemblyInfo.cs b/src/Perspex.SceneGraph/Properties/AssemblyInfo.cs index bfe8371a52..e7138be6ab 100644 --- a/src/Perspex.SceneGraph/Properties/AssemblyInfo.cs +++ b/src/Perspex.SceneGraph/Properties/AssemblyInfo.cs @@ -5,4 +5,5 @@ using System.Reflection; using Perspex.Metadata; [assembly: AssemblyTitle("Perspex.SceneGraph")] +[assembly: XmlnsDefinition("https://github.com/perspex", "Perspex.Animation")] [assembly: XmlnsDefinition("https://github.com/perspex", "Perspex.Media")] \ No newline at end of file