Browse Source

Merge branch 'ShowTaskbarIcon' of https://github.com/JurjenBiewenga/Avalonia into ShowTaskbarIcon

pull/1146/head
Jurjen Biewenga 9 years ago
parent
commit
33200e8296
  1. 6
      .gitignore
  2. 13
      docs/guidelines/build.md
  3. 16
      src/Gtk/Avalonia.Gtk3/Interop/Resolver.cs
  4. 11
      src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs
  5. 15
      src/Windows/Avalonia.Win32/SystemDialogImpl.cs

6
.gitignore

@ -159,6 +159,12 @@ $RECYCLE.BIN/
*.userprefs *.userprefs
*.nugetreferenceswitcher *.nugetreferenceswitcher
#################
## Rider
#################
.idea
################# #################
## Cake ## Cake
################# #################

13
docs/guidelines/build.md

@ -80,10 +80,11 @@ mono ./samples/ControlCatalog.Desktop/bin/Debug/ControlCatalog.Desktop.exe
### Building Avalonia in MonoDevelop ### Building Avalonia in MonoDevelop
Unless you have a very current version of monodevelop (6.1.x or newer), it is necessary to manually Flatpak version will *NOT* work. Version from https://github.com/cra0zy/monodevelop-run-installer/ might work if you are very lucky. Make sure that you have the latest version of Mono (from alpha update channel) and .NET Core SDK. Make sure to follow `FrameworkPathOverride` workaround from https://github.com/dotnet/sdk/issues/335
restore the Nuget depdendencies as [mentioned above](#restore-nuget-packages). You must then
disable MonoDevelop's inbuilt NuGet package manager add-in by going to `Tools -> Add-in Manager` or ### Building and running Avalonia in Rider
it will complain that a newer version of NuGet is needed.
For Linux/OSX you'll probably need to apply workaround from https://github.com/dotnet/sdk/issues/335
Just add `export FrameworkPathOverride=/usr/lib/mono/4.6.1-api` (or `export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.6.1-api` for OSX)
Finally, select the `Debug | Mono` or `Release | Mono` build configuration and you should be good to
go!

16
src/Gtk/Avalonia.Gtk3/Interop/Resolver.cs

@ -104,14 +104,16 @@ namespace Avalonia.Gtk3.Interop
var path = Custom?.Lookup(dll); var path = Custom?.Lookup(dll);
if (path == null && Custom?.BasePath != null) if (path == null && Custom?.BasePath != null)
path = Path.Combine(Custom.BasePath, name); path = Path.Combine(Custom.BasePath, name);
if (path != null)
try
{
return loader.LoadLibrary(path);
}
catch (Exception e)
{ {
exceptions.Add(e); try
{
return loader.LoadLibrary(path);
}
catch (Exception e)
{
exceptions.Add(e);
}
} }
throw new AggregateException("Unable to load " + dll, exceptions); throw new AggregateException("Unable to load " + dll, exceptions);
} }

11
src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs

@ -841,14 +841,14 @@ namespace Avalonia.Win32.Interop
return SetClassLong64(hWnd, nIndex, dwNewLong); return SetClassLong64(hWnd, nIndex, dwNewLong);
} }
#if !NETSTANDARD && !NETSTANDARD2_0
[ComImport, ClassInterface(ClassInterfaceType.None), TypeLibType(TypeLibTypeFlags.FCanCreate), Guid("DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7")] [DllImport("ole32.dll", PreserveSig = true)]
internal class FileOpenDialogRCW { } internal static extern int CoCreateInstance(ref Guid clsid,
IntPtr ignore1, int ignore2, ref Guid iid, [MarshalAs(UnmanagedType.IUnknown), Out] out object pUnkOuter);
[DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = true)] [DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int SHCreateItemFromParsingName([MarshalAs(UnmanagedType.LPWStr)] string pszPath, IntPtr pbc, ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out IShellItem ppv); internal static extern int SHCreateItemFromParsingName([MarshalAs(UnmanagedType.LPWStr)] string pszPath, IntPtr pbc, ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out IShellItem ppv);
#endif
[DllImport("user32.dll", SetLastError = true)] [DllImport("user32.dll", SetLastError = true)]
public static extern bool OpenClipboard(IntPtr hWndOwner); public static extern bool OpenClipboard(IntPtr hWndOwner);
@ -1183,7 +1183,7 @@ namespace Avalonia.Win32.Interop
public int flagsEx; public int flagsEx;
} }
} }
#if !NETSTANDARD && !NETSTANDARD1_3
[ComImport(), Guid("42F85136-DB7E-439C-85F1-E4075D135FC8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport(), Guid("42F85136-DB7E-439C-85F1-E4075D135FC8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IFileDialog internal interface IFileDialog
{ {
@ -1283,5 +1283,4 @@ namespace Avalonia.Win32.Interop
uint Compare([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, [In] uint hint, out int piOrder); uint Compare([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, [In] uint hint, out int piOrder);
} }
#endif
} }

15
src/Windows/Avalonia.Win32/SystemDialogImpl.cs

@ -100,17 +100,14 @@ namespace Avalonia.Win32
var pofn = &ofn; var pofn = &ofn;
// We should save the current directory to restore it later. // We should save the current directory to restore it later.
#if !NETSTANDARD
var currentDirectory = Environment.CurrentDirectory; var currentDirectory = Environment.CurrentDirectory;
#endif
var res = dialog is OpenFileDialog var res = dialog is OpenFileDialog
? UnmanagedMethods.GetOpenFileName(new IntPtr(pofn)) ? UnmanagedMethods.GetOpenFileName(new IntPtr(pofn))
: UnmanagedMethods.GetSaveFileName(new IntPtr(pofn)); : UnmanagedMethods.GetSaveFileName(new IntPtr(pofn));
// Restore the old current directory, since GetOpenFileName and GetSaveFileName change it after they're called // Restore the old current directory, since GetOpenFileName and GetSaveFileName change it after they're called
#if !NETSTANDARD
Environment.CurrentDirectory = currentDirectory; Environment.CurrentDirectory = currentDirectory;
#endif
if (!res) if (!res)
return null; return null;
@ -155,15 +152,16 @@ namespace Avalonia.Win32
public Task<string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent) public Task<string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent)
{ {
#if NETSTANDARD
throw new NotImplementedException();
#else
return Task.Factory.StartNew(() => return Task.Factory.StartNew(() =>
{ {
string result = string.Empty; string result = string.Empty;
var hWnd = parent?.Handle?.Handle ?? IntPtr.Zero; var hWnd = parent?.Handle?.Handle ?? IntPtr.Zero;
var frm = (IFileDialog)(new UnmanagedMethods.FileOpenDialogRCW()); var clsid = Guid.Parse("DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7");
var iid = Guid.Parse("42F85136-DB7E-439C-85F1-E4075D135FC8");
UnmanagedMethods.CoCreateInstance(ref clsid, IntPtr.Zero, 1, ref iid, out var unk);
var frm = (IFileDialog)unk;
uint options; uint options;
frm.GetOptions(out options); frm.GetOptions(out options);
options |= (uint)(UnmanagedMethods.FOS.FOS_PICKFOLDERS | UnmanagedMethods.FOS.FOS_FORCEFILESYSTEM | UnmanagedMethods.FOS.FOS_NOVALIDATE | UnmanagedMethods.FOS.FOS_NOTESTFILECREATE | UnmanagedMethods.FOS.FOS_DONTADDTORECENT); options |= (uint)(UnmanagedMethods.FOS.FOS_PICKFOLDERS | UnmanagedMethods.FOS.FOS_FORCEFILESYSTEM | UnmanagedMethods.FOS.FOS_NOVALIDATE | UnmanagedMethods.FOS.FOS_NOTESTFILECREATE | UnmanagedMethods.FOS.FOS_DONTADDTORECENT);
@ -214,7 +212,6 @@ namespace Avalonia.Win32
return result; return result;
}); });
#endif
} }
} }
} }

Loading…
Cancel
Save