Skip to content

Commit

Permalink
1.Ctrl + Alt + = : 以選取文字檢索CTP中阮元刻《十三經注疏》本《周易正義》。便於擷取《易》學資料用。
Browse files Browse the repository at this point in the history
2. Ctrl + Alt + pageup : 在新的分頁開啟CTP圖文對照前一頁以供檢視
    Ctrl + Alt + pagedown : 在新的分頁開啟CTP圖文對照下一頁以供檢視
3. Fonts 模組 WordVBA
4. 《古籍酷》自動標點返回值的優化
5. textBox4FontDefault

感恩感恩 讚歎讚歎 南無阿彌陀佛
  • Loading branch information
oscarsun72 committed Sep 20, 2024
1 parent e58248c commit f4e9fed
Show file tree
Hide file tree
Showing 7 changed files with 404 additions and 130 deletions.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ Ctrl + Shift + ` 切換OBS開始串流和停止串流時可處理的程序(這
Ctrl + Alt + i 顯示IP現狀訊息方塊

Ctrl + Alt + pageup : 在新的分頁開啟CTP圖文對照前一頁以供檢視 20240920

Ctrl + Alt + pagedown : 在新的分頁開啟CTP圖文對照下一頁以供檢視

Ctrl + Shift + o 執行《看典古籍》OCR API ,執行 GetOCRResult 方法。(須將token存成「OCRAPItoken.txt」檔置於「我的文件\\CtextTempFiles」下,並在程式碼中覆寫本人帳號/郵箱。)

Ctrl + Shift + w 關閉 Chrome 網頁視窗
Expand Down Expand Up @@ -711,11 +715,16 @@ Ctrl + Delete : 將插入點所在位置之後的文字一律清除(Ctrl + z
Alt + 滑鼠左鍵 : 更新最後的備份頁文本

Ctrl+ 滑鼠左鍵:在插入點後分行分段(原為切換RichTextBox用)
Ctrl + 滑鼠左鍵:在插入點後分行分段(原為切換RichTextBox用)

Ctrl + 滑鼠右鍵:切換RichTextBox用

Ctrl + Alt + 滑鼠左鍵:將插入點後的分行分段清除

Ctrl+ 滑鼠右鍵:切換RichTextBox用
Ctrl + Alt + = : 以選取文字檢索CTP中阮元刻《十三經注疏》本《周易正義》。便於擷取《易》學資料用。20240920
> 選取字串將複製至剪貼簿備用。
Ctrl+ Alt + 滑鼠左鍵:將插入點後的分行分段清除
> https://ctext.org/library.pl?if=gb&res=83519&by_collection=127
滑鼠點二下,執行 Ctrl + + , 將插入點所在之前的文本貼到 Ctext 網頁 [簡單修改模式] 文字方塊中,並會重設以插入點位置為頁面結束位國(同Ctrl + -(數字鍵盤))

Expand Down
Binary file modified TextForCtextPortable.zip
Binary file not shown.
177 changes: 112 additions & 65 deletions WindowsFormsApp1/Browser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5451,7 +5451,7 @@ internal static bool OCR_GJcool_AutoRecognizeVertical(string downloadImgFullName
#endregion


if (ActiveForm1.TopMost) ActiveForm1.TopMost = false;
ActiveForm1.TopMost = false;
//點數(算力值、算力配额)不足逕用「快速體驗」執行
if (!OCR_GJcool_AccountChanged && waitGJcoolPoint || (!OCR_GJcool_AccountChanged && waitGJcoolPoint && DateTime.Now.Subtract(gjCoolPointLess150When) < gjCoolPointEnoughTimespan))
{
Expand Down Expand Up @@ -5792,7 +5792,7 @@ internal static bool OCR_GJcool_AutoRecognizeVertical(string downloadImgFullName
//Thread.Sleep(3200);
//等待「選擇檔案」控制項出現,最多等timeSpanSecs秒;
//為免tab鍵數不同,而須手動操作,以免表單遮住畫面:
if (ActiveForm1.TopMost) ActiveForm1.TopMost = false;
ActiveForm1.TopMost = false;
Clipboard.Clear();
DateTime begin = DateTime.Now; const int timeSpanSecs = 30;
TimeSpan timeSpan = new TimeSpan();
Expand Down Expand Up @@ -8057,6 +8057,24 @@ string standardizedText(ref string text)
return true;
}
/// <summary>
/// 改變CTP圖文對照網址的 Page 參數以供翻頁
/// 20240920 Copilot大菩薩:更改 URL 参数以翻页:https://sl.bing.net/jZV8afaj85Q
/// </summary>
/// <param name="url">要改變的網址</param>
/// <param name="newPageNumber">Page參數要成的數值</param>
/// <returns>傳回改動後的網址</returns>
public static string ChangePageParameter(string url, int newPageNumber)
{
var uri = new Uri(url);
var query = System.Web.HttpUtility.ParseQueryString(uri.Query);
query.Set("page", newPageNumber.ToString());
var uriBuilder = new UriBuilder(uri)
{
Query = query.ToString()
};
return uriBuilder.ToString();
}
/// <summary>
/// 作為「《漢籍全文資料庫》檢索易學關鍵字」的欲檢索關鍵字瀏覽清單索引(已檢索瀏覽之位置)記錄用。在textBox2中輸入「lx」(list index clear(x=叉=清除))以歸零
/// </summary>
internal static int ListIndex_Hanchi_SearchingKeywordsYijing = 0;
Expand All @@ -8072,12 +8090,91 @@ internal static bool Hanchi_CTP_SearchingKeywordsYijing()
{
if (driver == null) return true;

string title;
string title = null;

#region 檢查title creedit_with_Copilot大菩薩: C# 比對字串中的特定子字串: https://sl.bing.net/dy0lfJJXE72
//檢查title 如果不包含指定的條件,則傳回false
bool checkTitle(string titleToCheck)
{
string pattern = "漢籍全文|中國哲學書電子化計劃|Chinese Text Project";
return Regex.IsMatch(title, pattern);
//string[] keywords = { "漢籍全文", "中國哲學書電子化計劃", "Chinese Text Project" };
//var foundKeywords = keywords.Where(keyword => title.Contains(keyword));
}

void forEachTabChectTitle()
{
//《漢籍全文資料庫》網頁介面
foreach (var item in driver.WindowHandles)
{
driver.SwitchTo().Window(item);
try
{
if (driver.Title.Contains("漢籍全文")) break;
}
catch (Exception exx)
{
switch (exx.HResult)
{
case -2146233088:
if (exx.Message.StartsWith("unknown error\nfrom no such execution context:"))//unknown error
//from no such execution context: frame does not have execution context
// (Session info: chrome = 128.0.6613.138)
continue;
break;
default:
Console.WriteLine(exx.HResult + exx.Message);
Form1.MessageBoxShowOKExclamationDefaultDesktopOnly(exx.HResult + exx.Message);
break;
}
}
}
if (!driver.Title.Contains("漢籍全文"))
{
title = string.Empty;
foreach (var item in driver.WindowHandles)
{
try
{
if (driver.SwitchTo().Window(item).Url.StartsWith("https://ctext.org/wiki.pl?if="))//https://ctext.org/wiki.pl?if=gb&res=、https://ctext.org/wiki.pl?if=en&res=
{ title = driver.Title; break; }
}
catch (Exception exx)
{
switch (exx.HResult)
{
case -2146233088:
if (exx.Message.StartsWith("unknown error\nfrom no such execution context:"))//unknown error
//from no such execution context: frame does not have execution context
// (Session info: chrome = 128.0.6613.138)
continue;
break;
default:
Console.WriteLine(exx.HResult + exx.Message);
Form1.MessageBoxShowOKExclamationDefaultDesktopOnly(exx.HResult + exx.Message);
break;
}
}

}
}
}

#endregion



try
{
//不要切到Chrome瀏覽器!可以在等結果的時候做別的工作。20240915
//driver.SwitchTo().Window(driver.CurrentWindowHandle);
title = driver.Title;//避免誤關出錯
if (!checkTitle(title)) forEachTabChectTitle();
if (title.IsNullOrEmpty())
{
Form1.MessageBoxShowOKExclamationDefaultDesktopOnly("請開啟《漢籍全文資料庫》網頁檢索介面,再開始操作");
return true;
}
}
catch (Exception ex)
{
Expand All @@ -8096,65 +8193,11 @@ internal static bool Hanchi_CTP_SearchingKeywordsYijing()
}
break;
default:

//《漢籍全文資料庫》網頁介面
foreach (var item in driver.WindowHandles)
forEachTabChectTitle();
if (title.IsNullOrEmpty())
{
driver.SwitchTo().Window(item);
try
{
if (driver.Title.Contains("漢籍全文")) break;
}
catch (Exception exx)
{
switch (exx.HResult)
{
case -2146233088:
if (exx.Message.StartsWith("unknown error\nfrom no such execution context:"))//unknown error
//from no such execution context: frame does not have execution context
// (Session info: chrome = 128.0.6613.138)
continue;
break;
default:
Console.WriteLine(exx.HResult + exx.Message);
Form1.MessageBoxShowOKExclamationDefaultDesktopOnly(exx.HResult + exx.Message);
break;
}
}
}
if (!driver.Title.Contains("漢籍全文"))
{
title = string.Empty;
foreach (var item in driver.WindowHandles)
{
try
{
if (driver.SwitchTo().Window(item).Url.StartsWith("https://ctext.org/wiki.pl?if="))//https://ctext.org/wiki.pl?if=gb&res=、https://ctext.org/wiki.pl?if=en&res=
{ title = driver.Title; break; }
}
catch (Exception exx)
{
switch (exx.HResult)
{
case -2146233088:
if (exx.Message.StartsWith("unknown error\nfrom no such execution context:"))//unknown error
//from no such execution context: frame does not have execution context
// (Session info: chrome = 128.0.6613.138)
continue;
break;
default:
Console.WriteLine(exx.HResult + exx.Message);
Form1.MessageBoxShowOKExclamationDefaultDesktopOnly(exx.HResult + exx.Message);
break;
}
}

}
if (title == string.Empty)
{
Form1.MessageBoxShowOKExclamationDefaultDesktopOnly("請開啟《漢籍全文資料庫》網頁檢索介面,再開始操作");
return true;
}
Form1.MessageBoxShowOKExclamationDefaultDesktopOnly("請開啟《漢籍全文資料庫》網頁檢索介面,再開始操作");
return true;
}
break;
}
Expand All @@ -8166,9 +8209,9 @@ internal static bool Hanchi_CTP_SearchingKeywordsYijing()
"咸恆","老陰", "老陽", "少陰", "少陽","十翼","四象","兩儀",
"无妄", "彖", "象曰", "象傳", "象日", "象云","小象", "筮",
"初九","九二","九三","九四","九五","上九","初六","六二","六三","六四","六五","上六","用九","用六", "繇辭","繇詞",
"隨時之義","庖有魚","包有魚","精義入神","豶豕","童牛","承之羞","雷在天上","錫馬", "蕃庶","晝日","三接","懲忿","窒欲","敬以直內","義以方外","迷後得主","利西南","品物咸章","天下大行","益動而", "日進無疆","頻巽","豚魚","頻復", "懲窒","閑邪","存誠","乾乾","悔吝","憧憧", "類萬物","柔順利貞","比之匪人","貞厲","履貞","履道坦坦","貞吉","悔亡","時義","健順", "內健而外順", "內健外順", "外順而內健", "外順內健","敦復","直方","開物成務","窮神知化", "夕惕","惕若","研幾極深","極深研幾","一陰一陽","允升","木上有水","勞民勸相","索而得","我有好爵","言有序","有聖人之道四","長子帥師","弟子輿尸","無悶","日用而不知","之道鮮","原始反終", "寂然不動", "感而遂通","朋從", "朋盍", "容民畜眾","有過則改","見善則遷",
"隨時之義","庖有魚","包有魚","精義入神","豶豕","童牛","承之羞","雷在天上","錫馬", "蕃庶","晝日","三接","懲忿","窒欲","敬以直內","義以方外","迷後得主","利西南","品物咸章","天下大行","益動而", "日進無疆","頻巽","豚魚","頻復", "懲窒","閑邪","存誠","乾乾","悔吝","憧憧", "類萬物","柔順利貞","比之匪人","貞厲","履貞","履道坦坦","貞吉","悔亡","時義","健順", "內健而外順", "內健外順", "外順而內健", "外順內健","敦復","直方","開物成務","窮神知化", "夕惕","惕若","研幾極深","極深研幾","一陰一陽","允升","木上有水","勞民勸相","索而得","我有好爵","言有序","有聖人之道四","長子帥師","弟子輿尸","無悶","日用而不知","之道鮮","原始反終", "寂然不動", "感而遂通","朋從", "朋盍", "容民畜眾","有過則改","見善則遷","養正","養賢","知臨","臨大君", "默而成之","黙而成之","不言而信", "存乎德行","通天下之志","履正", "繼之者善", "仁者見之", "知者見之", "智者見之",
"象義",
"伏羲","伏𦏁","庖𦏁","宓𦏁","伏犧","庖犧"};
"伏羲","伏𦏁","庖羲","庖𦏁","宓𦏁","宓羲","宓犧","伏犧","庖犧"};

//異體字處理(只用在《中國哲學書電子化計劃》,因為《漢籍全文資料庫》已俱。)
if (title.EndsWith("中國哲學書電子化計劃") || title.EndsWith("Chinese Text Project"))
Expand Down Expand Up @@ -8261,23 +8304,27 @@ internal static bool Hanchi_CTP_SearchingKeywordsYijing()
driver.Navigate().Back();
returnValue = false;
}
else//有結果-中國哲學書電子化計劃
else//檢索有結果-中國哲學書電子化計劃
{
returnValue = true; Clipboard.SetText(keyword); ActiveForm1.KeyinTextmodeSwitcher();
//有文本的文字框
//Thread.Sleep(800);
ActiveForm1.TopMost = false;
driver.SwitchTo().Window(driver.CurrentWindowHandle);
if (new StringInfo(keyword).LengthInTextElements > 1)
FindPageAndPaste2Find(driver, keyword);
else
HighlightKeywords(keyword);
}//ActiveForm1.HideToNICo(); }

}
else//有結果-中國哲學書電子化計劃
else//檢索有結果-中國哲學書電子化計劃
{
returnValue = true; Clipboard.SetText(keyword); ActiveForm1.KeyinTextmodeSwitcher();
//有文本的文字框
//Thread.Sleep(800);
ActiveForm1.TopMost = false;
driver.SwitchTo().Window(driver.CurrentWindowHandle);
if (new StringInfo(keyword).LengthInTextElements > 1)
FindPageAndPaste2Find(driver, keyword);
else
Expand Down
Loading

0 comments on commit f4e9fed

Please sign in to comment.