Skip to content

Commit

Permalink
Add Setup Program.
Browse files Browse the repository at this point in the history
Now when the window is close to the edge of screen, the window will slide in to the edge. (Or we can say hide).
  • Loading branch information
hanyizhao committed Jan 22, 2018
1 parent 863221d commit 882f682
Show file tree
Hide file tree
Showing 9 changed files with 1,050 additions and 8 deletions.
4 changes: 4 additions & 0 deletions NetSpeedMonitor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.27130.2024
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetSpeedMonitor", "NetSpeedMonitor\NetSpeedMonitor.csproj", "{E2E127EA-1E45-427F-A63C-B3327D97BA03}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "NetSpeedMonitorSetup", "NetSpeedMonitorSetup\NetSpeedMonitorSetup.vdproj", "{F721A8E7-747E-4236-811C-3D43A1D3C353}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,8 @@ Global
{E2E127EA-1E45-427F-A63C-B3327D97BA03}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2E127EA-1E45-427F-A63C-B3327D97BA03}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2E127EA-1E45-427F-A63C-B3327D97BA03}.Release|Any CPU.Build.0 = Release|Any CPU
{F721A8E7-747E-4236-811C-3D43A1D3C353}.Debug|Any CPU.ActiveCfg = Debug
{F721A8E7-747E-4236-811C-3D43A1D3C353}.Release|Any CPU.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
13 changes: 12 additions & 1 deletion NetSpeedMonitor/DetailWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,18 @@ public void NewData(List<UDOneItem> items, double timeSpan)
{
if (items.Count == 0)
{

for(int i = 0;i < ContentGrid.RowDefinitions.Count;i++)
{
if(names[i].Text == null|| names[i].Text == "")
{
break;
}
else
{
ups[i].Text = "0K/s";
downs[i].Text = "0K/s";
}
}
}
else
{
Expand Down
69 changes: 68 additions & 1 deletion NetSpeedMonitor/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ private void Timer_Elapsed(object sender, ElapsedEventArgs e)
private void DetailWindow_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
portProcessMap.Enabled = detailWindow.IsVisible;
if(!detailWindow.IsVisible)
{
TryToEdgeHide();
}
}

private void InitializeTray()
Expand Down Expand Up @@ -256,6 +260,7 @@ private void Window_MouseMove(object sender, MouseEventArgs e)
private void Window_MouseEnter(object sender, MouseEventArgs e)
{
detailWindow.OthersWantShow(false);
TryToEdgeShow();
}

private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
Expand All @@ -270,6 +275,7 @@ private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
private void Window_MouseLeave(object sender, MouseEventArgs e)
{
detailWindow.OthersWantHide(false);
TryToEdgeHide();
}

private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
Expand All @@ -278,6 +284,7 @@ private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (DateTime.Now.Subtract(leftPressTime).TotalMilliseconds < 500)
{
TryToEdgeShow();
detailWindow.OthersWantShow(true);
}
}
Expand All @@ -286,7 +293,6 @@ private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
detailWindow.OthersWantShow(false);
Tool.MoveWindowBackToWorkArea(this, windowPadding);
}

}

private void Window_Loaded(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -335,6 +341,65 @@ private void HideAllView(bool hide)
}
}


private void TryToEdgeShow()
{
if(isEdgeHide)
{
if (Top + windowPadding.Top < 0)
{
Top = windowPadding.Top;
}
if (Top + Height + windowPadding.Bottom > SystemParameters.PrimaryScreenHeight)
{
Top = SystemParameters.PrimaryScreenHeight - Height - windowPadding.Bottom;
}
if (Left + windowPadding.Left < 0)
{
Left = windowPadding.Left;
}
if (Left + Width + windowPadding.Right > SystemParameters.PrimaryScreenWidth)
{
Left = SystemParameters.PrimaryScreenWidth - Width - windowPadding.Right;
}
isEdgeHide = false;
}

}

private void TryToEdgeHide()
{
if (!isEdgeHide)
{
if (!detailWindow.IsVisible)
{
if (Top - windowPadding.Top <= 2)
{
Top = -windowPadding.Bottom - Height;
isEdgeHide = true;
}
else if (SystemParameters.PrimaryScreenHeight - (Top + Height + windowPadding.Bottom) <= 2)
{
Top = SystemParameters.PrimaryScreenHeight + windowPadding.Top;
isEdgeHide = true;
}
else if (Left - windowPadding.Left <= 2)
{
Left = -windowPadding.Right - Width;
isEdgeHide = true;
}
else if (SystemParameters.PrimaryScreenWidth - (Left + Width + windowPadding.Right) <= 2)
{
Left = SystemParameters.PrimaryScreenWidth + windowPadding.Left;
isEdgeHide = true;
}
}

}

}


private void RegisterAppBar(bool register)
{
APPBARDATA abd = new APPBARDATA();
Expand Down Expand Up @@ -374,6 +439,8 @@ private void RegisterAppBar(bool register)
private int uCallBackMsg;

private DetailWindow detailWindow;

private bool isEdgeHide = false;

private double oldLeft, oldTop;
private DateTime leftPressTime = DateTime.Now;
Expand Down
25 changes: 23 additions & 2 deletions NetSpeedMonitor/NetSpeedMonitor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<TargetFrameworkProfile />
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -23,10 +24,10 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down Expand Up @@ -56,6 +57,24 @@
<PropertyGroup>
<StartupObject>USTC.Software.hanyizhao.NetSpeedMonitor.App</StartupObject>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>E74577D556CBCC51EC6629ED8028142CECAC27E1</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>NetSpeedMonitor_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="PacketDotNet">
<HintPath>..\SharpPcap-4.2.0.bin\SharpPcap-4.2.0\PacketDotNet.dll</HintPath>
Expand Down Expand Up @@ -124,6 +143,8 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="app.config" />
<None Include="NetSpeedMonitor_TemporaryKey.pfx" />
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down
4 changes: 2 additions & 2 deletions NetSpeedMonitor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyTitle("NetSpeedMonitor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("HanYizhao")]
[assembly: AssemblyProduct("NetSpeedMonitor")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
Expand All @@ -19,7 +19,7 @@
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
[assembly: ComVisible(true)]

//若要开始生成可本地化的应用程序,请设置
//.csproj 文件中的 <UICulture>CultureYouAreCodingWith</UICulture>
Expand Down
2 changes: 1 addition & 1 deletion NetSpeedMonitor/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion NetSpeedMonitor/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions NetSpeedMonitor/Properties/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 清单选项
如果想要更改 Windows 用户帐户控制级别,请使用
以下节点之一替换 requestedExecutionLevel 节点。n
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
如果你的应用程序需要此虚拟化来实现向后兼容性,则删除此
元素。
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
<defaultAssemblyRequest permissionSetReference="Custom" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
Windows 版本的列表。取消评论适当的元素,Windows 将
自动选择最兼容的环境。 -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- 指示该应用程序可以感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
选择加入。选择加入此设置的 Windows 窗体应用程序(目标设定为 .NET Framework 4.6 )还应
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。-->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>
Loading

0 comments on commit 882f682

Please sign in to comment.