コード例 #1
0
        /// <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);
            }
        }
コード例 #2
0
 /// <summary>
 /// 常に手前チェックボックスが変更されたとき
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void chkForemost_CheckedChanged(object sender, EventArgs e)
 {
     MainProgram.Foremost(!this.TopMost);
 }