private bool fnc_SetFormSize() { bool blRes; int intTop; int intLeft; int intWidth; int intHight; try { intTop = this.Top; intLeft = this.Left; intWidth = this.Width; intHight = this.Height; if (intTop < 0) { intTop = 0; } if (intLeft < 0) { intLeft = 0; } if (intWidth < 0) { intWidth = 0; } if (intHight < 0) { intHight = 0; } SaveImageCommon.SetIniValue("FormSize", "Top", intTop.ToString(), SaveImageCommon.CON_SAVEIMAGE_INI); SaveImageCommon.SetIniValue("FormSize", "Left", intLeft.ToString(), SaveImageCommon.CON_SAVEIMAGE_INI); SaveImageCommon.SetIniValue("FormSize", "Width", intWidth.ToString(), SaveImageCommon.CON_SAVEIMAGE_INI); SaveImageCommon.SetIniValue("FormSize", "Hight", intHight.ToString(), SaveImageCommon.CON_SAVEIMAGE_INI); blRes = true; } catch (Exception ex) { intTop = 0; intLeft = 0; intWidth = 0; intHight = 0; blRes = false; CommonLogger.WriteLine(ex.Message); } return(blRes); }
public static string GetIniValue(string lpSection, string lpKeyName, string lpFileName) { try { StringBuilder strValue = new StringBuilder(1024); uint sLen = GetPrivateProfileString(lpSection, lpKeyName, "", strValue, 1024, lpFileName); return(strValue.ToString()); } catch (Exception ex) { CommonLogger.WriteLine(ex.Message); return(""); } }
private void txt_SetVerticalScrollSize_LostFocus(object sender, EventArgs e) { try { this.pImageVerticalScorllSize = int.Parse(txt_SetVerticalScrollSize.Text); } catch (Exception ex) { this.pImageVerticalScorllSize = 0; txt_SetVerticalScrollSize.Text = this.pImageVerticalScorllSize.ToString(); CommonLogger.WriteLine(ex.Message); } fnc_SetImageVerticalScorllSize(); }
private void cob_url_KeyUp(object sender, KeyEventArgs e) { try { if (this.pSelUrlText != null && this.pSelUrlText != "") { cob_url.Text = this.pSelUrlText; this.pSelUrlText = ""; } } catch (Exception ex) { CommonLogger.WriteLine(ex.Message); } }
private void tsb_ImageFile_ExtList_SelectedIndexChanged(object sender, EventArgs e) { try { // 画像拡張子INIファイルに設定 this.pImageType = tsb_ImageFile_ExtList.Text; SaveImageCommon.SetIniValue("Option", "FileExtense", this.pImageType, SaveImageCommon.CON_SAVEIMAGE_INI); } catch (Exception ex) { // SaveImageCommon.SetIniValue("Option", "FileExtense", CON_EXTENSE_PNG, SaveImageCommon.CON_SAVEIMAGE_INI); SaveImageCommon.SetIniValue("Option", "FileExtense", SaveImageCommon.CON_EXTENSE_JPG, SaveImageCommon.CON_SAVEIMAGE_INI); CommonLogger.WriteLine(ex.Message); } }
private bool fnc_SetImageExtense() { bool blRes; try { SaveImageCommon.SetIniValue("Option", "FileExtense", this.pImageType, SaveImageCommon.CON_SAVEIMAGE_INI); blRes = true; } catch (Exception ex) { blRes = false; CommonLogger.WriteLine(ex.Message); } return(blRes); }
private bool fnc_SetImageVerticalScorllSize() { bool blRes; try { SaveImageCommon.SetIniValue("Option", "VerticalScorllSize", this.pImageVerticalScorllSize.ToString(), SaveImageCommon.CON_SAVEIMAGE_INI); blRes = true; } catch (Exception ex) { blRes = false; CommonLogger.WriteLine(ex.Message); } return(blRes); }
private bool fnc_GetFormSize() { bool blRes; string strTemp; int intTop; int intLeft; int intWidth; int intHight; try { intTop = 0; intLeft = 0; intWidth = 0; intHight = 0; strTemp = SaveImageCommon.GetIniValue("FormSize", "Top", SaveImageCommon.CON_SAVEIMAGE_INI); intTop = int.Parse(strTemp); strTemp = SaveImageCommon.GetIniValue("FormSize", "Left", SaveImageCommon.CON_SAVEIMAGE_INI); intLeft = int.Parse(strTemp); strTemp = SaveImageCommon.GetIniValue("FormSize", "Width", SaveImageCommon.CON_SAVEIMAGE_INI); intWidth = int.Parse(strTemp); strTemp = SaveImageCommon.GetIniValue("FormSize", "Hight", SaveImageCommon.CON_SAVEIMAGE_INI); intHight = int.Parse(strTemp); if (intTop >= 0 && intLeft >= 0 && intWidth >= 0 && intHight >= 0) { this.Top = intTop; this.Left = intLeft; this.Width = intWidth; this.Height = intHight; } blRes = true; } catch (Exception ex) { intTop = 0; intLeft = 0; intWidth = 0; intHight = 0; blRes = false; CommonLogger.WriteLine(ex.Message); } return(blRes); }
private bool fnc_SetImageExtenseCombox() { bool blRes; string strImageType; try { this.pImageType = ""; // INIファイルから画像拡張子取得 strImageType = SaveImageCommon.GetIniValue("Option", "FileExtense", SaveImageCommon.CON_SAVEIMAGE_INI); strImageType = strImageType.ToUpper(); tsb_ImageFile_ExtList.Items.Clear(); foreach (string strExt in CON_EXTENSE) { // 画像拡張子値設定 tsb_ImageFile_ExtList.Items.Add(strExt); // デフォルト(ユーザ指定)取得 if (this.pImageType == "" && strImageType == strExt) { this.pImageType = strExt; } } if (this.pImageType == "") { this.pImageType = SaveImageCommon.CON_EXTENSE_JPG; } // 画像拡張子デフォルト(ユーザ指定)値設定 tsb_ImageFile_ExtList.Text = this.pImageType; blRes = true; } catch (Exception ex) { // this.pImageType = CON_EXTENSE_PNG; // TODO this.pImageType = SaveImageCommon.CON_EXTENSE_JPG; blRes = false; CommonLogger.WriteLine(ex.Message); } return(blRes); }
private string fnc_SaveImageToOneFile() { string strCurrentDir; string strFileName; Bitmap bmpImage; try { // フル画面画像取得 bmpImage = fnc_GetWebImageFullScreen(); // ファイルに出力 strFileName = fnc_GetImageFileMainNo(); strFileName = strFileName.Replace("_YY", ""); strCurrentDir = Directory.GetCurrentDirectory(); switch (this.pImageType) { case SaveImageCommon.CON_EXTENSE_JPG: bmpImage.Save(strCurrentDir + "\\" + strFileName, ImageFormat.Jpeg); break; case SaveImageCommon.CON_EXTENSE_PNG: bmpImage.Save(strCurrentDir + "\\" + strFileName, ImageFormat.Png); break; case SaveImageCommon.CON_EXTENSE_TIFF: bmpImage.Save(strCurrentDir + "\\" + strFileName, ImageFormat.Tiff); break; case SaveImageCommon.CON_EXTENSE_GIF: bmpImage.Save(strCurrentDir + "\\" + strFileName, ImageFormat.Gif); break; // case CON_EXTENSE_XPS: // break; default: bmpImage.Save(strCurrentDir + "\\" + strFileName, ImageFormat.Jpeg); break; } } catch (Exception ex) { strFileName = ""; CommonLogger.WriteLine(ex.Message); } return(strFileName); }
private string fnc_GetImageFileMainNo() { string strTemp; string strFile; int intCnt; try { strFile = SaveImageCommon.CON_IAMGE_FILE; strTemp = SaveImageCommon.CON_IAMGE_FILE; for (intCnt = 1; intCnt <= 999; intCnt++) { strTemp = strFile.Replace("XXX", intCnt.ToString("000")); if (fnc_CheckImageFile(strTemp) == false) { strFile = strTemp; break; } } //MessageBox.Show(strFile); CommonLogger.WriteLine(strFile); // 拡張子設定 foreach (string strExt in CON_EXTENSE) { if (this.pImageType == strExt) { strFile = strFile + "." + strExt; } } } catch (Exception ex) { strFile = ""; CommonLogger.WriteLine(ex.Message); } return(strFile); }
private void cob_url_KeyDown(object sender, KeyEventArgs e) { try { if ((e.Modifiers & Keys.Shift) == Keys.Shift) { if (e.KeyCode == Keys.T) { fnc_ResetListItem(cob_url.SelectedIndex); } else if (e.KeyCode == Keys.Delete) { fnc_DeleteListItem(cob_url.SelectedIndex); } } } catch (Exception ex) { CommonLogger.WriteLine(ex.Message); } }
private bool fnc_SetUrlExclusionList() { bool blRes; int intCnt, intList; string strExcUrl; try { // INIファイル定義をいったん削除 SaveImageCommon.SetIniValue("UrlExclusion", null, null, SaveImageCommon.CON_SAVEIMAGE_INI); if (lst_url_exclustion.Items.Count <= 0) { SaveImageCommon.SetIniValue("UrlExclusion", "Key01", SaveImageCommon.CON_DEF_EXC_KEY, SaveImageCommon.CON_SAVEIMAGE_INI); } else { // 保存対象をINIファイルに出力 intCnt = 0; for (intList = 0; intList < lst_url_exclustion.Items.Count; intList++) { strExcUrl = lst_url_exclustion.Items[intList].ToString().Trim(); if (lst_url_exclustion.Items[intList].ToString().Trim() != "") { intCnt = intCnt + 1; SaveImageCommon.SetIniValue("UrlExclusion", "Key" + (intCnt).ToString("00"), strExcUrl, SaveImageCommon.CON_SAVEIMAGE_INI); } } } blRes = true; } catch (Exception ex) { CommonLogger.WriteLine(ex.Message); blRes = false; } return(blRes); }
private void cob_url_KeyPress(object sender, KeyPressEventArgs e) { try { if (e.KeyChar.ToString() == "\r") { //comboBox1_Click(sender, e); if (this.pDontNavigateNow == false) { this.pSaveUrlList = true; UrlTimer.Enabled = true; if (cob_url.Text != "") { TargetWebBrowser.Navigate(cob_url.Text); } } } } catch (Exception ex) { CommonLogger.WriteLine(ex.Message); } }
private bool fnc_DelUrlExclusionItem() { bool blRes; int intDelUrl; try { blRes = true; intDelUrl = lst_url_exclustion.SelectedIndex; if (intDelUrl > -1) { lst_url_exclustion.Items.RemoveAt(intDelUrl); txt_edit.Text = ""; txt_edit.Select(); } } catch (Exception ex) { blRes = false; CommonLogger.WriteLine(ex.Message); } return(blRes); }
private bool fnc_AddUrlExclusionItem() { bool blRes; int intCnt; string strAddUrl; try { blRes = true; strAddUrl = txt_edit.Text.Trim(); if (strAddUrl != "") { for (intCnt = 0; intCnt < lst_url_exclustion.Items.Count; intCnt++) { if (strAddUrl == lst_url_exclustion.Items[intCnt].ToString()) { blRes = false; } } if (blRes == true) { lst_url_exclustion.Items.Add(strAddUrl); txt_edit.Text = ""; txt_edit.Select(); } } } catch (Exception ex) { blRes = false; CommonLogger.WriteLine(ex.Message); } return(blRes); }
private bool fnc_ResetListItem(int int_sel_idx) { bool blRes; int intCnt; string[] strTempList; string strSelText; try { strTempList = new string[CON_COB_URL_CNT]; intCnt = 0; strSelText = ""; // コンボアイテム取得 for (intCnt = 0; intCnt < CON_COB_URL_CNT; intCnt++) { if (intCnt < cob_url.Items.Count) { strTempList[intCnt] = cob_url.Items[intCnt].ToString().Trim(); // 指定されたアイテムを記憶 if (intCnt == int_sel_idx) { strSelText = strTempList[intCnt]; } } else { strTempList[intCnt] = ""; } } cob_url.Items.Clear(); // 選択されたURLをトップにセット cob_url.Items.Add(strSelText); for (intCnt = 0; intCnt < CON_COB_URL_CNT; intCnt++) { if (strTempList[intCnt] != "") { if (intCnt != int_sel_idx) { cob_url.Items.Add(strTempList[intCnt]); } else { strSelText = strTempList[intCnt]; } } } this.pSelUrlText = strSelText; blRes = true; } catch (Exception ex) { blRes = false; CommonLogger.WriteLine(ex.Message); } return(blRes); }
private bool fnc_DeleteListItem(int int_sel_idx) { bool blRes; int intCnt; string[] strTempList; string strSelText; string strMsg; try { strTempList = new string[CON_COB_URL_CNT]; intCnt = 0; // コンボアイテム取得 for (intCnt = 0; intCnt < CON_COB_URL_CNT; intCnt++) { if (intCnt < cob_url.Items.Count) { strTempList[intCnt] = cob_url.Items[intCnt].ToString().Trim(); } else { strTempList[intCnt] = ""; } } // 指定されたアイテムをコンボリストから削除 strSelText = ""; cob_url.Items.Clear(); for (intCnt = 0; intCnt < CON_COB_URL_CNT; intCnt++) { if (strTempList[intCnt] != "") { if (intCnt != int_sel_idx) { cob_url.Items.Add(strTempList[intCnt]); } else { strSelText = strTempList[intCnt]; } } } // URL再設定 if (int_sel_idx == 0) { cob_url.Text = cob_url.Items[0].ToString(); } else { cob_url.Text = cob_url.Items[int_sel_idx - 1].ToString(); } // 削除されたURLをステータスバーに表示 strMsg = "Delete Url [" + strSelText + "] From List ComboBox."; tsl_msg.Text = strMsg; StatusTimer.Start(); //// 設定されたURLに遷移 //if (cob_url.Text.Trim() != "") //{ // TargetWebBrowser.Navigate(cob_url.Text); //} blRes = true; } catch (Exception ex) { blRes = false; CommonLogger.WriteLine(ex.Message); } return(blRes); }
private bool fnc_SetUrlList() { bool blRes; int intCnt; int intList, intExcList; string[] strTempUrl, strUrl; string strExc; try { // 保存除外キーを含む対象を取得 fnc_GetUrlExclusionList(); strTempUrl = new string[cob_url.Items.Count]; intList = 0; // コンボボックスからアイテムを取得 for (intList = 0; intList < cob_url.Items.Count; intList++) { if (intList < CON_COB_URL_CNT) { strTempUrl[intList] = cob_url.Items[intList].ToString().Trim(); } } // 保存除外キーを含む対象を除外 intCnt = 0; strUrl = new string[cob_url.Items.Count]; for (intList = 0; intList < strTempUrl.Length; intList++) { strExc = ""; for (intExcList = 0; intExcList < this.pUrlExclusionList.Length; intExcList++) { strExc = this.pUrlExclusionList[intExcList].Trim(); if (strExc == "") { break; } // 両端は「*」の場合 if (strExc[0] == char.Parse("*") && strExc[strExc.Length - 1] == char.Parse("*")) { strExc = strExc.Substring(1, strExc.Length - 2); if (strExc != "") { if (strTempUrl[intList].Contains(strExc) == false) { strUrl[intCnt] = strTempUrl[intList].Trim(); intCnt = intCnt + 1; } } } else { // 先頭は「*」の場合 if (strExc[0] == char.Parse("*")) { strExc = strExc.Substring(1, strExc.Length - 1); if (strExc != "") { if (strTempUrl[intList].EndsWith(strExc) == false) { strUrl[intCnt] = strTempUrl[intList].Trim(); intCnt = intCnt + 1; } } } // 最後は「*」の場合 else if (strExc[strExc.Length - 1] == char.Parse("*")) { strExc = strExc.Substring(0, strExc.Length - 1); if (strExc != "") { if (strTempUrl[intList].StartsWith(strExc) == false) { strUrl[intCnt] = strTempUrl[intList].Trim(); intCnt = intCnt + 1; } } } else { // 両端は「*」以外の場合 if (strTempUrl[intList] != strExc) { strUrl[intCnt] = strTempUrl[intList].Trim(); intCnt = intCnt + 1; } } } } } // INIファイル定義をいったん削除 SaveImageCommon.SetIniValue("UrlList", null, null, SaveImageCommon.CON_SAVEIMAGE_INI); // 保存対象をINIファイルに出力 if (intCnt == 0) { // 除外キー情報は存在しない場合 intCnt = 0; for (intList = 0; intList < strTempUrl.Length; intList++) { if (strTempUrl[intList] != null && strTempUrl[intList] != "") { intCnt = intCnt + 1; SaveImageCommon.SetIniValue("UrlList", "List" + (intCnt).ToString("00"), strTempUrl[intList], SaveImageCommon.CON_SAVEIMAGE_INI); } } } else { // 除外キー情報は存在し、突合せ実施した場合 intCnt = 0; for (intList = 0; intList < strUrl.Length; intList++) { if (strUrl[intList] != null && strUrl[intList] != "") { intCnt = intCnt + 1; SaveImageCommon.SetIniValue("UrlList", "List" + (intCnt).ToString("00"), strUrl[intList], SaveImageCommon.CON_SAVEIMAGE_INI); } } } blRes = true; } catch (Exception ex) { CommonLogger.WriteLine(ex.Message); blRes = false; } return(blRes); }
private Bitmap fnc_GetWebImageFullScreen() { int intWbWidthDefault; int intWbHeightDefault; int intBodyWidth; int intBodyHeight; Bitmap bitmap = null; try { intWbWidthDefault = TargetWebBrowser.Width; intWbHeightDefault = TargetWebBrowser.Height; // キャプチャサイズを指定 intBodyWidth = TargetWebBrowser.Document.Body.ScrollRectangle.Width; intBodyHeight = TargetWebBrowser.Document.Body.ScrollRectangle.Height; TargetWebBrowser.Width = intBodyWidth; TargetWebBrowser.Height = intBodyHeight; // キャプチャの保存先bitmapを生成 bitmap = new Bitmap(intBodyWidth, intBodyHeight); Graphics graphic = null; IntPtr ptrObj = IntPtr.Zero; IntPtr ptrHdc = IntPtr.Zero; try { graphic = Graphics.FromImage(bitmap); ptrHdc = graphic.GetHdc(); ptrObj = Marshal.GetIUnknownForObject(TargetWebBrowser.ActiveXInstance); Rectangle rect = new Rectangle(0, 0, intBodyWidth, intBodyHeight); // ptrObj画像内のrectで指定した領域を,HDCのエリアに貼付 SaveImageCommon.OleDraw(ptrObj, (int)DVASPECT.DVASPECT_CONTENT, ptrHdc, ref rect); } finally { if (ptrObj != IntPtr.Zero) { Marshal.Release(ptrObj); } if (ptrHdc != IntPtr.Zero) { graphic.ReleaseHdc(ptrHdc); } if (graphic != null) { graphic.Dispose(); } TargetWebBrowser.Width = intWbWidthDefault; TargetWebBrowser.Height = intWbHeightDefault; } // 取得したbmp情報を返す return(bitmap); } catch (Exception ex) { CommonLogger.WriteLine(ex.Message); MessageBox.Show(ex.Message); return(null); } }
private string fnc_SaveImageToDivFile() { string strCurrentDir; string strTempFileName; string strFileName; Bitmap srcBitmap, expBitmap; int intWbWidth, intWbHeight; int intCnt, intPageCount; int intLeft, intTop, intWidth, intHeight; try { // フル画面画像取得 srcBitmap = fnc_GetWebImageFullScreen(); // 出力ファイル名取得 strCurrentDir = Directory.GetCurrentDirectory(); strTempFileName = fnc_GetImageFileMainNo(); // ステータスバーに表示する文言のため strFileName = strTempFileName.Replace("_YY", "_XX"); // 分割ページ数計算 intWbWidth = TargetWebBrowser.Document.Body.ScrollRectangle.Width; intWbHeight = TargetWebBrowser.Document.Body.ScrollRectangle.Height; if (intWbHeight % this.pImageVerticalScorllSize == 0) { intPageCount = intWbHeight / this.pImageVerticalScorllSize; } else { intPageCount = intWbHeight / this.pImageVerticalScorllSize + 1; } // 分割ページ(MAX:99)超える場合、MAX値設定 if (intPageCount > 99) { intPageCount = 99; } intLeft = 0; intTop = 0; intWidth = TargetWebBrowser.Document.Body.ScrollRectangle.Width; intHeight = this.pImageVerticalScorllSize; for (intCnt = 0; intCnt < intPageCount; intCnt++) { strFileName = strTempFileName.Replace("_YY", (intCnt + 1).ToString("_00")); // (X,Y)位置計算 intTop = intCnt * this.pImageVerticalScorllSize; // 画像ファイル出力 if (intCnt == intPageCount - 1) { // 最後の(分割)1ページの縦幅再計算 intHeight = intWbHeight - intTop; expBitmap = fnc_GetWebImage(srcBitmap, intLeft, intTop, intWidth, intHeight); if (intCnt == 0) { strFileName = strFileName.Replace("_01", ""); } } else { expBitmap = fnc_GetWebImage(srcBitmap, intLeft, intTop, intWidth, intHeight); } switch (this.pImageType) { case SaveImageCommon.CON_EXTENSE_JPG: expBitmap.Save(strCurrentDir + "\\" + strFileName, ImageFormat.Jpeg); break; case SaveImageCommon.CON_EXTENSE_PNG: expBitmap.Save(strCurrentDir + "\\" + strFileName, ImageFormat.Png); break; case SaveImageCommon.CON_EXTENSE_TIFF: expBitmap.Save(strCurrentDir + "\\" + strFileName, ImageFormat.Tiff); break; case SaveImageCommon.CON_EXTENSE_GIF: expBitmap.Save(strCurrentDir + "\\" + strFileName, ImageFormat.Gif); break; // case CON_EXTENSE_XPS: // break; default: expBitmap.Save(strCurrentDir + "\\" + strFileName, ImageFormat.Jpeg); break; } } // ステータスバーに表示する文言のため(複数ファイルの場合) if (intCnt > 0) { strFileName = " ~ " + strFileName; } } catch (Exception ex) { strFileName = ""; CommonLogger.WriteLine(ex.Message); } return(strFileName); }