Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell creates a dynamic window with a webview2 control #101

Merged
merged 49 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
80afd1e
Shell creates a dynamic window with a webview2 control
kruplm Oct 20, 2022
65bc499
Eliminate the creation of unnecessary Window objects
kruplm Oct 28, 2022
65e926a
Set up layout in xaml
kruplm Oct 28, 2022
ae57ae4
Opening WebContent Window with a button.
kruplm Oct 28, 2022
de92fd4
Remove unnecessary Show() event.
kruplm Nov 3, 2022
c859caf
Removed unnecessary wrapper function
kruplm Nov 3, 2022
0df7f05
Opening multiple child windows
kruplm Nov 15, 2022
91c2538
Closing child windows upon app closing
kruplm Nov 16, 2022
2b44ba9
Rearange layout
kruplm Nov 16, 2022
75eed79
Clean-up code
kruplm Nov 16, 2022
4712876
Add license headers
kruplm Nov 16, 2022
4dfa1b1
Remove empty lines
kruplm Nov 16, 2022
6e6c9bb
URL from manifest file
kruplm Nov 18, 2022
1fb9852
Multiple child windows from manifest file
kruplm Nov 23, 2022
5628ee1
Move to Manifest namespace
kruplm Nov 23, 2022
3ef7103
Pass manifest filepath as a parameter
kruplm Nov 23, 2022
ae08744
Add license headers
kruplm Nov 23, 2022
5c25c44
Simplify ForEach loop
kruplm Nov 23, 2022
3acc7bb
Refine Child Window handling
kruplm Dec 5, 2022
7294926
webContentList is internal
kruplm Dec 6, 2022
2d72362
Upgrade WebView2
kruplm Dec 13, 2022
e18cf5e
Shell creates a dynamic window with a webview2 control
kruplm Oct 20, 2022
a6f74cc
Eliminate the creation of unnecessary Window objects
kruplm Oct 28, 2022
5b1d4d9
Set up layout in xaml
kruplm Oct 28, 2022
9d1b173
Opening WebContent Window with a button.
kruplm Oct 28, 2022
27ffdcf
Remove unnecessary Show() event.
kruplm Nov 3, 2022
e432342
Removed unnecessary wrapper function
kruplm Nov 3, 2022
29351a9
Opening multiple child windows
kruplm Nov 15, 2022
8ac1b3b
Closing child windows upon app closing
kruplm Nov 16, 2022
3bb4e42
Rearange layout
kruplm Nov 16, 2022
4344c05
Clean-up code
kruplm Nov 16, 2022
bc2fe15
Add license headers
kruplm Nov 16, 2022
0617e14
Remove empty lines
kruplm Nov 16, 2022
0e2ab30
URL from manifest file
kruplm Nov 18, 2022
7becbef
Multiple child windows from manifest file
kruplm Nov 23, 2022
788a6ab
Move to Manifest namespace
kruplm Nov 23, 2022
2659d53
Pass manifest filepath as a parameter
kruplm Nov 23, 2022
457f55f
Add license headers
kruplm Nov 23, 2022
2291b12
Simplify ForEach loop
kruplm Nov 23, 2022
07950da
Refine Child Window handling
kruplm Dec 5, 2022
679affd
webContentList is internal
kruplm Dec 6, 2022
93a3f7e
Upgrade WebView2
kruplm Dec 13, 2022
667c289
Clean-up code
kruplm Dec 15, 2022
53a4ed2
Resolve Merge Conflict
kruplm Dec 15, 2022
171456c
Simplify manifest parsing
kruplm Dec 15, 2022
2f465f7
Clean-up
kruplm Dec 15, 2022
6418dc0
Buttons are dynamic
kruplm Dec 16, 2022
826b31f
Url through DataContext
kruplm Dec 19, 2022
694c268
Merge branch 'main' into webview2-control
kruplm Dec 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Tryouts/Prototypes/Shell/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
********************************************************************************************************
Morgan Stanley makes this available to you under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
See the NOTICE file distributed with this work for additional information regarding copyright ownership.
Unless required by applicable law or agreed to in writing, software distributed under the License
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
********************************************************************************************************
-->

<Application x:Class="Shell.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Shell"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
33 changes: 33 additions & 0 deletions Tryouts/Prototypes/Shell/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// /*
// * Morgan Stanley makes this available to you under the Apache License,
// * Version 2.0 (the "License"). You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0.
// *
// * See the NOTICE file distributed with this work for additional information
// * regarding copyright ownership. Unless required by applicable law or agreed
// * to in writing, software distributed under the License is distributed on an
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// * or implied. See the License for the specific language governing permissions
// * and limitations under the License.
// */

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows;

namespace Shell
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{

}
}
24 changes: 24 additions & 0 deletions Tryouts/Prototypes/Shell/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// /*
// * Morgan Stanley makes this available to you under the Apache License,
// * Version 2.0 (the "License"). You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0.
// *
// * See the NOTICE file distributed with this work for additional information
// * regarding copyright ownership. Unless required by applicable law or agreed
// * to in writing, software distributed under the License is distributed on an
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// * or implied. See the License for the specific language governing permissions
// * and limitations under the License.
// */

using System.Windows;

[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)
)]
28 changes: 28 additions & 0 deletions Tryouts/Prototypes/Shell/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--
********************************************************************************************************
Morgan Stanley makes this available to you under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
See the NOTICE file distributed with this work for additional information regarding copyright ownership.
Unless required by applicable law or agreed to in writing, software distributed under the License
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
********************************************************************************************************
-->

<Window x:Class="Shell.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Shell"
mc:Ignorable="d"
Title="Compose" Height="450" Width="800">
<DockPanel Background="#002B51">
<Label DockPanel.Dock="Top" Foreground="White" FontSize="20">Hello Compose!</Label>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" HorizontalAlignment="Center">
<Button x:Name="ButtonGo" HorizontalAlignment="Center" DockPanel.Dock="Right" Click="ShowChild_Click" Content="Open morganstanley.com" Background="#FFF2F2F2" Padding="5" Margin="20" Height="40"/>
<Button x:Name="ButtonGo2" HorizontalAlignment="Center" DockPanel.Dock="Right" Click="ShowChild_Click2" Content="Open microsoft.com" Background="#FFF2F2F2" Padding="5" Margin="20" Height="40"/>
<Button x:Name="ButtonGo3" HorizontalAlignment="Center" DockPanel.Dock="Right" Click="ShowChild_Click3" Content="Open google.com" Background="#FFF2F2F2" Padding="5" Margin="20" Height="40"/>
</StackPanel>
</DockPanel>
</Window>
76 changes: 76 additions & 0 deletions Tryouts/Prototypes/Shell/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// /*
// * Morgan Stanley makes this available to you under the Apache License,
// * Version 2.0 (the "License"). You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0.
// *
// * See the NOTICE file distributed with this work for additional information
// * regarding copyright ownership. Unless required by applicable law or agreed
// * to in writing, software distributed under the License is distributed on an
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// * or implied. See the License for the specific language governing permissions
// * and limitations under the License.
// */

using Manifest;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Shell
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
internal static List<WebContent> webContentList { get; set; } = new List<WebContent>();
kruplm marked this conversation as resolved.
Show resolved Hide resolved
private ManifestModel config;
private ModuleModel[]? modules;

public MainWindow()
{
InitializeComponent();

config = new ManifestParser().manifest;
modules = config.Modules;
}

private void UpdateViews(ModuleModel item) {
kruplm marked this conversation as resolved.
Show resolved Hide resolved

var webContent = new WebContent(item.Url);
webContent.Title = item.AppName;

webContent.Owner = this;

webContentList.Add(webContent);
webContent.Show();
}

private void ShowChild_Click(object sender, RoutedEventArgs e)
{
this.UpdateViews(modules[0]);
}

private void ShowChild_Click2(object sender, RoutedEventArgs e)
{
this.UpdateViews(modules[1]);
}

private void ShowChild_Click3(object sender, RoutedEventArgs e)
{
this.UpdateViews(modules[2]);
kruplm marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
36 changes: 36 additions & 0 deletions Tryouts/Prototypes/Shell/Manifest/ManifestModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// /*
// * Morgan Stanley makes this available to you under the Apache License,
// * Version 2.0 (the "License"). You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0.
// *
// * See the NOTICE file distributed with this work for additional information
// * regarding copyright ownership. Unless required by applicable law or agreed
// * to in writing, software distributed under the License is distributed on an
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// * or implied. See the License for the specific language governing permissions
// * and limitations under the License.
// */

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;
using System.Text.Json;

namespace Manifest
{
[Serializable]
internal sealed class ManifestModel
{
public ModuleModel[]? Modules { get; set; }

public static JsonSerializerOptions JsonSerializerOptions = new()
{
PropertyNameCaseInsensitive = true
};
}
}



54 changes: 54 additions & 0 deletions Tryouts/Prototypes/Shell/Manifest/ManifestParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// /*
// * Morgan Stanley makes this available to you under the Apache License,
// * Version 2.0 (the "License"). You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0.
// *
// * See the NOTICE file distributed with this work for additional information
// * regarding copyright ownership. Unless required by applicable law or agreed
// * to in writing, software distributed under the License is distributed on an
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// * or implied. See the License for the specific language governing permissions
// * and limitations under the License.
// */

using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Policy;
using System.Text;
using System.Text.Json;
using System.Windows.Automation;
using System.Windows.Controls.Primitives;

namespace Manifest
{
internal class ManifestParser
{
internal ManifestModel manifest { get; set; }
kruplm marked this conversation as resolved.
Show resolved Hide resolved

public ManifestParser()
{
OpenManifestFile("./Manifest/exampleManifest.json");
}

public void OpenManifestFile(string manifestFile)
{
using (StreamReader r = new StreamReader(manifestFile))
kruplm marked this conversation as resolved.
Show resolved Hide resolved
{
try
{
string fileContent = r.ReadToEnd();
manifest = JsonSerializer.Deserialize<ManifestModel>(fileContent, ManifestModel.JsonSerializerOptions);
kruplm marked this conversation as resolved.
Show resolved Hide resolved
}
catch (Exception e)
kruplm marked this conversation as resolved.
Show resolved Hide resolved
{

throw;
}

r.Close();
}
}
}
}
27 changes: 27 additions & 0 deletions Tryouts/Prototypes/Shell/Manifest/ModuleModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// /*
// * Morgan Stanley makes this available to you under the Apache License,
// * Version 2.0 (the "License"). You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0.
// *
// * See the NOTICE file distributed with this work for additional information
// * regarding copyright ownership. Unless required by applicable law or agreed
// * to in writing, software distributed under the License is distributed on an
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// * or implied. See the License for the specific language governing permissions
// * and limitations under the License.
// */

using System;
using System.Collections.Generic;
using System.Text;

namespace Manifest
{
[Serializable]
kruplm marked this conversation as resolved.
Show resolved Hide resolved
internal sealed class ModuleModel
{
public string AppName { get; set; } = string.Empty;
public string Url { get; set; } = string.Empty;
}
}
16 changes: 16 additions & 0 deletions Tryouts/Prototypes/Shell/Manifest/exampleManifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"modules":[
{
"appName": "TestApp",
"url": "http://www.morganstanley.com"
},
{
"appName": "TestApp2",
"url": "http://www.microsoft.com"
},
{
"appName": "TestApp3",
"url": "http://www.google.com"
}
]
}
33 changes: 33 additions & 0 deletions Tryouts/Prototypes/Shell/Shell.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<EnableDefaultPageItems>false</EnableDefaultPageItems>
</PropertyGroup>

<ItemGroup>
<None Remove="MainWindow.xaml" />
<None Remove="WebContent.xaml" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1462.37" />
</ItemGroup>

<ItemGroup>
<Page Include="MainWindow.xaml" />
<Page Include="WebContent.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>

<ItemGroup>
<None Update="Manifest\exampleManifest.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions Tryouts/Prototypes/Shell/Shell.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shell", "Shell.csproj", "{E82FEAE8-FDB2-45A6-93B6-E94E5478C796}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E82FEAE8-FDB2-45A6-93B6-E94E5478C796}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E82FEAE8-FDB2-45A6-93B6-E94E5478C796}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E82FEAE8-FDB2-45A6-93B6-E94E5478C796}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E82FEAE8-FDB2-45A6-93B6-E94E5478C796}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4C901E6C-4B9A-48C2-AB16-461040DC57B4}
EndGlobalSection
EndGlobal
Loading