-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReader.cs
108 lines (90 loc) · 3.36 KB
/
Reader.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CefSharp;
using CefSharp.WinForms;
using miniSys0._3.Controls;
using Sunny.UI;
using static miniSys0._3.Controls.UC_main;
namespace miniSys0._3
{
public partial class Reader : UIForm
{
public static Reader reader;
public ChromiumWebBrowser WebBrowser2;
public Reader()
{
InitializeComponent();
InitializeChromeForMainLineChart();
reader = this;
InitTheme();
}
private void InitializeChromeForMainLineChart()
{
/*var setting = new CefSettings();
setting.MultiThreadedMessageLoop = true;
CefSharp.Cef.Initialize(setting);*/
string url_path = Environment.CurrentDirectory.Substring(0, Environment.CurrentDirectory.IndexOf("bin")) + "Html\\Articles\\index.html";
WebBrowser2 = new ChromiumWebBrowser(url_path);
WebBrowser2.Dock = DockStyle.Fill;//铺满
WebBrowser2.Dock = DockStyle.Fill;//设置停靠方式
WebBrowser2.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true; //交互数据
WebBrowser2.JavascriptObjectRepository.Register("bound", new BoundObject(), isAsync: false, options: BindingOptions.DefaultBinder); //交互数据
WebBrowser2.MenuHandler = new MenuHandler();//阻止右键
panelBrower.Controls.Add(WebBrowser2);
}
private void form_closing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Hide();
}
private void InitTheme()
{
if (User_type.user_theme == "dark")
{
this.BackColor = Color.FromArgb(28, 47, 70);
TitleColor = Color.FromArgb(28, 47, 70);
TitleForeColor = Color.White;
ControlBoxForeColor = Color.White;
rectColor = Color.FromArgb(55, 55, 57);
}
}
}
public class BoundObject
{
public string MessageText { get; set; }
public void Getvalue()
{
MessageBox.Show("call c#.\n\r" + MessageText);
}
public void GetValueArg(string inss)
{
MessageBox.Show("call with argument.\n\r" + inss);
}
public void add1ToLikes()
{
//Console.WriteLine("get");
if (ArticlesInfo.currentArticleType == "news")
{
int no = ArticlesInfo.currentnewsLablelD;
string likes = ArticlesInfo.likesParaList[no];
ArticlesInfo.likesParaList[no] = (int.Parse(likes) + 1).ToString();
add1ToViewsOrLikesToDB("likes","news");
}
else if (ArticlesInfo.currentArticleType == "notice")
{
int no = NoticeInfo.currentnoticeLablelD;
string likes = NoticeInfo.likesParaList[no];
NoticeInfo.likesParaList[no] = (int.Parse(likes) + 1).ToString();
add1ToViewsOrLikesToDB("likes","notice");
}
}
}
}