Skip to content

Commit

Permalink
1.5.9 Update
Browse files Browse the repository at this point in the history
메인 화면 사용자 정보 구조 변경
  • Loading branch information
Potato-Y committed Apr 25, 2021
1 parent 4a8920e commit da58b56
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 112 deletions.
3 changes: 3 additions & 0 deletions Version.1/Game Utility App/Game Utility App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
<Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand Down
59 changes: 31 additions & 28 deletions Version.1/Game Utility App/MainForm/Basic Check.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using GameUtilityApp.Notice;
using GameUtilityApp.Properties;
using Microsoft.Win32;
using Newtonsoft.Json.Linq;
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.NetworkInformation;
Expand All @@ -12,7 +14,7 @@ namespace GameUtilityApp
{
class Basic_Check
{
int thisrelese = 20200929;
int thisrelese = 20210425;
int termsOfUseRelese = 20200818;

/// <summary>
Expand Down Expand Up @@ -282,49 +284,50 @@ string CheckFor45PlusVersion(int releaseKey)
/// </summary>

string UserCountHomepageHtml;
public readonly int LOAD = 0;
public readonly int RELOAD = 1;
string userDataResponseText = string.Empty;

//서버에서 정보 가져오기
private void GetUserCountData()
{
private void GetUserCountData(int type)
{
try
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

var client = new HttpClient(); //웹으로부터 다운로드 받을 수 있는 클래스의 인스턴스를 제작 한다.
/*var client = new HttpClient(); //웹으로부터 다운로드 받을 수 있는 클래스의 인스턴스를 제작 한다.
var response = client.GetAsync("http://potatoystudio.pe.kr/?device=mobile").Result; //웹으로부터 다운로드
UserCountHomepageHtml = response.Content.ReadAsStringAsync().Result; //다운로드 결과를 html 로 받아 온다.
}
catch (Exception)
{
UserCountHomepageHtml = response.Content.ReadAsStringAsync().Result; //다운로드 결과를 html 로 받아 온다.*/

}
}
string url = "https://script.google.com/macros/s/AKfycbyQ9B-jOm6yGr2bF3n-6SEX3l4C1p8-_M-l8poJPDWfbjd_S5Gaha4EF_lL1GsnMSwW/exec";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.Timeout = 10 * 1000;

public string GetNowUserCountData()
{
GetUserCountData();
try
{
var now_match = Regex.Match(UserCountHomepageHtml, "<span>.+?</span>"); //정규식을 사용해서 위의 문장과 동일한 패턴을 가져온다.
string now_result = now_match.Value; //캡쳐 된 내용을 가져온다.
return now_result.Substring(6, now_result.Length - 13);
using (HttpWebResponse resp = (HttpWebResponse)request.GetResponse())
{
Stream respStream = resp.GetResponseStream();
using (StreamReader sr = new StreamReader(respStream))
{
userDataResponseText = sr.ReadToEnd();
}
}
}
catch (Exception)
{
MessageBox.Show("유저 데이터를 가져오는데 오류가 발생하였습니다.");
return "0";
}

}
}

public string GetTodayCountData()
public string GetTodayCountData(int type)
{
GetUserCountData(type);
try
{
var today_match = Regex.Match(UserCountHomepageHtml, @"<dt>오늘</dt>\n <dd>.+?</dd>"); //정규식을 사용해서 위의 문장과 동일한 패턴을 가져온다.
string today_result = today_match.Value; //캡쳐 된 내용을 가져온다.
return today_result.Substring(24, today_result.Length - 29);
JObject json = JObject.Parse(userDataResponseText);
JToken jToken = json["today"];
return jToken.ToString();
}
catch (Exception)
{
Expand All @@ -337,9 +340,9 @@ public string GetTotalCountData()
{
try
{
var total_match = Regex.Match(UserCountHomepageHtml, @"<dt>전체</dt>\n <dd>.+?</dd>"); //정규식을 사용해서 위의 문장과 동일한 패턴을 가져온다.
string total_result = total_match.Value; //캡쳐 된 내용을 가져온다.
return total_result.Substring(24, total_result.Length - 29);
JObject json = JObject.Parse(userDataResponseText);
JToken jToken = json["total"];
return jToken.ToString();
}
catch (Exception)
{
Expand Down
40 changes: 8 additions & 32 deletions Version.1/Game Utility App/MainForm/Main.Designer.cs

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

55 changes: 15 additions & 40 deletions Version.1/Game Utility App/MainForm/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ private void UpdateCheck()
Basic_Check newCheck = new Basic_Check();
newCheck.DotNetverCheck(); //업데이트 확인 전 .net 버전 먼저 확인한다.
newCheck.NetworkCheck();

try
{
String path = "http://potatoystudio.pe.kr/"; //사이트 접속
webBrowser2.Navigate(path);
}
catch (Exception)
{
MessageBox.Show("인터넷 오류", "오류");
Application.Exit();
this.Close();
}

//서버 페이지 연결 만약 0이면 업데이트가 없는 상태, 1이면 업데이트가 있는 상태

Expand Down Expand Up @@ -62,7 +50,6 @@ private void UpdateCheck()

private void Form1_Load(object sender, EventArgs e) //프로그램 로딩
{
label11.Text = "0";
label14.Text = "0";
label15.Text = "0";
//필수 시작점
Expand Down Expand Up @@ -106,7 +93,7 @@ private void UpdateCheck()
//레이블 영역 끝

UpdateCheck();
UserCount();
UserCount(new Basic_Check().LOAD);
//레지 불러오기
RegReload_keyboard();
RegReload_Response();
Expand Down Expand Up @@ -150,25 +137,12 @@ private void loadtooltip()
}

//사용자 파악
private void UserCount()
private void UserCount(int type)
{
try
{
String path = "http://potatoystudio.pe.kr/";
webBrowser2.Navigate(path);
}
catch (Exception)
{
MessageBox.Show("Error");
Application.Exit();
this.Close();
}

try
{
Basic_Check userCheck = new Basic_Check();
label11.Text = userCheck.GetNowUserCountData();
label14.Text = userCheck.GetTodayCountData();
label14.Text = userCheck.GetTodayCountData(type);
label15.Text = userCheck.GetTotalCountData();
}
catch (Exception)
Expand Down Expand Up @@ -196,23 +170,23 @@ private void KeyboardClick(object sender, EventArgs e)
RegSave_keyboard();
MessageBox.Show("Keyboard 부분을 저장하였습니다.", "Save");
RegReload_keyboard();
UserCount(); //버튼 누를 때마다 사용자 수 재설정
//UserCount(new Basic_Check().RELOAD); //버튼 누를 때마다 사용자 수 재설정
}

private void ResponseClick(object sender, EventArgs e)
{
RegSave_Response();
MessageBox.Show("Keyboard Response 부분을 저장하였습니다.", "Save");
RegReload_Response();
UserCount(); //버튼 누를 때마다 사용자 수 재설정
//UserCount(new Basic_Check().RELOAD); //버튼 누를 때마다 사용자 수 재설정
}

private void ToggleKeysClick(object sender, EventArgs e)
{
RegSave_ToggleKeys();
MessageBox.Show("ToggleKeys 부분을 저장하였습니다.", "Save");
RegReload_ToggleKeys();
UserCount(); //버튼 누를 때마다 사용자 수 재설정
//UserCount(new Basic_Check().RELOAD); //버튼 누를 때마다 사용자 수 재설정
}

private void SaveAll(object sender, EventArgs e) //전체 세이브
Expand All @@ -224,7 +198,7 @@ private void ToggleKeysClick(object sender, EventArgs e)
RegReload_keyboard();
RegReload_Response();
RegReload_ToggleKeys();
UserCount(); //버튼 누를 때마다 사용자 수 재설정
// UserCount(new Basic_Check().RELOAD); //버튼 누를 때마다 사용자 수 재설정
}
//세이브 버튼 끝

Expand All @@ -234,7 +208,7 @@ private void ToggleKeysClick(object sender, EventArgs e)
RegReload_Response();
RegReload_ToggleKeys();
MessageBox.Show("모두 저장 전으로 새로고침 되었습니다.", "Reload");
UserCount(); //버튼 누를 때마다 사용자 수 재설정
// UserCount(new Basic_Check().RELOAD); //버튼 누를 때마다 사용자 수 재설정
}

private void RecommendReg_Click(object sender, EventArgs e) //권장 레지로 설정
Expand Down Expand Up @@ -265,34 +239,34 @@ private void ToggleKeysClick(object sender, EventArgs e)
RegReload_keyboard();
RegReload_Response();
RegReload_ToggleKeys();
UserCount(); //버튼 누를 때마다 사용자 수 재설정
// UserCount(new Basic_Check().RELOAD); //버튼 누를 때마다 사용자 수 재설정
}

private void SettingButton_Click(object sender, EventArgs e)
{
MainSetting newForm = new MainSetting();
newForm.ShowDialog();
UserCount(); //버튼 누를 때마다 사용자 수 재설정
//UserCount(new Basic_Check().RELOAD); //버튼 누를 때마다 사용자 수 재설정
}

private void Utility_Click(object sender, EventArgs e)
{
UtilityChoice newForm = new UtilityChoice();
newForm.ShowDialog();
UserCount(); //버튼 누를 때마다 사용자 수 재설정
//UserCount(new Basic_Check().RELOAD); //버튼 누를 때마다 사용자 수 재설정
}

private void Sponsor_Click(object sender, EventArgs e)
{
Sponsor newForm = new Sponsor();
newForm.ShowDialog();
UserCount();
//UserCount(new Basic_Check().RELOAD);
}

private void UseHelp_Click(object sender, EventArgs e)
{
Process.Start("https://repotato.tistory.com/138");
UserCount();
//UserCount(new Basic_Check().RELOAD);
}

//숫자만 입력되도록 하며 입력시 글자색이 파란색으로 변경
Expand Down Expand Up @@ -334,6 +308,7 @@ private void textbox3_keyup(object sender, KeyEventArgs e)
{
if (vs.Major == 10)
{
MessageBox.Show(vs.Major + " " + vs.Minor);
try
{
if (win10_message_count == 0)
Expand Down Expand Up @@ -506,7 +481,7 @@ private void RegPluse_Click(object sender, EventArgs e)
RegReload_keyboard();
RegReload_Response();
RegReload_ToggleKeys();
UserCount(); //버튼 누를 때마다 사용자 수 재설정
//UserCount(new Basic_Check().RELOAD); //버튼 누를 때마다 사용자 수 재설정
}

private void Homepage_Click(object sender, EventArgs e)
Expand Down
Loading

0 comments on commit da58b56

Please sign in to comment.