コード例 #1
0
        /// <summary>
        /// デリートスキップを実行する
        /// </summary>
        /// <param name="DeleteFile">削除ファイルパス</param>
        /// <param name="bolChange">削除後、壁紙変更するか</param>
        public void DeleteSkip(string DeleteFile, bool bolChange)
        {
            // 設定されている壁紙をTrashBoxに移動
            if (DeleteFile != "" && File.Exists(DeleteFile))
            {
                try
                {
                    // ファイルを移動
                    File.Move(DeleteFile, MainProgram.ApplicationPath + "\\TrashBox\\" + Path.GetFileName(DeleteFile));
                }
                catch (Exception ex)
                {
                    MainProgram.ShowMessage(ex.Message, MainProgram.MES_TITLE_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MainProgram.ShowMessage(MainProgram.MES_FILE_DELETED, MainProgram.MES_TITLE_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            // 壁紙の変更
            if (bolChange == true)
            {
                WallpaperChange();
            }
        }
コード例 #2
0
            /// <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);
                }
            }
コード例 #3
0
        /// <summary>
        /// 壁紙を変更する(チェンジ)
        /// </summary>
        public void WallpaperChange()
        {
            int num = 0;

            int lstCount  = MainProgram.frmMain.Grid.RowsCount;
            int lstMaxNum = lstCount;

            if (lstCount > 1)
            {
                // チェンジモードにより処理をわける
                switch (MainProgram.frmMain.frmOpt.ChangeMode)
                {
                case (int)MainProgram.enuChgMode.RANDOM:
                    // ランダム

                    Random rnd = new Random();

                    num = rnd.Next(1, lstMaxNum);
                    while (MainProgram.frmMain.WallpaperFolder + "\\" + (string)MainProgram.frmMain.Grid[num, (int)MainProgram.enuGrid.FILENAME].Value ==
                           MainProgram.frmMain.NowWallpaper)
                    {
                        num = rnd.Next(1, lstMaxNum);
                    }
                    break;

                case (int)MainProgram.enuChgMode.NORMAL:
                    // ノーマル

                    num = MainProgram.frmMain.GetKeyIndex(Path.GetFileName(MainProgram.frmMain.NowWallpaper));
                    num++;
                    if (lstMaxNum == num)
                    {
                        num = 1;
                    }
                    break;

                case (int)MainProgram.enuChgMode.NONE:
                    // なし

                    return;
                }
            }
            else if (lstCount == 2)
            {
                // 1行しかないときはそれを選択する。
                num = 2;
            }
            else if (lstCount == 1)
            {
                // フォルダに画像がない場合は終了(ヘッダしかない)

                MainProgram.ShowMessage(MainProgram.MES_GRAPHIC_NOTHING + MainProgram.frmMain.WallpaperFolder,
                                        MainProgram.MES_TITLE_INFO,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                Environment.Exit(0);
                return;
            }

            // BGWC壁紙設定
            BGWChanerWallpaperSetting((string)MainProgram.frmMain.Grid[num, (int)MainProgram.enuGrid.FILENAME].Value);
        }
コード例 #4
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);
            }
        }