diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/App.config b/Samples/Islands/DrawingIsland/CalculatorDemo/App.config new file mode 100644 index 000000000..51fffc74b --- /dev/null +++ b/Samples/Islands/DrawingIsland/CalculatorDemo/App.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/App.cs b/Samples/Islands/DrawingIsland/CalculatorDemo/App.cs new file mode 100644 index 000000000..4ee71a09d --- /dev/null +++ b/Samples/Islands/DrawingIsland/CalculatorDemo/App.cs @@ -0,0 +1,31 @@ +// // Copyright (c) Microsoft. All rights reserved. +// // Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.UI.Dispatching; +using System.Windows; + +namespace CalculatorDemo +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + // Many WinAppSDK APIs require a DispatcherQueue to be running on the thread. We'll start one when the app starts up + // and shut it down when the app is finished. + protected override void OnStartup(StartupEventArgs e) + { + _dispatcherQueueController = DispatcherQueueController.CreateOnCurrentThread(); + base.OnStartup(e); + } + + protected override void OnExit(ExitEventArgs e) + { + base.OnExit(e); + _dispatcherQueueController?.ShutdownQueue(); + _dispatcherQueueController = null; + } + + DispatcherQueueController? _dispatcherQueueController; + } +} \ No newline at end of file diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/App.xaml b/Samples/Islands/DrawingIsland/CalculatorDemo/App.xaml new file mode 100644 index 000000000..d9362e4e3 --- /dev/null +++ b/Samples/Islands/DrawingIsland/CalculatorDemo/App.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/CalculatorDemo.csproj b/Samples/Islands/DrawingIsland/CalculatorDemo/CalculatorDemo.csproj new file mode 100644 index 000000000..2778ec86c --- /dev/null +++ b/Samples/Islands/DrawingIsland/CalculatorDemo/CalculatorDemo.csproj @@ -0,0 +1,147 @@ + + + + net9.0-windows10.0.22621.0 + true + false + x64;ARM64;x86 + + + win-x64;win-x86;win-arm64 + + + false + false + + + Debug + AnyCPU + {5731865D-6685-47A7-8877-5DBAF39B54CD} + WinExe + Properties + CalculatorDemo + CalculatorDemo + 512 + 4 + true + + + AnyCPU + true + portable + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + true + portable + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + true + portable + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + + + + + + + + diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/MainWindow.cs b/Samples/Islands/DrawingIsland/CalculatorDemo/MainWindow.cs new file mode 100644 index 000000000..b720cdb40 --- /dev/null +++ b/Samples/Islands/DrawingIsland/CalculatorDemo/MainWindow.cs @@ -0,0 +1,506 @@ +// // Copyright (c) Microsoft. All rights reserved. +// // Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.UI; +using Microsoft.UI.Windowing; +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Interop; +using Windows.ApplicationModel.Contacts; + +namespace CalculatorDemo +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public sealed partial class MainWindow : Window + { + private static PaperTrail _paper; + private Operation _lastOper; + private string _lastVal; + private string _memVal; + private AppWindow _appWindow; + private Microsoft.UI.Composition.Compositor _compositor; + + public MainWindow() + { + InitializeComponent(); + _paper = new PaperTrail(this); + ProcessKey('0'); + EraseDisplay = true; + _compositor = new Microsoft.UI.Composition.Compositor(); + } + + /// + /// Flag to erase or just add to current display flag + /// + private bool EraseDisplay { get; set; } + + /// + /// Get/Set Memory cell value + /// + private double Memory + { + get + { + if (_memVal == string.Empty) + return 0.0; + return Convert.ToDouble(_memVal); + } + set { _memVal = value.ToString(CultureInfo.InvariantCulture); } + } + + //Lats value entered + private string LastValue + { + get + { + if (_lastVal == string.Empty) + return "0"; + return _lastVal; + } + set { _lastVal = value; } + } + + //The current Calculator display + private string Display { get; set; } + // Sample event handler: + private void OnWindowKeyDown(object sender, TextCompositionEventArgs /*System.Windows.Input.KeyEventArgs*/ e) + { + var s = e.Text; + var c = (s.ToCharArray())[0]; + e.Handled = true; + + if ((c >= '0' && c <= '9') || c == '.' || c == '\b') // '\b' is backspace + { + ProcessKey(c); + return; + } + switch (c) + { + case '+': + ProcessOperation("BPlus"); + break; + case '-': + ProcessOperation("BMinus"); + break; + case '*': + ProcessOperation("BMultiply"); + break; + case '/': + ProcessOperation("BDevide"); + break; + case '%': + ProcessOperation("BPercent"); + break; + case '=': + ProcessOperation("BEqual"); + break; + } + } + + private void DigitBtn_Click(object sender, RoutedEventArgs e) + { + var s = ((Button) sender).Content.ToString(); + + //char[] ids = ((Button)sender).ID.ToCharArray(); + var ids = s.ToCharArray(); + ProcessKey(ids[0]); + } + + private void ProcessKey(char c) + { + if (EraseDisplay) + { + Display = string.Empty; + EraseDisplay = false; + } + AddToDisplay(c); + } + + private void ProcessOperation(string s) + { + var d = 0.0; + switch (s) + { + case "BPM": + _lastOper = Operation.Negate; + LastValue = Display; + CalcResults(); + LastValue = Display; + EraseDisplay = true; + _lastOper = Operation.None; + break; + case "BDevide": + + if (EraseDisplay) //stil wait for a digit... + { + //stil wait for a digit... + _lastOper = Operation.Devide; + break; + } + CalcResults(); + _lastOper = Operation.Devide; + LastValue = Display; + EraseDisplay = true; + break; + case "BMultiply": + if (EraseDisplay) //stil wait for a digit... + { + //stil wait for a digit... + _lastOper = Operation.Multiply; + break; + } + CalcResults(); + _lastOper = Operation.Multiply; + LastValue = Display; + EraseDisplay = true; + break; + case "BMinus": + if (EraseDisplay) //stil wait for a digit... + { + //stil wait for a digit... + _lastOper = Operation.Subtract; + break; + } + CalcResults(); + _lastOper = Operation.Subtract; + LastValue = Display; + EraseDisplay = true; + break; + case "BPlus": + if (EraseDisplay) + { + //stil wait for a digit... + _lastOper = Operation.Add; + break; + } + CalcResults(); + _lastOper = Operation.Add; + LastValue = Display; + EraseDisplay = true; + break; + case "BEqual": + if (EraseDisplay) //stil wait for a digit... + break; + CalcResults(); + EraseDisplay = true; + _lastOper = Operation.None; + LastValue = Display; + //val = Display; + break; + case "BSqrt": + _lastOper = Operation.Sqrt; + LastValue = Display; + CalcResults(); + LastValue = Display; + EraseDisplay = true; + _lastOper = Operation.None; + break; + case "BPercent": + if (EraseDisplay) //stil wait for a digit... + { + //stil wait for a digit... + _lastOper = Operation.Percent; + break; + } + CalcResults(); + _lastOper = Operation.Percent; + LastValue = Display; + EraseDisplay = true; + //LastOper = Operation.None; + break; + case "BOneOver": + _lastOper = Operation.OneX; + LastValue = Display; + CalcResults(); + LastValue = Display; + EraseDisplay = true; + _lastOper = Operation.None; + break; + case "BC": //clear All + _lastOper = Operation.None; + Display = LastValue = string.Empty; + _paper.Clear(); + UpdateDisplay(); + break; + case "BCE": //clear entry + _lastOper = Operation.None; + Display = LastValue; + UpdateDisplay(); + break; + case "BMemClear": + Memory = 0.0F; + DisplayMemory(); + break; + case "BMemSave": + Memory = Convert.ToDouble(Display); + DisplayMemory(); + EraseDisplay = true; + break; + case "BMemRecall": + Display = /*val =*/ Memory.ToString(CultureInfo.InvariantCulture); + UpdateDisplay(); + //if (LastOper != Operation.None) //using MR is like entring a digit + EraseDisplay = false; + break; + case "BMemPlus": + d = Memory + Convert.ToDouble(Display); + Memory = d; + DisplayMemory(); + EraseDisplay = true; + break; + } + } + + private void OperBtn_Click(object sender, RoutedEventArgs e) + { + ProcessOperation(((Button) sender).Name); + } + + private double Calc(Operation lastOper) + { + var d = 0.0; + + + try + { + switch (lastOper) + { + case Operation.Devide: + _paper.AddArguments(LastValue + " / " + Display); + d = (Convert.ToDouble(LastValue)/Convert.ToDouble(Display)); + CheckResult(d); + _paper.AddResult(d.ToString(CultureInfo.InvariantCulture)); + break; + case Operation.Add: + _paper.AddArguments(LastValue + " + " + Display); + d = Convert.ToDouble(LastValue) + Convert.ToDouble(Display); + CheckResult(d); + _paper.AddResult(d.ToString(CultureInfo.InvariantCulture)); + break; + case Operation.Multiply: + _paper.AddArguments(LastValue + " * " + Display); + d = Convert.ToDouble(LastValue)*Convert.ToDouble(Display); + CheckResult(d); + _paper.AddResult(d.ToString(CultureInfo.InvariantCulture)); + break; + case Operation.Percent: + //Note: this is different (but make more sense) then Windows calculator + _paper.AddArguments(LastValue + " % " + Display); + d = (Convert.ToDouble(LastValue)*Convert.ToDouble(Display))/100.0F; + CheckResult(d); + _paper.AddResult(d.ToString(CultureInfo.InvariantCulture)); + break; + case Operation.Subtract: + _paper.AddArguments(LastValue + " - " + Display); + d = Convert.ToDouble(LastValue) - Convert.ToDouble(Display); + CheckResult(d); + _paper.AddResult(d.ToString(CultureInfo.InvariantCulture)); + break; + case Operation.Sqrt: + _paper.AddArguments("Sqrt( " + LastValue + " )"); + d = Math.Sqrt(Convert.ToDouble(LastValue)); + CheckResult(d); + _paper.AddResult(d.ToString(CultureInfo.InvariantCulture)); + break; + case Operation.OneX: + _paper.AddArguments("1 / " + LastValue); + d = 1.0F/Convert.ToDouble(LastValue); + CheckResult(d); + _paper.AddResult(d.ToString(CultureInfo.InvariantCulture)); + break; + case Operation.Negate: + d = Convert.ToDouble(LastValue)*(-1.0F); + break; + } + } + catch + { + d = 0; + var parent = (Window) MyPanel.Parent; + _paper.AddResult("Error"); + MessageBox.Show(parent, "Operation cannot be perfomed", parent.Title); + } + + return d; + } + + private void CheckResult(double d) + { + if (double.IsNegativeInfinity(d) || double.IsPositiveInfinity(d) || double.IsNaN(d)) + throw new Exception("Illegal value"); + } + + private void DisplayMemory() + { + if (_memVal != string.Empty) + BMemBox.Text = "Memory: " + _memVal; + else + BMemBox.Text = "Memory: [empty]"; + } + + private void CalcResults() + { + double d; + if (_lastOper == Operation.None) + return; + + d = Calc(_lastOper); + Display = d.ToString(CultureInfo.InvariantCulture); + + UpdateDisplay(); + } + + private void UpdateDisplay() + { + DisplayBox.Text = Display == string.Empty ? "0" : Display; + } + + private void AddToDisplay(char c) + { + if (c == '.') + { + if (Display.IndexOf('.', 0) >= 0) //already exists + return; + Display = Display + c; + } + else + { + if (c >= '0' && c <= '9') + { + Display = Display + c; + } + else if (c == '\b') //backspace ? + { + if (Display.Length <= 1) + Display = string.Empty; + else + { + var i = Display.Length; + Display = Display.Remove(i - 1, 1); //remove last char + } + } + } + + UpdateDisplay(); + } + + private void OnMenuAbout(object sender, RoutedEventArgs e) + { + var parent = (Window) MyPanel.Parent; + MessageBox.Show(parent, parent.Title + " - By Jossef Goldberg ", parent.Title, MessageBoxButton.OK, + MessageBoxImage.Information); + } + + private void OnMenuExit(object sender, RoutedEventArgs e) + { + Close(); + } + + private void OnMenuStandard(object sender, RoutedEventArgs e) + { + //((MenuItem)ScientificMenu).IsChecked = false; + StandardMenu.IsChecked = true; //for now always Standard + } + + private void OnMenuScientific(object sender, RoutedEventArgs e) + { + //((MenuItem)StandardMenu).IsChecked = false; + } + + private enum Operation + { + None, + Devide, + Multiply, + Subtract, + Add, + Percent, + Sqrt, + OneX, + Negate + } + + private class PaperTrail + { + private readonly MainWindow _window; + private string _args; + + public PaperTrail(MainWindow window) + { + _window = window; + } + + public void AddArguments(string a) + { + _args = a; + } + + public void AddResult(string r) + { + _window.PaperBox.Text += _args + " = " + r + "\n"; + } + + public void Clear() + { + _window.PaperBox.Text = string.Empty; + _args = string.Empty; + } + } + + private void CompactView_Click(object sender, RoutedEventArgs e) + { + SetCompactView(true); + } + + private void ExitCompactViewButton_Click(object sender, RoutedEventArgs e) + { + SetCompactView(false); + } + + void SetCompactView(bool useCompactView) + { + // Ensure we have an AppWindow for this WPF Window. + if (_appWindow == null) + { + _appWindow = AppWindow.GetFromWindowId( + new WindowId((ulong)new WindowInteropHelper(this).Handle)); + } + + if (useCompactView) + { + // For compact view, hide the main panel and show the compact panel. + MyPanel.Visibility = Visibility.Collapsed; + CompactPanel.Visibility = Visibility.Visible; + + CompactViewText.Text = DisplayBox.Text; + + // The AppWindow's CompactOverlay mode will make it always-on-top. + _appWindow.SetPresenter(AppWindowPresenterKind.CompactOverlay); + _appWindow.ResizeClient(new Windows.Graphics.SizeInt32(300, 80)); + } + else + { + MyPanel.Visibility = Visibility.Visible; + CompactPanel.Visibility = Visibility.Collapsed; + + _appWindow.SetPresenter(AppWindowPresenterKind.Default); + } + } + + private void CreateDrawingIslandMenuItem_Click(object sender, RoutedEventArgs e) + { + var wpfIslandHost = new WpfIslandHost(_compositor); + var drawingIsland = new DrawingIslandComponents.DrawingIsland(_compositor); + + // After this, the WpfIslandHost will be live, and the DesktopChildSiteBridge will be available. + DisplayAreaBorder.Child = wpfIslandHost; + + wpfIslandHost.DesktopChildSiteBridge.Connect(drawingIsland.Island); + } + } +} \ No newline at end of file diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/MainWindow.xaml b/Samples/Islands/DrawingIsland/CalculatorDemo/MainWindow.xaml new file mode 100644 index 000000000..030847680 --- /dev/null +++ b/Samples/Islands/DrawingIsland/CalculatorDemo/MainWindow.xaml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Memory: [empty] + + + + + + + + + + + + + + + + + diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/MyTextBox.cs b/Samples/Islands/DrawingIsland/CalculatorDemo/MyTextBox.cs new file mode 100644 index 000000000..f42222459 --- /dev/null +++ b/Samples/Islands/DrawingIsland/CalculatorDemo/MyTextBox.cs @@ -0,0 +1,17 @@ +// // Copyright (c) Microsoft. All rights reserved. +// // Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Windows.Controls; +using System.Windows.Input; + +namespace CalculatorDemo +{ + internal sealed class MyTextBox : TextBox + { + protected override void OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs e) + { + e.Handled = true; + base.OnPreviewGotKeyboardFocus(e); + } + } +} \ No newline at end of file diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/Properties/AssemblyInfo.cs b/Samples/Islands/DrawingIsland/CalculatorDemo/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..5dcea412b --- /dev/null +++ b/Samples/Islands/DrawingIsland/CalculatorDemo/Properties/AssemblyInfo.cs @@ -0,0 +1,59 @@ +// // Copyright (c) Microsoft. All rights reserved. +// // Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Reflection; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly: AssemblyTitle("CalculatorDemo")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CalculatorDemo")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. + +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) + )] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] + +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/Properties/Resources.Designer.cs b/Samples/Islands/DrawingIsland/CalculatorDemo/Properties/Resources.Designer.cs new file mode 100644 index 000000000..66e92c0be --- /dev/null +++ b/Samples/Islands/DrawingIsland/CalculatorDemo/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace CalculatorDemo.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CalculatorDemo.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/Properties/Resources.resx b/Samples/Islands/DrawingIsland/CalculatorDemo/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Samples/Islands/DrawingIsland/CalculatorDemo/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/Properties/Settings.Designer.cs b/Samples/Islands/DrawingIsland/CalculatorDemo/Properties/Settings.Designer.cs new file mode 100644 index 000000000..0610885f1 --- /dev/null +++ b/Samples/Islands/DrawingIsland/CalculatorDemo/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace CalculatorDemo.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/Properties/Settings.settings b/Samples/Islands/DrawingIsland/CalculatorDemo/Properties/Settings.settings new file mode 100644 index 000000000..c14891b94 --- /dev/null +++ b/Samples/Islands/DrawingIsland/CalculatorDemo/Properties/Settings.settings @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/WpfIslandHost.cs b/Samples/Islands/DrawingIsland/CalculatorDemo/WpfIslandHost.cs new file mode 100644 index 000000000..34bf02a09 --- /dev/null +++ b/Samples/Islands/DrawingIsland/CalculatorDemo/WpfIslandHost.cs @@ -0,0 +1,34 @@ +using Microsoft.UI.Composition; +using Microsoft.UI.Content; +using System.Runtime.InteropServices; +using System.Windows.Interop; + +namespace CalculatorDemo +{ + internal class WpfIslandHost : HwndHost + { + public WpfIslandHost(Compositor compositor) + { + _compositor = compositor; + } + + public DesktopChildSiteBridge DesktopChildSiteBridge { get; private set; } + + protected override HandleRef BuildWindowCore(HandleRef hwndParent) + { + DesktopChildSiteBridge = Microsoft.UI.Content.DesktopChildSiteBridge.Create( + _compositor, + new Microsoft.UI.WindowId((ulong)hwndParent.Handle)); + + return new HandleRef(null, (nint)DesktopChildSiteBridge.WindowId.Value); + } + + protected override void DestroyWindowCore(HandleRef hwnd) + { + DesktopChildSiteBridge.Dispose(); + DesktopChildSiteBridge = null; + } + + Microsoft.UI.Composition.Compositor _compositor; + } +} \ No newline at end of file diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/appicon.ico b/Samples/Islands/DrawingIsland/CalculatorDemo/appicon.ico new file mode 100644 index 000000000..2cec3ddd0 Binary files /dev/null and b/Samples/Islands/DrawingIsland/CalculatorDemo/appicon.ico differ diff --git a/Samples/Islands/DrawingIsland/CalculatorDemoPackage/CalculatorDemoPackage.wapproj b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/CalculatorDemoPackage.wapproj new file mode 100644 index 000000000..714365817 --- /dev/null +++ b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/CalculatorDemoPackage.wapproj @@ -0,0 +1,77 @@ + + + + 15.0 + + + + Debug + x86 + + + Release + x86 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM64 + + + Release + ARM64 + + + + $(MSBuildExtensionsPath)\Microsoft\DesktopBridge\ + + + + 0a343519-113b-4ef9-959c-30f559524bc4 + 10.0.22621.0 + 10.0.17763.0 + en-US + false + $(NoWarn);NU1702 + ..\CalculatorDemo\CalculatorDemo.csproj + + + + Windows + .NETCoreApp,Version=v9.0 + net9.0-windows10.0.17763.0 + + + + Designer + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/LockScreenLogo.scale-200.png b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/LockScreenLogo.scale-200.png new file mode 100644 index 000000000..735f57adb Binary files /dev/null and b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/LockScreenLogo.scale-200.png differ diff --git a/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/SplashScreen.scale-200.png b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/SplashScreen.scale-200.png new file mode 100644 index 000000000..023e7f1fe Binary files /dev/null and b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/SplashScreen.scale-200.png differ diff --git a/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/Square150x150Logo.scale-200.png b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/Square150x150Logo.scale-200.png new file mode 100644 index 000000000..af49fec1a Binary files /dev/null and b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/Square150x150Logo.scale-200.png differ diff --git a/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/Square44x44Logo.scale-200.png b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/Square44x44Logo.scale-200.png new file mode 100644 index 000000000..ce342a2ec Binary files /dev/null and b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/Square44x44Logo.scale-200.png differ diff --git a/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/Square44x44Logo.targetsize-24_altform-unplated.png b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 000000000..f6c02ce97 Binary files /dev/null and b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/StoreLogo.png b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/StoreLogo.png new file mode 100644 index 000000000..7385b56c0 Binary files /dev/null and b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/StoreLogo.png differ diff --git a/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/Wide310x150Logo.scale-200.png b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/Wide310x150Logo.scale-200.png new file mode 100644 index 000000000..288995b39 Binary files /dev/null and b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Images/Wide310x150Logo.scale-200.png differ diff --git a/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Package.appxmanifest b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Package.appxmanifest new file mode 100644 index 000000000..767f60891 --- /dev/null +++ b/Samples/Islands/DrawingIsland/CalculatorDemoPackage/Package.appxmanifest @@ -0,0 +1,49 @@ + + + + + + + + CalculatorDemoPackage + jecollin + Images\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Islands/DrawingIsland/DrawingIsland.sln b/Samples/Islands/DrawingIsland/DrawingIsland.sln index 74fb743d9..14b58de43 100644 --- a/Samples/Islands/DrawingIsland/DrawingIsland.sln +++ b/Samples/Islands/DrawingIsland/DrawingIsland.sln @@ -13,7 +13,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DrawingCsTestApp", "Drawing EndProject Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "DrawingCsTestPackage", "DrawingCsTestPackage\DrawingCsTestPackage.wapproj", "{3ED80AF8-0D53-4568-8A9A-BCB852B85DC7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DrawingIslandCsProjection", "DrawingIslandCsProjection\DrawingIslandCsProjection.csproj", "{48847923-880A-4A61-99CF-64B8EABD412B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DrawingIslandCsProjection", "DrawingIslandCsProjection\DrawingIslandCsProjection.csproj", "{48847923-880A-4A61-99CF-64B8EABD412B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CalculatorDemo", "CalculatorDemo\CalculatorDemo.csproj", "{5731865D-6685-47A7-8877-5DBAF39B54CD}" +EndProject +Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "CalculatorDemoPackage", "CalculatorDemoPackage\CalculatorDemoPackage.wapproj", "{0A343519-113B-4EF9-959C-30F559524BC4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -109,6 +113,36 @@ Global {48847923-880A-4A61-99CF-64B8EABD412B}.Release|x64.Build.0 = Release|x64 {48847923-880A-4A61-99CF-64B8EABD412B}.Release|x86.ActiveCfg = Release|x86 {48847923-880A-4A61-99CF-64B8EABD412B}.Release|x86.Build.0 = Release|x86 + {5731865D-6685-47A7-8877-5DBAF39B54CD}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {5731865D-6685-47A7-8877-5DBAF39B54CD}.Debug|ARM64.Build.0 = Debug|ARM64 + {5731865D-6685-47A7-8877-5DBAF39B54CD}.Debug|x64.ActiveCfg = Debug|x64 + {5731865D-6685-47A7-8877-5DBAF39B54CD}.Debug|x64.Build.0 = Debug|x64 + {5731865D-6685-47A7-8877-5DBAF39B54CD}.Debug|x86.ActiveCfg = Debug|x86 + {5731865D-6685-47A7-8877-5DBAF39B54CD}.Debug|x86.Build.0 = Debug|x86 + {5731865D-6685-47A7-8877-5DBAF39B54CD}.Release|ARM64.ActiveCfg = Release|ARM64 + {5731865D-6685-47A7-8877-5DBAF39B54CD}.Release|ARM64.Build.0 = Release|ARM64 + {5731865D-6685-47A7-8877-5DBAF39B54CD}.Release|x64.ActiveCfg = Release|x64 + {5731865D-6685-47A7-8877-5DBAF39B54CD}.Release|x64.Build.0 = Release|x64 + {5731865D-6685-47A7-8877-5DBAF39B54CD}.Release|x86.ActiveCfg = Release|x86 + {5731865D-6685-47A7-8877-5DBAF39B54CD}.Release|x86.Build.0 = Release|x86 + {0A343519-113B-4EF9-959C-30F559524BC4}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {0A343519-113B-4EF9-959C-30F559524BC4}.Debug|ARM64.Build.0 = Debug|ARM64 + {0A343519-113B-4EF9-959C-30F559524BC4}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {0A343519-113B-4EF9-959C-30F559524BC4}.Debug|x64.ActiveCfg = Debug|x64 + {0A343519-113B-4EF9-959C-30F559524BC4}.Debug|x64.Build.0 = Debug|x64 + {0A343519-113B-4EF9-959C-30F559524BC4}.Debug|x64.Deploy.0 = Debug|x64 + {0A343519-113B-4EF9-959C-30F559524BC4}.Debug|x86.ActiveCfg = Debug|x86 + {0A343519-113B-4EF9-959C-30F559524BC4}.Debug|x86.Build.0 = Debug|x86 + {0A343519-113B-4EF9-959C-30F559524BC4}.Debug|x86.Deploy.0 = Debug|x86 + {0A343519-113B-4EF9-959C-30F559524BC4}.Release|ARM64.ActiveCfg = Release|ARM64 + {0A343519-113B-4EF9-959C-30F559524BC4}.Release|ARM64.Build.0 = Release|ARM64 + {0A343519-113B-4EF9-959C-30F559524BC4}.Release|ARM64.Deploy.0 = Release|ARM64 + {0A343519-113B-4EF9-959C-30F559524BC4}.Release|x64.ActiveCfg = Release|x64 + {0A343519-113B-4EF9-959C-30F559524BC4}.Release|x64.Build.0 = Release|x64 + {0A343519-113B-4EF9-959C-30F559524BC4}.Release|x64.Deploy.0 = Release|x64 + {0A343519-113B-4EF9-959C-30F559524BC4}.Release|x86.ActiveCfg = Release|x86 + {0A343519-113B-4EF9-959C-30F559524BC4}.Release|x86.Build.0 = Release|x86 + {0A343519-113B-4EF9-959C-30F559524BC4}.Release|x86.Deploy.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Samples/nuget.config b/Samples/nuget.config index 7b954d29d..49af023e1 100644 --- a/Samples/nuget.config +++ b/Samples/nuget.config @@ -14,6 +14,9 @@ + + +