/// <summary> /// スプラッシュスクリーンを消す /// </summary> public void EndWait() { // フェード更新間隔 int DURATION_MS = 100; int elapsedms = 0; float fadeDurationMs = 1.0f * 1000; float fadeCount = fadeDurationMs / (float)DURATION_MS; double ope = 1.0d; double opechange = 0; opechange = (ope / fadeCount) * -1; while (fadeDurationMs >= elapsedms) { ope += opechange; this.Opacity = ope; System.Threading.Thread.Sleep(DURATION_MS); elapsedms += DURATION_MS; this.picWait.Refresh(); } this.Close(); if (MainProgram.frmMain.frmOpt.AlwaysOnTop == true) { MainProgram.Foremost(true); } }
/// <summary> /// スプラッシュスクリーンを消す /// </summary> public void EndWait() { this.Close(); if (MainProgram.frmMain.frmOpt.AlwaysOnTop == true) { MainProgram.Foremost(true); } }
/// <summary> /// スプラッシュスクリーン表示する /// </summary> public void StartWait() { if (MainProgram.frmMain.frmOpt.AlwaysOnTop == true) { MainProgram.Foremost(false); } this.StartPosition = FormStartPosition.CenterScreen; this.Show(); Application.DoEvents(); }
/// <summary> /// ファイル名を変更する /// </summary> /// <param name="strEditFilePath">変更対象ファイルパス</param> private void changeFileName(string strEditFilePath) { // 常に手前を解除 MainProgram.Foremost(false); // ファイルが存在するか確認 if (File.Exists(strEditFilePath)) { // ファイルを名前を入力してもらう string strNewFileName = Microsoft.VisualBasic.Interaction.InputBox(MainProgram.MES_FILE_NEWNAME, MainProgram.MES_TITLE_CHANGEFILENAME, Path.GetFileNameWithoutExtension(strEditFilePath), -1, -1); try { if (strNewFileName != "") { // OKクリック if (Path.GetFileNameWithoutExtension(strEditFilePath) != strNewFileName) { // ファイル名変更 File.Move(strEditFilePath, Path.GetDirectoryName(strEditFilePath) + "\\" + strNewFileName + Path.GetExtension(strEditFilePath)); // キー更新 string strBeforeKey = (string)MainProgram.frmMain.Grid[MainProgram.frmMain.Grid.Selection.ActivePosition.Row, (int)MainProgram.enuGrid.FILENAME].Value; string strAfterKey; if (Path.GetDirectoryName(strBeforeKey) == String.Empty) { strAfterKey = strNewFileName + Path.GetExtension(strEditFilePath); } else { strAfterKey = Path.GetDirectoryName(strBeforeKey) + "\\" + strNewFileName + Path.GetExtension(strEditFilePath); } MainProgram.frmMain.Grid[MainProgram.frmMain.Grid.Selection.ActivePosition.Row, (int)MainProgram.enuGrid.FILENAME].Value = strAfterKey; MainProgram.frmMain.updateKeyIndex(strBeforeKey, strAfterKey); // プレビューファイル名更新 MainProgram.frmMain.PreviewFileName = Path.GetFileName(strAfterKey); } } } catch (Exception ex) { // エラーメッセージ MainProgram.ShowMessage(ex.Message, MainProgram.MES_TITLE_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); } } // 常に手前だったら戻す if (MainProgram.frmMain.frmOpt.AlwaysOnTop == true) { MainProgram.Foremost(true); } }
/// <summary> /// スプラッシュスクリーン表示する /// </summary> public void StartWait() { if (MainProgram.frmMain.frmOpt.AlwaysOnTop == true) { MainProgram.Foremost(false); } // Program Manager のハンドルを取得する //System.IntPtr hProgramManagerHandle = FindWindow(null, "Program Manager"); // 正しく取得できた場合は、Program Manager を親ウィンドウに設定する //if (!hProgramManagerHandle.Equals(System.IntPtr.Zero)) //{ // SetParent(this.Handle, hProgramManagerHandle); //} //this.SendToBack(); //this.SendToBack(); //this.SendToBack(); //this.SendToBack(); IntPtr HWND_BOTTOM = new IntPtr(1); const UInt32 SWP_NOSIZE = 0x0001; const UInt32 SWP_NOMOVE = 0x0002; const UInt32 SWP_NOREDRAW = 0x0008; //for (int i = 0; i < 1000; i++) //{ // this.SendToBack(); //} SetParent(this.Handle, GetDesktopWindow()); Rectangle rect = Screen.PrimaryScreen.Bounds; this.Width = rect.Width; this.Height = rect.Height; this.picWait.Width = rect.Width; this.picWait.Height = rect.Height; //this.StartPosition = FormStartPosition.Manual; this.Top = 0; this.Left = 0; //Bitmapの作成 Bitmap bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); //Graphicsの作成 Graphics g = Graphics.FromImage(bmp); //Graphicsのデバイスコンテキストを取得 IntPtr hDC = g.GetHdc(); System.IntPtr hwndDesktop = GetDC(GetDesktopWindow()); //IntPtr dc = GetDC(IntPtr.Zero); //IntPtr hwndDesktop = IntPtr.Zero; //PaintDesktop(hwndDesktop); const int SRCCOPY = 13369376; //Bitmapに画像をコピーする BitBlt(hDC, 0, 0, bmp.Width, bmp.Height, hwndDesktop, 0, 0, SRCCOPY); //解放 g.ReleaseHdc(hDC); g.Dispose(); ReleaseDC(hwndDesktop); //bmp.Save(@"c:\test.bmp"); // this.SetStyle(ControlStyles.DoubleBuffer, true); // this.SetStyle(ControlStyles.UserPaint, true); //this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); //this.SetStyle(ControlStyles.Opaque, true); //表示 this.BackgroundImage = bmp; this.Show(); SetWindowPos(this.Handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOREDRAW); Application.DoEvents(); }
/// <summary> /// 壁紙を登録する /// </summary> /// <param name="strAddFilePath">登録する壁紙のパス</param> private void AddWallpaper(string strAddFilePath) { // 常に手前を解除 MainProgram.Foremost(false); // コピー先パス string strCopyFilePath = this.txtWallpaperFolder.Text + "\\" + Path.GetFileName(strAddFilePath); // コピーファイルが存在するか確認 if (File.Exists(strCopyFilePath)) { // もしすでに存在していたら //拡張子取得 string strExt = Path.GetExtension(strAddFilePath); //違う名前を入力してもらう string strNewFileName = Microsoft.VisualBasic.Interaction.InputBox(MainProgram.MES_FILE_NEWNAME, MainProgram.MES_FILE_EXISTS, "Wallpaper" + DateTime.Now.ToString("yyyymmdd") + DateTime.Now.ToString("hhmmss"), -1, -1); if (strNewFileName == "") { // キャンセルされたら登録せずに終了 return; } // コピー先パスを更新 strCopyFilePath = this.WallpaperFolder + "\\" + strNewFileName + "." + strExt; } // 壁紙を登録(ファイル移動) try { File.Move(strAddFilePath, strCopyFilePath); } catch (Exception ex) { MainProgram.ShowMessage(ex.Message, MainProgram.MES_TITLE_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); } // 登録後壁紙設定するか確認する。 DialogResult ret = MessageBox.Show(Path.GetFileName(strCopyFilePath) + "を壁紙に設定しますか?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (ret == DialogResult.Yes) { // OKが選択されたら // リストを再構築 this.ListCreate(); // 追加した壁紙を選択状態にする ListWallpaperSelected(GetWallpaperKey(strCopyFilePath)); // 追加した壁紙を現在の壁紙にする MainFunc.NowWallpaperUpdate(strCopyFilePath, strCopyFilePath); // 壁紙にする MainProgram.frmMain.btnApply_Click(new Object(), new EventArgs()); } // 常に手前だったら戻す if (MainProgram.frmMain.frmOpt.AlwaysOnTop == true) { MainProgram.Foremost(true); } }
/// <summary> /// 常に手前チェックボックスが変更されたとき /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void chkForemost_CheckedChanged(object sender, EventArgs e) { MainProgram.Foremost(!this.TopMost); }