Skip to content

Commit

Permalink
增加启动界面,修复一些 BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed May 28, 2018
1 parent 6c97699 commit 9d1d686
Show file tree
Hide file tree
Showing 11 changed files with 320 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,5 @@ __pycache__/

# my rules
local

Nacollector/GlobalConstant.cs
12 changes: 11 additions & 1 deletion Nacollector/Browser/Handler/MenuHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public MenuHandler(bool showReload = false)
private const int SaveLink = 26504;
private const int CopyLink = 26505;
private const int LinkOpenDefaultBrowser = 26506;
private const int LinkToZneiatProject = 26507;
private const int FeedbackProject = 26508;

void IContextMenuHandler.OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
{
Expand Down Expand Up @@ -77,7 +79,9 @@ void IContextMenuHandler.OnBeforeContextMenu(IWebBrowser browserControl, IBrowse
{
if (_showReload)
model.AddItem(CefMenuCommand.ReloadNoCache, "刷新 (ReloadNoCache)");
model.AddItem((CefMenuCommand)ShowDevTools, "检查 (ShowDevTools)");
model.AddItem((CefMenuCommand)FeedbackProject, "反馈问题");
model.AddItem((CefMenuCommand)LinkToZneiatProject, "开源项目");
// model.AddItem((CefMenuCommand)ShowDevTools, "检查 (ShowDevTools)");
}
}

Expand Down Expand Up @@ -108,6 +112,12 @@ bool IContextMenuHandler.OnContextMenuCommand(IWebBrowser browserControl, IBrows
case LinkOpenDefaultBrowser:
System.Diagnostics.Process.Start("explorer.exe", parameters.UnfilteredLinkUrl);
break;
case LinkToZneiatProject:
System.Diagnostics.Process.Start("https://github.com/Zneiat/Nacollector");
break;
case FeedbackProject:
System.Diagnostics.Process.Start("https://github.com/Zneiat/Nacollector/issues");
break;
}

return false;
Expand Down
13 changes: 0 additions & 13 deletions Nacollector/GlobalConstant.cs

This file was deleted.

52 changes: 41 additions & 11 deletions Nacollector/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ private void InitSkin()

private void MainForm_Load(object sender, EventArgs e)
{
// 设置窗体透明
SetOpacity(0);
// 程序启动画面
SetIsStarting(true);
}

private void InitBrowser()
Expand All @@ -67,14 +67,14 @@ private void InitBrowser()
crBrowser.GetBrowser().FrameLoadEnd += new EventHandler<FrameLoadEndEventArgs>(Browser_FrameLoadEnd); // 浏览器初始化完毕时执行

crDownloads = new CrDownloads(crBrowser);

ContentPanel.Controls.Add(crBrowser.GetBrowser());
}

private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
{
// 取消设置窗体透明
SetOpacity(1);
// 关闭程序启动画面
SetIsStarting(false);
}

/// <summary>
Expand All @@ -85,9 +85,15 @@ public class AppActionForJs
// 获取程序版本
public string getVersion()
{
crBrowser.RunJS($"AppConfig.updateCheckUrl=\"{GlobalConstant.UpdateCheckUrl}\";AppConfig.updateCheckToken=\"{GlobalConstant.UpdateCheckToken}\"");
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
}

public void showDevTools()
{
crBrowser.GetBrowser().ShowDevTools();
}

// 采集是否使用IE代理请求
public void _utilsReqIeProxy(bool isEnable)
{
Expand Down Expand Up @@ -210,16 +216,40 @@ public void StartTask(object obj)
Utils.ReleaseMemory(true);
}


private Form startingForm;

/// <summary>
/// 设置窗体透明度
/// 设置程序启动画面
/// </summary>
public void SetOpacity(int value)
public void SetIsStarting(bool isStarting)
{
if (this.InvokeRequired) { this.Invoke(new SetOpacityDelegate(SetOpacity), new object[] { value }); return; }
if (this.InvokeRequired) { this.Invoke(new SetIsStartingDelegate(SetIsStarting), new object[] { isStarting }); return; }

this.Opacity = value;
if (isStarting)
{
startingForm = new Form
{
Size = new Size(640, 400),
TopMost = true,
ControlBox = false,
ShowInTaskbar = false,
AutoSizeMode = AutoSizeMode.GrowAndShrink,
FormBorderStyle = FormBorderStyle.None,
StartPosition = FormStartPosition.CenterScreen,
BackgroundImageLayout = ImageLayout.Zoom,
BackgroundImage = Properties.Resources.StartingImg
};
startingForm.Show();
this.Opacity = 0;
} else
{
startingForm.Hide();
this.Opacity = 1;
}

}
public delegate void SetOpacityDelegate(int value);
public delegate void SetIsStartingDelegate(bool isStarting);

private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
Expand Down
1 change: 1 addition & 0 deletions Nacollector/Nacollector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
<Content Include="Resources\html_res\assets\material-design-iconic-font.min.css">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="Resources\StartingImg.png" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
Expand Down
4 changes: 2 additions & 2 deletions Nacollector/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: NeutralResourcesLanguage("zh-Hans")]

12 changes: 11 additions & 1 deletion Nacollector/Properties/Resources.Designer.cs

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

Loading

0 comments on commit 9d1d686

Please sign in to comment.