-
Notifications
You must be signed in to change notification settings - Fork 636
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create the notifications button * Notification ui popup * fit webview2 into the popup * pointer tooltip and shadow * ViewExtension project * creation of viewextension * Inserting the notification ui into the NotificationsExtension * Load local files * Unit tests * Notifications Icon * Removing old created notifications center * Code refactor * Reverting dynamo sln * Assigning comments * PR comments * Addressing comments * updates * Addressing comments * inserting npm install notifications package * misspelling fix * commenting npm build command * undoing npm command comment * Commenting npm command and adding the js bundle file Co-authored-by: tanga <[email protected]>
- Loading branch information
1 parent
c88bbf8
commit 468d604
Showing
16 changed files
with
517 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using Dynamo.Controls; | ||
using Dynamo.Notifications.View; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Controls.Primitives; | ||
|
||
namespace Dynamo.Notifications | ||
{ | ||
public class NotificationCenterController | ||
{ | ||
NotificationUI notificationUIPopup; | ||
DynamoView dynamoView; | ||
Button notificationsButton; | ||
|
||
private static int notificationPopupHorizontalOffset = -285; | ||
private static int notificationPopupVerticalOffset = 10; | ||
|
||
private static string htmlEmbeddedFile = "Dynamo.Notifications.Web.index.html"; | ||
private static string jsEmbeddedFile = "Dynamo.Notifications.node_modules._dynam0.notificati0ns.index.js"; | ||
|
||
public NotificationCenterController(DynamoView dynamoView) | ||
{ | ||
var shortcutBar = dynamoView.ShortcutBar; | ||
var notificationsButton = (Button)shortcutBar.FindName("notificationsButton"); | ||
|
||
notificationUIPopup = new NotificationUI(); | ||
notificationUIPopup.IsOpen = false; | ||
notificationUIPopup.PlacementTarget = notificationsButton; | ||
notificationUIPopup.Placement = PlacementMode.Bottom; | ||
notificationUIPopup.HorizontalOffset = notificationPopupHorizontalOffset; | ||
notificationUIPopup.VerticalOffset = notificationPopupVerticalOffset; | ||
|
||
this.dynamoView = dynamoView; | ||
this.notificationsButton = notificationsButton; | ||
|
||
this.dynamoView.SizeChanged += DynamoView_SizeChanged; | ||
this.dynamoView.LocationChanged += DynamoView_LocationChanged; | ||
this.notificationsButton.Click += NotificationsButton_Click; | ||
|
||
notificationUIPopup.webView.EnsureCoreWebView2Async(); | ||
notificationUIPopup.webView.CoreWebView2InitializationCompleted += WebView_CoreWebView2InitializationCompleted; | ||
} | ||
|
||
private void WebView_CoreWebView2InitializationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs e) | ||
{ | ||
var assembly = Assembly.GetExecutingAssembly(); | ||
string htmlString = string.Empty; | ||
|
||
using (Stream stream = assembly.GetManifestResourceStream(htmlEmbeddedFile)) | ||
using (StreamReader reader = new StreamReader(stream)) | ||
{ | ||
htmlString = reader.ReadToEnd(); | ||
} | ||
|
||
using (Stream stream = assembly.GetManifestResourceStream(jsEmbeddedFile)) | ||
using (StreamReader reader = new StreamReader(stream)) | ||
{ | ||
var jsString = reader.ReadToEnd(); | ||
htmlString = htmlString.Replace("#mainJs", jsString); | ||
} | ||
|
||
if(notificationUIPopup.webView.CoreWebView2 != null) | ||
notificationUIPopup.webView.CoreWebView2.NavigateToString(htmlString); | ||
} | ||
|
||
internal void Dispose() | ||
{ | ||
notificationUIPopup.webView.CoreWebView2InitializationCompleted -= WebView_CoreWebView2InitializationCompleted; | ||
dynamoView.SizeChanged -= DynamoView_SizeChanged; | ||
dynamoView.LocationChanged -= DynamoView_LocationChanged; | ||
notificationsButton.Click -= NotificationsButton_Click; | ||
} | ||
|
||
private void DynamoView_LocationChanged(object sender, EventArgs e) | ||
{ | ||
notificationUIPopup.Placement = PlacementMode.Bottom; | ||
notificationUIPopup.UpdatePopupLocation(); | ||
} | ||
|
||
private void DynamoView_SizeChanged(object sender, SizeChangedEventArgs e) | ||
{ | ||
notificationUIPopup.Placement = PlacementMode.Bottom; | ||
notificationUIPopup.UpdatePopupLocation(); | ||
} | ||
|
||
private void NotificationsButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
notificationUIPopup.IsOpen = !notificationUIPopup.IsOpen; | ||
if (notificationUIPopup.IsOpen) | ||
notificationUIPopup.webView.Focus(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,102 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ImportGroup Label="PropertySheets"> | ||
<Import Project="$(SolutionDir)Config\CS_SDK.props" /> | ||
</ImportGroup> | ||
<PropertyGroup> | ||
<ProjectGuid>{09F48994-BB2F-4A26-8CCD-469FE3F7F904}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Dynamo.Notifications</RootNamespace> | ||
<AssemblyName>Notifications</AssemblyName> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="FontAwesome.WPF" Version="4.7.0.9" /> | ||
<Reference Include="Microsoft.Practices.Prism"> | ||
<HintPath>..\..\extern\prism\Microsoft.Practices.Prism.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="PresentationCore" /> | ||
<Reference Include="PresentationFramework" /> | ||
<Reference Include="System.Xaml" /> | ||
<Reference Include="WindowsBase" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\DynamoCoreWpf\DynamoCoreWpf.csproj"> | ||
<Project>{51bb6014-43f7-4f31-b8d3-e3c37ebedaf4}</Project> | ||
<Name>DynamoCoreWpf</Name> | ||
<Private>False</Private> | ||
</ProjectReference> | ||
<ProjectReference Include="..\DynamoCore\DynamoCore.csproj"> | ||
<Project>{7858fa8c-475f-4b8e-b468-1f8200778cf8}</Project> | ||
<Name>DynamoCore</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Page Include="NotificationsMenuItem.xaml"> | ||
<SubType>Designer</SubType> | ||
<Generator>MSBuild:Compile</Generator> | ||
</Page> | ||
<Page Include="NotificationsView.xaml"> | ||
<SubType>Designer</SubType> | ||
<Generator>MSBuild:Compile</Generator> | ||
</Page> | ||
<Page Include="Styles\DynamoModern.xaml"> | ||
<Generator>MSBuild:Compile</Generator> | ||
<SubType>Designer</SubType> | ||
</Page> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Update="Properties\Resources.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DesignTime>True</DesignTime> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
</Compile> | ||
<Compile Update="Properties\Resources.en-US.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DesignTime>True</DesignTime> | ||
<DependentUpon>Resources.en-US.resx</DependentUpon> | ||
</Compile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Update="Properties\Resources.resx"> | ||
<Generator>PublicResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
</EmbeddedResource> | ||
<EmbeddedResource Update="Properties\Resources.en-US.resx"> | ||
<Generator>PublicResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.en-US.Designer.cs</LastGenOutput> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
<Target Name="AfterBuildOps" AfterTargets="Build"> | ||
<ItemGroup> | ||
<ExtensionDefinition Include="Notifications_ViewExtensionDefinition.xml" /> | ||
</ItemGroup> | ||
<Copy SourceFiles="@(ExtensionDefinition)" DestinationFolder="$(OutputPath)\viewExtensions\" /> | ||
</Target> | ||
<ImportGroup Label="PropertySheets"> | ||
<Import Project="$(SolutionDir)Config\CS_SDK.props" /> | ||
</ImportGroup> | ||
<PropertyGroup> | ||
<ProjectGuid>{09F48994-BB2F-4A26-8CCD-469FE3F7F904}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Dynamo.Notifications</RootNamespace> | ||
<AssemblyName>Notifications</AssemblyName> | ||
</PropertyGroup> | ||
|
||
<!--<Target Name="NpmInstall" Inputs="package.json" Outputs="node_modules/.install-stamp"> | ||
<Exec Command="npm install @dynam0/notificati0ns" /> | ||
</Target> | ||
<Target Name="NpmRunBuild" DependsOnTargets="NpmInstall" BeforeTargets="BeforeBuild"> | ||
<Exec Command="npm install" /> | ||
</Target>--> | ||
|
||
<ItemGroup> | ||
<None Remove="node_modules\%40dynam0\notificati0ns\index.js" /> | ||
<None Remove="View\NotificationUI.xaml" /> | ||
<None Remove="Web\index.html" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="node_modules\@dynam0\notificati0ns\index.js" /> | ||
<EmbeddedResource Include="Web\index.html" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="FontAwesome.WPF" Version="4.7.0.9" /> | ||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1264.42" /> | ||
<Reference Include="Microsoft.Practices.Prism"> | ||
<HintPath>..\..\extern\prism\Microsoft.Practices.Prism.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="PresentationCore" /> | ||
<Reference Include="PresentationFramework" /> | ||
<Reference Include="System.Xaml" /> | ||
<Reference Include="WindowsBase" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\DynamoCoreWpf\DynamoCoreWpf.csproj"> | ||
<Project>{51bb6014-43f7-4f31-b8d3-e3c37ebedaf4}</Project> | ||
<Name>DynamoCoreWpf</Name> | ||
<Private>False</Private> | ||
</ProjectReference> | ||
<ProjectReference Include="..\DynamoCore\DynamoCore.csproj"> | ||
<Project>{7858fa8c-475f-4b8e-b468-1f8200778cf8}</Project> | ||
<Name>DynamoCore</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Page Include="NotificationsMenuItem.xaml"> | ||
<SubType>Designer</SubType> | ||
<Generator>MSBuild:Compile</Generator> | ||
</Page> | ||
<Page Include="NotificationsView.xaml"> | ||
<SubType>Designer</SubType> | ||
<Generator>MSBuild:Compile</Generator> | ||
</Page> | ||
<Page Include="Styles\DynamoModern.xaml"> | ||
<Generator>MSBuild:Compile</Generator> | ||
<SubType>Designer</SubType> | ||
</Page> | ||
<Page Include="View\NotificationUI.xaml"> | ||
<SubType>Designer</SubType> | ||
<Generator>MSBuild:Compile</Generator> | ||
</Page> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Update="Properties\Resources.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DesignTime>True</DesignTime> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
</Compile> | ||
<Compile Update="Properties\Resources.en-US.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DesignTime>True</DesignTime> | ||
<DependentUpon>Resources.en-US.resx</DependentUpon> | ||
</Compile> | ||
<Compile Update="View\NotificationUI.xaml.cs"> | ||
<DependentUpon>NotificationUI.xaml</DependentUpon> | ||
</Compile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Update="Properties\Resources.resx"> | ||
<Generator>PublicResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
</EmbeddedResource> | ||
<EmbeddedResource Update="Properties\Resources.en-US.resx"> | ||
<Generator>PublicResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.en-US.Designer.cs</LastGenOutput> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
<Target Name="AfterBuildOps" AfterTargets="Build"> | ||
<ItemGroup> | ||
<ExtensionDefinition Include="Notifications_ViewExtensionDefinition.xml" /> | ||
</ItemGroup> | ||
<Copy SourceFiles="@(ExtensionDefinition)" DestinationFolder="$(OutputPath)\viewExtensions\" /> | ||
</Target> | ||
</Project> |
Oops, something went wrong.