EgtWPFLib48 2.5c1 :

- primo rilascio
This commit is contained in:
Emmanuele Sassi
2023-03-14 15:37:31 +01:00
parent 2e09c230a1
commit 37371ca9d6
13 changed files with 1646 additions and 0 deletions
+330
View File
@@ -0,0 +1,330 @@
# ---> VisualStudio
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# Windows Azure Build Output
csx/
*.build.csdef
# Windows Store app package directory
AppPackages/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# ---> C Sharp
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
[Bb]in/
[Oo]bj/
# mstest test results
TestResults
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.log
*.vspscc
*.vssscc
.builds
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish
# Publish Web Output
*.Publish.xml
# NuGet Packages Directory
packages
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
[Bb]in
[Oo]bj
sql
TestResults
[Tt]est[Rr]esult*
*.Cache
ClientBin
[Ss]tyle[Cc]op.*
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
.ionide/symbolCache.db
+25
View File
@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33205.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EgtWPFLib48", "EgtWPFLib48\EgtWPFLib48.vbproj", "{0FB825B1-2865-422F-8FD2-E5D58D05DAD1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0FB825B1-2865-422F-8FD2-E5D58D05DAD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0FB825B1-2865-422F-8FD2-E5D58D05DAD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0FB825B1-2865-422F-8FD2-E5D58D05DAD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0FB825B1-2865-422F-8FD2-E5D58D05DAD1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {816C1BFC-2FE0-4ED9-8F7D-5E86F235FBA1}
EndGlobalSection
EndGlobal
+430
View File
@@ -0,0 +1,430 @@
' Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
'
' Step 1a) Using this custom control in a XAML file that exists in the current project.
' Add this XmlNamespace attribute to the root element of the markup file where it is
' to be used:
'
' xmlns:MyNamespace="clr-namespace:EgtWPFLib5"
'
'
' Step 1b) Using this custom control in a XAML file that exists in a different project.
' Add this XmlNamespace attribute to the root element of the markup file where it is
' to be used:
'
' xmlns:MyNamespace="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5"
'
' You will also need to add a project reference from the project where the XAML file lives
' to this project and Rebuild to avoid compilation errors:
'
' Right click on the target project in the Solution Explorer and
' "Add Reference"->"Projects"->[Browse to and select this project]
'
'
' Step 2)
' Go ahead and use your control in the XAML file. Note that Intellisense in the
' XML editor does not currently work on custom controls and its child elements.
'
' <MyNamespace:EgtMainWindow/>
'
Imports Microsoft.Win32
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Forms
Imports System.Windows.Input
Imports System.Windows.Interop
Public Class EgtMainWindow
Inherits Window
Private _hwndSource As HwndSource
Private isMouseButtonDown As Boolean
Private isManualDrag As Boolean
Private mouseDownPosition As System.Windows.Point
Private positionBeforeDrag As System.Windows.Point
Private previousScreenBounds As System.Windows.Point
Public Property WindowRoot As Grid
Public Property LayoutRoot As Grid
Public Property MinimizeButton As System.Windows.Controls.Button
Public Property MaximizeButton As System.Windows.Controls.Button
Public Property RestoreButton As System.Windows.Controls.Button
Public Property CloseButton As System.Windows.Controls.Button
Public Property HeaderBar As Grid
Public Property HeightBeforeMaximize As Double
Public Property WidthBeforeMaximize As Double
Public Property PreviousState As WindowState
Shared Sub New()
'This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.
'This style is defined in themes\generic.xaml
DefaultStyleKeyProperty.OverrideMetadata(GetType(EgtMainWindow), New FrameworkPropertyMetadata(GetType(EgtMainWindow)))
End Sub
Public Sub New()
Dim currentDPIScaleFactor As Double = CDbl(SystemHelper.GetCurrentDPIScaleFactor())
Dim screen As Screen = Screen.FromHandle((New WindowInteropHelper(Me)).Handle)
AddHandler MyBase.SizeChanged, AddressOf Me.OnSizeChanged
AddHandler MyBase.StateChanged, AddressOf Me.OnStateChanged
AddHandler MyBase.Loaded, AddressOf Me.OnLoaded
Dim workingArea As Rectangle = screen.WorkingArea
MyBase.MaxHeight = CDbl((workingArea.Height + 16)) / currentDPIScaleFactor
AddHandler SystemEvents.DisplaySettingsChanged, AddressOf Me.SystemEvents_DisplaySettingsChanged
Me.AddHandler(Window.MouseLeftButtonUpEvent, New MouseButtonEventHandler(AddressOf Me.OnMouseButtonUp), True)
Me.AddHandler(Window.MouseMoveEvent, New System.Windows.Input.MouseEventHandler(AddressOf Me.OnMouseMove))
End Sub
Public Sub New(Owner As Window)
Me.New()
Me.Owner = Owner
End Sub
Public Function GetRequiredTemplateChild(Of T As DependencyObject)(ByVal childName As String) As T
Return CType(MyBase.GetTemplateChild(childName), T)
End Function
Public Overrides Sub OnApplyTemplate()
Me.WindowRoot = Me.GetRequiredTemplateChild(Of Grid)("WindowRoot")
Me.LayoutRoot = Me.GetRequiredTemplateChild(Of Grid)("LayoutRoot")
Me.MinimizeButton = Me.GetRequiredTemplateChild(Of System.Windows.Controls.Button)("MinimizeButton")
Me.MaximizeButton = Me.GetRequiredTemplateChild(Of System.Windows.Controls.Button)("MaximizeButton")
Me.RestoreButton = Me.GetRequiredTemplateChild(Of System.Windows.Controls.Button)("RestoreButton")
Me.CloseButton = Me.GetRequiredTemplateChild(Of System.Windows.Controls.Button)("CloseButton")
Me.HeaderBar = Me.GetRequiredTemplateChild(Of Grid)("PART_HeaderBar")
If Me.LayoutRoot IsNot Nothing AndAlso Me.WindowState = WindowState.Maximized Then
Me.LayoutRoot.Margin = GetDefaultMarginForDpi()
End If
If Me.CloseButton IsNot Nothing Then
AddHandler Me.CloseButton.Click, AddressOf CloseButton_Click
End If
If Me.MinimizeButton IsNot Nothing Then
AddHandler Me.MinimizeButton.Click, AddressOf MinimizeButton_Click
End If
If Me.RestoreButton IsNot Nothing Then
AddHandler Me.RestoreButton.Click, AddressOf RestoreButton_Click
End If
If Me.MaximizeButton IsNot Nothing Then
AddHandler Me.MaximizeButton.Click, AddressOf MaximizeButton_Click
End If
If Me.HeaderBar IsNot Nothing Then
Me.HeaderBar.[AddHandler](Grid.MouseLeftButtonDownEvent, New MouseButtonEventHandler(AddressOf Me.OnHeaderBarMouseLeftButtonDown))
End If
MyBase.OnApplyTemplate()
End Sub
Protected Overrides Sub OnInitialized(ByVal e As EventArgs)
AddHandler SourceInitialized, AddressOf OnSourceInitialized
MyBase.OnInitialized(e)
End Sub
' Proprietà che permette di impostare il nome del progetto
Public Shared ReadOnly ProjectNameProperty As DependencyProperty = DependencyProperty.Register("ProjectName", GetType(String), GetType(EgtMainWindow), New PropertyMetadata(""))
Public Property ProjectName() As Double
Get
Return CType(GetValue(ProjectNameProperty), Double)
End Get
Set(ByVal value As Double)
SetValue(ProjectNameProperty, value)
End Set
End Property
' Proprietà che permette di impostare la path del progetto
Public Shared ReadOnly ProjectPathProperty As DependencyProperty = DependencyProperty.Register("ProjectPath", GetType(String), GetType(EgtMainWindow), New PropertyMetadata(""))
Public Property ProjectPath() As Double
Get
Return CType(GetValue(ProjectPathProperty), Double)
End Get
Set(ByVal value As Double)
SetValue(ProjectPathProperty, value)
End Set
End Property
' Proprietà che permette di impostare uno UserControl per aggiungere elementi alla TitleBar
Public Shared ReadOnly TitlePanelProperty As DependencyProperty = DependencyProperty.Register("TitlePanel", GetType(Controls.Panel), GetType(EgtMainWindow), New PropertyMetadata(Nothing))
Public Property TitlePanel() As Controls.Panel
Get
Return DirectCast(GetValue(TitlePanelProperty), Controls.Panel)
End Get
Set(ByVal value As Controls.Panel)
SetValue(TitlePanelProperty, value)
End Set
End Property
' Proprietà che permette di impostare l'altezza della TitleBar
Public Shared ReadOnly CloseCommandProperty As DependencyProperty = DependencyProperty.Register("CloseCommand", GetType(ICommand), GetType(EgtMainWindow), New PropertyMetadata(Nothing))
Public Property CloseCommand() As ICommand
Get
Return DirectCast(GetValue(CloseCommandProperty), ICommand)
End Get
Set(ByVal value As ICommand)
SetValue(CloseCommandProperty, value)
End Set
End Property
Protected Overridable Sub OnHeaderBarMouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
If isManualDrag Then
Return
End If
Dim position As System.Windows.Point = e.GetPosition(Me)
Dim headerBarHeight As Integer = 36
Dim leftmostClickableOffset As Integer = 50
If position.X - Me.LayoutRoot.Margin.Left <= leftmostClickableOffset AndAlso position.Y <= headerBarHeight Then
If e.ClickCount <> 2 Then
Me.OpenSystemContextMenu(e)
Else
MyBase.Close()
End If
e.Handled = True
Return
End If
If e.ClickCount = 2 AndAlso MyBase.ResizeMode = ResizeMode.CanResize Then
Me.ToggleWindowState()
Return
End If
If MyBase.WindowState = WindowState.Maximized Then
Me.isMouseButtonDown = True
Me.mouseDownPosition = position
Else
Try
Me.positionBeforeDrag = New System.Windows.Point(MyBase.Left, MyBase.Top)
Me.DragMove()
Catch
End Try
End If
End Sub
Protected Sub ToggleWindowState()
If MyBase.WindowState <> WindowState.Maximized Then
MyBase.WindowState = WindowState.Maximized
Else
MyBase.WindowState = WindowState.Normal
End If
End Sub
Private Sub MaximizeButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.ToggleWindowState()
End Sub
Private Sub RestoreButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.ToggleWindowState()
End Sub
Private Sub MinimizeButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.WindowState = WindowState.Minimized
End Sub
Private Sub CloseButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
If IsNothing(CloseCommand) Then
Me.Close()
End If
End Sub
Private Shadows Sub OnSourceInitialized(ByVal sender As Object, ByVal e As EventArgs)
_hwndSource = CType(PresentationSource.FromVisual(Me), HwndSource)
End Sub
Private Sub SetMaximizeButtonsVisibility(ByVal maximizeButtonVisibility As Visibility, ByVal reverseMaximizeButtonVisiility As Visibility)
If Me.MaximizeButton IsNot Nothing Then
Me.MaximizeButton.Visibility = maximizeButtonVisibility
End If
If Me.RestoreButton IsNot Nothing Then
Me.RestoreButton.Visibility = reverseMaximizeButtonVisiility
End If
End Sub
Private Sub OpenSystemContextMenu(ByVal e As MouseButtonEventArgs)
Dim position As System.Windows.Point = e.GetPosition(Me)
Dim screen As System.Windows.Point = Me.PointToScreen(position)
Dim num As Integer = 36
If position.Y < CDbl(num) Then
Dim handle As IntPtr = (New WindowInteropHelper(Me)).Handle
Dim systemMenu As IntPtr = NativeUtils.GetSystemMenu(handle, False)
If MyBase.WindowState <> WindowState.Maximized Then
NativeUtils.EnableMenuItem(systemMenu, 61488, 0)
Else
NativeUtils.EnableMenuItem(systemMenu, 61488, 1)
End If
Dim num1 As Integer = NativeUtils.TrackPopupMenuEx(systemMenu, NativeUtils.TPM_LEFTALIGN Or NativeUtils.TPM_RETURNCMD, Convert.ToInt32(screen.X + 2), Convert.ToInt32(screen.Y + 2), handle, IntPtr.Zero)
If num1 = 0 Then
Return
End If
NativeUtils.PostMessage(handle, 274, New IntPtr(num1), IntPtr.Zero)
End If
End Sub
Protected Overridable Function GetDefaultMarginForDpi() As Thickness
Dim currentDPI As Integer = SystemHelper.GetCurrentDPI()
Dim thickness As Thickness = New Thickness(8, 8, 8, 8)
If currentDPI = 120 Then
thickness = New Thickness(7, 7, 7, 6)
ElseIf currentDPI = 144 Then
thickness = New Thickness(7, 7, 7, 3)
ElseIf currentDPI = 168 Then
thickness = New Thickness(7, 7, 7, 2)
ElseIf currentDPI = 192 Then
thickness = New Thickness(6, 6, 0, 0)
ElseIf currentDPI = 240 Then
thickness = New Thickness(6, 6, 0, 0)
End If
Return thickness
End Function
Protected Overridable Function GetFromMinimizedMarginForDpi() As Thickness
Dim currentDPI As Integer = SystemHelper.GetCurrentDPI()
Dim thickness As Thickness = New Thickness(7, 7, 5, 7)
If currentDPI = 96 Then
thickness = New Thickness(8, 8, 8, 8)
ElseIf currentDPI = 120 Then
thickness = New Thickness(7, 7, 7, 6)
ElseIf currentDPI = 144 Then
thickness = New Thickness(7, 7, 7, 3)
ElseIf currentDPI = 168 Then
thickness = New Thickness(7, 7, 7, 2)
ElseIf currentDPI = 192 Then
thickness = New Thickness(6, 6, 2, 2)
ElseIf currentDPI = 240 Then
thickness = New Thickness(6, 6, 0, 0)
End If
Return thickness
End Function
Private Sub OnLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim MyHandle As IntPtr = (New WindowInteropHelper(Me)).Handle
'If Environment.OSVersion.Version.Major >= 6 Then
' DwmSetWindowAttribute(MyHandle, DWMWINDOWATTRIBUTE.DWMWA_TRANSITIONS_FORCEDISABLED, 1, 4)
'End If
Dim screen As Screen = Screen.FromHandle(MyHandle)
Dim width As Double = CDbl(screen.WorkingArea.Width)
Dim workingArea As Rectangle = screen.WorkingArea
Me.previousScreenBounds = New System.Windows.Point(width, CDbl(workingArea.Height))
End Sub
Private Sub SystemEvents_DisplaySettingsChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim screen As Screen = Screen.FromHandle((New WindowInteropHelper(Me)).Handle)
Dim width As Double = CDbl(screen.WorkingArea.Width)
Dim workingArea As Rectangle = screen.WorkingArea
Me.previousScreenBounds = New System.Windows.Point(width, CDbl(workingArea.Height))
Me.RefreshWindowState()
End Sub
Private Sub OnSizeChanged(ByVal sender As Object, ByVal e As SizeChangedEventArgs)
If MyBase.WindowState = WindowState.Normal Then
Me.HeightBeforeMaximize = MyBase.ActualHeight
Me.WidthBeforeMaximize = MyBase.ActualWidth
Return
End If
If MyBase.WindowState = WindowState.Maximized Then
Dim screen As Screen = Screen.FromHandle((New WindowInteropHelper(Me)).Handle)
If Me.previousScreenBounds.X <> CDbl(screen.WorkingArea.Width) OrElse Me.previousScreenBounds.Y <> CDbl(screen.WorkingArea.Height) Then
Dim width As Double = CDbl(screen.WorkingArea.Width)
Dim workingArea As Rectangle = screen.WorkingArea
Me.previousScreenBounds = New System.Windows.Point(width, CDbl(workingArea.Height))
Me.RefreshWindowState()
End If
End If
End Sub
Private Shadows Sub OnStateChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim screen As Screen = Screen.FromHandle((New WindowInteropHelper(Me)).Handle)
Dim thickness As Thickness = New Thickness(0)
If Me.WindowState <> WindowState.Maximized Then
Dim currentDPIScaleFactor As Double = CDbl(SystemHelper.GetCurrentDPIScaleFactor())
Dim workingArea As Rectangle = screen.WorkingArea
Me.MaxHeight = CDbl((workingArea.Height + 16)) / currentDPIScaleFactor
Me.MaxWidth = Double.PositiveInfinity
If Me.WindowState <> WindowState.Maximized Then
Me.SetMaximizeButtonsVisibility(Visibility.Visible, Visibility.Collapsed)
End If
Else
thickness = Me.GetDefaultMarginForDpi()
If Me.PreviousState = WindowState.Minimized OrElse Me.Left = Me.positionBeforeDrag.X AndAlso Me.Top = Me.positionBeforeDrag.Y Then
thickness = Me.GetFromMinimizedMarginForDpi()
End If
Me.SetMaximizeButtonsVisibility(Visibility.Collapsed, Visibility.Visible)
End If
Me.LayoutRoot.Margin = thickness
Me.PreviousState = Me.WindowState
End Sub
Private Shadows Sub OnMouseMove(ByVal sender As Object, ByVal e As System.Windows.Input.MouseEventArgs)
If Not Me.isMouseButtonDown Then
Return
End If
Dim currentDPIScaleFactor As Double = CDbl(SystemHelper.GetCurrentDPIScaleFactor())
Dim position As System.Windows.Point = e.GetPosition(Me)
System.Diagnostics.Debug.WriteLine(position)
Dim screen As System.Windows.Point = MyBase.PointToScreen(position)
Dim x As Double = Me.mouseDownPosition.X - position.X
Dim y As Double = Me.mouseDownPosition.Y - position.Y
If Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2)) > 1 Then
Dim actualWidth As Double = Me.mouseDownPosition.X
If Me.mouseDownPosition.X <= 0 Then
actualWidth = 0
ElseIf Me.mouseDownPosition.X >= MyBase.ActualWidth Then
actualWidth = Me.WidthBeforeMaximize
End If
If MyBase.WindowState = WindowState.Maximized Then
Me.ToggleWindowState()
Me.Top = (screen.Y - position.Y) / currentDPIScaleFactor
Me.Left = (screen.X - actualWidth) / currentDPIScaleFactor
Me.CaptureMouse()
End If
Me.isManualDrag = True
Me.Top = (screen.Y - Me.mouseDownPosition.Y) / currentDPIScaleFactor
Me.Left = (screen.X - actualWidth) / currentDPIScaleFactor
End If
End Sub
Private Sub OnMouseButtonUp(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
Me.isMouseButtonDown = False
Me.isManualDrag = False
Me.ReleaseMouseCapture()
End Sub
Private Sub RefreshWindowState()
If MyBase.WindowState = WindowState.Maximized Then
Me.ToggleWindowState()
Me.ToggleWindowState()
End If
End Sub
End Class
+128
View File
@@ -0,0 +1,128 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>
<RootNamespace>EgtWPFLib48</RootNamespace>
<AssemblyName>EgtWPFLib48</AssemblyName>
<OutputType>Library</OutputType>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<MyType>Custom</MyType>
<Deterministic>true</Deterministic>
<ProjectGuid>{0FB825B1-2865-422F-8FD2-E5D58D05DAD1}</ProjectGuid>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<IncrementalBuild>true</IncrementalBuild>
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>EgtWPFLib48.xml</DocumentationFile>
<NoWarn>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<DebugSymbols>false</DebugSymbols>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<IncrementalBuild>false</IncrementalBuild>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DocumentationFile>EgtWPFLib48.xml</DocumentationFile>
<NoWarn>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314</NoWarn>
</PropertyGroup>
<PropertyGroup>
<OptionExplicit>On</OptionExplicit>
</PropertyGroup>
<PropertyGroup>
<OptionCompare>Binary</OptionCompare>
</PropertyGroup>
<PropertyGroup>
<OptionStrict>Off</OptionStrict>
</PropertyGroup>
<PropertyGroup>
<OptionInfer>On</OptionInfer>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup>
<Compile Include="EgtMainWindow.vb" />
<Compile Include="Utility\NativeUtils.vb" />
<Compile Include="Utility\SystemHelper.vb" />
<Page Include="Themes\Generic.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Import Include="System.Threading.Tasks" />
<Import Include="System.Linq" />
<Import Include="System.Xml.Linq" />
<Import Include="Microsoft.VisualBasic" />
<Import Include="System" />
<Import Include="System.Collections" />
<Import Include="System.Collections.Generic" />
<Import Include="System.Diagnostics" />
<Import Include="System.Windows" />
<Import Include="System.Windows.Controls" />
<Import Include="System.Windows.Data" />
<Import Include="System.Windows.Documents" />
<Import Include="System.Windows.Input" />
<Import Include="System.Windows.Shapes" />
<Import Include="System.Windows.Media" />
<Import Include="System.Windows.Media.Imaging" />
<Import Include="System.Windows.Navigation" />
</ItemGroup>
<ItemGroup>
<Compile Include="My Project\AssemblyInfo.vb">
<SubType>Code</SubType>
</Compile>
<Compile Include="My Project\Resources.Designer.vb">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="My Project\Settings.Designer.vb">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
<CustomToolNamespace>My.Resources</CustomToolNamespace>
</EmbeddedResource>
<None Include="My Project\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Resource Include="Readme.html" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<PropertyGroup>
<PostBuildEvent>IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\Dll32\EgtWPFLib48.dll
IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\Dll64\EgtWPFLib48.dll
IF "$(ConfigurationName)" == "Debug" copy $(TargetPath) c:\EgtProg\DllD32\EgtWPFLib48.dll
IF "$(ConfigurationName)" == "Debug" copy $(TargetPath) c:\EgtProg\DllD64\EgtWPFLib48.dll</PostBuildEvent>
</PropertyGroup>
</Project>
+59
View File
@@ -0,0 +1,59 @@
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.Globalization
Imports System.Resources
Imports 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.
' Review the values of the assembly attributes
<Assembly: AssemblyTitle("EgtWPFLib48")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("Windows User")>
<Assembly: AssemblyProduct("EgtWPFLib48")>
<Assembly: AssemblyCopyright("Copyright @ Windows User 2023")>
<Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(false)>
'In order to begin building localizable applications, set
'<UICulture>CultureYouAreCodingWith</UICulture> in your .vbproj file
'inside a <PropertyGroup>. For example, if you are using US english
'in your source files, set the <UICulture> 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)>
'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found.
'1st parameter: where theme specific resource dictionaries are located
'(used if a resource is not found in the page,
' or application resource dictionaries)
'2nd parameter: where the generic resource dictionary is located
'(used if a resource is not found in the page,
'app, and any theme specific resource dictionaries)
<Assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)>
'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("89b43b17-fadd-45bf-ac11-615c6a4694b4")>
' 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("2.5.2.1")>
<Assembly: AssemblyFileVersion("2.5.2.1")>
+63
View File
@@ -0,0 +1,63 @@
'------------------------------------------------------------------------------
' <auto-generated>
' 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.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Imports System
Namespace My.Resources
'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.
'''<summary>
''' A strongly-typed resource class, for looking up localized strings, etc.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
Friend Module Resources
Private resourceMan As Global.System.Resources.ResourceManager
Private resourceCulture As Global.System.Globalization.CultureInfo
'''<summary>
''' Returns the cached ResourceManager instance used by this class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("EgtWPFLib48.Resources", GetType(Resources).Assembly)
resourceMan = temp
End If
Return resourceMan
End Get
End Property
'''<summary>
''' Overrides the current thread's CurrentUICulture property for all
''' resource lookups using this strongly typed resource class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set
resourceCulture = value
End Set
End Property
End Module
End Namespace
+117
View File
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+73
View File
@@ -0,0 +1,73 @@
'------------------------------------------------------------------------------
' <auto-generated>
' 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.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
#Region "My.Settings Auto-Save Functionality"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.EgtWPFLib48.My.MySettings
Get
Return Global.EgtWPFLib48.My.MySettings.Default
End Get
End Property
End Module
End Namespace
+7
View File
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
+12
View File
@@ -0,0 +1,12 @@
<HTML>
<H3>To use this custom control in a XAML file in another project, complete the following steps:</H3>
<BODY>
<UL>
<LI>Add a reference to this project.</LI>
<LI>Add the following line to the root element of the XAML file where you wish to use this control:<BR>
xmlns:MyNamespace="clr-namespace:EgtWPFLib48;assembly=EgtWPFLib48"</LI>
<LI>Use the control in the XAML file:<BR>
&LT;MyNamespace:CustomControl1/&GT;</LI>
</UL>
</BODY>
</HTML>
+270
View File
@@ -0,0 +1,270 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:EgtWPFLib48">
<Style x:Key="AboutBox_Button" TargetType="{x:Type Button}">
<Setter Property="Background" Value="White"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type local:EgtMainWindow}">
<Setter Property="Background" Value="White"/>
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="MinHeight" Value="50"/>
<Setter Property="MinWidth" Value="100"/>
<Setter Property="RenderOptions.BitmapScalingMode" Value="HighQuality"/>
<Setter Property="Title" Value="{Binding Title}"/>
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome GlassFrameThickness="1"
ResizeBorderThickness="4"
CaptionHeight="0"/>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:EgtMainWindow}">
<Grid Background="Transparent" x:Name="WindowRoot">
<Grid x:Name="LayoutRoot"
Background="{TemplateBinding Background}">
<Grid.RowDefinitions>
<RowDefinition Height="{StaticResource TitleBarHeight}"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitleBar-->
<Grid x:Name="PART_HeaderBar">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Button Command="{Binding AboutBoxCommand}"
Width="{Binding ActualHeight, ElementName=PART_HeaderBar}"
Style="{StaticResource AboutBox_Button}">
<Image Source="{TemplateBinding Icon}"/>
</Button>
<Grid Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<ContentPresenter Content="{TemplateBinding TitlePanel}"
VerticalAlignment="Center"/>
<TextBlock Text="{TemplateBinding ProjectName}"
ToolTip="{TemplateBinding ProjectPath}"
Grid.Column="1"
TextTrimming="CharacterEllipsis"
FontSize="14"
VerticalAlignment="Center"
Background="{StaticResource Icarus_Gray}"
Padding="5,2,5,3"
Margin="10,0,0,0"
Foreground="White"
IsEnabled="{TemplateBinding IsActive}"/>
<TextBlock Text="{TemplateBinding Title}"
Grid.Column="2"
TextTrimming="CharacterEllipsis"
HorizontalAlignment="Stretch"
FontSize="14"
TextAlignment="Center"
VerticalAlignment="Center"
Width="Auto"
Foreground="{StaticResource Icarus_Gray}"
Panel.ZIndex="0"
IsEnabled="{TemplateBinding IsActive}"/>
</Grid>
<Grid x:Name="WindowControlsGrid"
Grid.Column="2"
Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Button x:Name="MinimizeButton"
Width="{Binding ActualHeight, ElementName=PART_HeaderBar}"
Style="{StaticResource AboutBox_Button}">
<Image Source="\Resources\Common\Minimize.png"/>
</Button>
<Button x:Name="MaximizeButton"
Grid.Column="1"
Width="{Binding ActualHeight, ElementName=PART_HeaderBar}"
Style="{StaticResource AboutBox_Button}">
<Image Source="\Resources\Common\Maximize.png"/>
</Button>
<Button x:Name="RestoreButton"
Grid.Column="1"
Width="{Binding ActualHeight, ElementName=PART_HeaderBar}"
Visibility="Collapsed"
Style="{StaticResource AboutBox_Button}">
<Image Source="\Resources\Common\Restore.png"/>
</Button>
<Button x:Name="CloseButton"
Grid.Column="2"
Width="{Binding ActualHeight, ElementName=PART_HeaderBar}"
Command="{Binding CloseApplicationCommand, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Style="{StaticResource AboutBox_Button}">
<Image Source="\Resources\Common\Close.png"/>
</Button>
</Grid>
</Grid>
<Grid x:Name="PART_MainContentGrid"
Grid.Row="1"
Panel.ZIndex="10">
<ContentPresenter x:Name="PART_MainContentPresenter"/>
</Grid>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--<Style TargetType="{x:Type Button}" x:Key="WindowButtonStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ButtonBase}">
<Border x:Name="Chrome"
BorderBrush="{TemplateBinding BorderBrush}"
Margin="0"
Background="{TemplateBinding Background}"
SnapsToDevicePixels="True">
<ContentPresenter
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="FontFamily" Value="Webdings"/>
<Setter Property="FontSize" Value="13.333" />
<Setter Property="Foreground" Value="Black" />
<Setter Property="Margin" Value="0,2,3,0"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="Gray" />
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="local:EgtMainWindow">
<Setter Property="Background" Value="White"/>
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="MinHeight" Value="320"/>
<Setter Property="MinWidth" Value="480"/>
<Setter Property="RenderOptions.BitmapScalingMode" Value="HighQuality"/>
<Setter Property="Title" Value="{Binding Title}"/>
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome GlassFrameThickness="1"
ResizeBorderThickness="4"
CaptionHeight="0"/>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:EgtMainWindow}">
<Grid Background="Transparent" x:Name="WindowRoot">
<Grid x:Name="LayoutRoot"
Background="{TemplateBinding Background}">
<Grid.RowDefinitions>
<RowDefinition Height="36"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
-->
<!--TitleBar-->
<!--
<Grid x:Name="PART_HeaderBar">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{TemplateBinding Title}"
Grid.Column="0"
Grid.ColumnSpan="3"
TextTrimming="CharacterEllipsis"
HorizontalAlignment="Stretch"
FontSize="13"
TextAlignment="Center"
VerticalAlignment="Center"
Width="Auto"
Padding="200 0 200 0"
Foreground="Black"
Panel.ZIndex="0"
IsEnabled="{TemplateBinding IsActive}"/>
<Grid x:Name="WindowControlsGrid" Grid.Column="2" Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="36"/>
<ColumnDefinition Width="36"/>
<ColumnDefinition Width="36"/>
</Grid.ColumnDefinitions>
<Button x:Name="MinimizeButton" Style="{StaticResource WindowButtonStyle}"
TextElement.FontFamily="pack://application:,,,/FontAwesome.WPF;component/#FontAwesome"
Grid.Column="0"/>
<Button x:Name="MaximizeButton" Style="{StaticResource WindowButtonStyle}"
TextElement.FontFamily="pack://application:,,,/FontAwesome.WPF;component/#FontAwesome"
Grid.Column="1"/>
<Button x:Name="RestoreButton" Style="{StaticResource WindowButtonStyle}"
Visibility="Collapsed"
TextElement.FontFamily="pack://application:,,,/FontAwesome.WPF;component/#FontAwesome"
Grid.Column="1"/>
<Button x:Name="CloseButton" Style="{StaticResource WindowButtonStyle}"
TextElement.FontFamily="pack://application:,,,/FontAwesome.WPF;component/#FontAwesome"
TextElement.FontSize="24"
Grid.Column="2"/>
</Grid>
</Grid>
<Grid x:Name="PART_MainContentGrid"
Grid.Row="1"
Panel.ZIndex="10">
<ContentPresenter x:Name="PART_MainContentPresenter" Grid.Row="1"/>
</Grid>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>-->
<!--</Style>-->
</ResourceDictionary>
+113
View File
@@ -0,0 +1,113 @@
Imports System.Runtime.InteropServices
Friend Module NativeUtils
Public Enum DWMWINDOWATTRIBUTE
DWMWA_ALLOW_NCPAINT = 4
DWMWA_CAPTION_BUTTON_BOUNDS = 5
DWMWA_FLIP3D_POLICY = 8
DWMWA_FORCE_ICONIC_REPRESENTATION = 7
DWMWA_LAST = 9
DWMWA_NCRENDERING_ENABLED = 1
DWMWA_NCRENDERING_POLICY = 2
DWMWA_NONCLIENT_RTL_LAYOUT = 6
DWMWA_TRANSITIONS_FORCEDISABLED = 3
End Enum
Friend TPM_LEFTALIGN As UInteger
Friend TPM_RETURNCMD As UInteger
Sub New()
NativeUtils.TPM_LEFTALIGN = 0
NativeUtils.TPM_RETURNCMD = 256
End Sub
<DllImport("user32.dll", CharSet:=CharSet.None, ExactSpelling:=False)>
Friend Function PostMessage(ByVal hWnd As IntPtr, ByVal msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
End Function
<DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=False, SetLastError:=True)>
Friend Function GetSystemMenu(ByVal hWnd As IntPtr, ByVal bRevert As Boolean) As IntPtr
End Function
<DllImport("user32.dll", CharSet:=CharSet.None, ExactSpelling:=False)>
Friend Function EnableMenuItem(ByVal hMenu As IntPtr, ByVal uIDEnableItem As UInteger, ByVal uEnable As UInteger) As Boolean
End Function
<DllImport("user32.dll", CharSet:=CharSet.None, ExactSpelling:=False)>
Friend Function TrackPopupMenuEx(ByVal hmenu As IntPtr, ByVal fuFlags As UInteger, ByVal x As Integer, ByVal y As Integer, ByVal hwnd As IntPtr, ByVal lptpm As IntPtr) As Integer
End Function
<DllImport("dwmapi.dll", PreserveSig:=True)>
Friend Function DwmSetWindowAttribute(ByVal hwnd As IntPtr, ByVal attr As Integer, ByRef attrValue As Integer, ByVal attrSize As Integer) As Integer
End Function
End Module
<Serializable>
Friend Structure RECT
Public Left As Integer
Public Top As Integer
Public Right As Integer
Public Bottom As Integer
Public Property Height As Integer
Get
Return Me.Bottom - Me.Top
End Get
Set(ByVal value As Integer)
Me.Bottom = Me.Top + value
End Set
End Property
Public ReadOnly Property Position As Point
Get
Return New Point(CDbl(Me.Left), CDbl(Me.Top))
End Get
End Property
Public ReadOnly Property Size As Size
Get
Return New Size(CDbl(Me.Width), CDbl(Me.Height))
End Get
End Property
Public Property Width As Integer
Get
Return Me.Right - Me.Left
End Get
Set(ByVal value As Integer)
Me.Right = Me.Left + value
End Set
End Property
Public Sub New(ByVal left As Integer, ByVal top As Integer, ByVal right As Integer, ByVal bottom As Integer)
Me.Left = left
Me.Top = top
Me.Right = right
Me.Bottom = bottom
End Sub
Public Sub New(ByVal rect As RECT)
Me.Left = CInt(rect.Left)
Me.Top = CInt(rect.Top)
Me.Right = CInt(rect.Right)
Me.Bottom = CInt(rect.Bottom)
End Sub
Public Sub Offset(ByVal dx As Integer, ByVal dy As Integer)
Me.Left += dx
Me.Right += dx
Me.Top += dy
Me.Bottom += dy
End Sub
Public Function ToInt32Rect() As Int32Rect
Return New Int32Rect(Me.Left, Me.Top, Me.Width, Me.Height)
End Function
End Structure
Friend Structure NCCALCSIZE_PARAMS
Friend rect0 As RECT
Friend rect1 As RECT
Friend rect2 As RECT
Friend lppos As IntPtr
End Structure
+19
View File
@@ -0,0 +1,19 @@
Imports System.Reflection
Imports System.Windows.Forms
Friend Module SystemHelper
Function GetCurrentDPI() As Integer
Return CInt(GetType(SystemParameters).GetProperty("Dpi", BindingFlags.[Static] Or BindingFlags.NonPublic).GetValue(Nothing, Nothing))
End Function
Function GetCurrentDPIScaleFactor() As Double
Return CDbl(SystemHelper.GetCurrentDPI()) / 96
End Function
Function GetMouseScreenPosition() As Point
Dim point As System.Drawing.Point = Control.MousePosition
Return New Point(point.X, point.Y)
End Function
End Module