예제 #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            // データチェック
            if (!Directory.Exists(txtSaveDirectory.Text))
            {
                var err = new StringBuilder();
                err.AppendLine(@"以下のフォルダは存在しません。作成しますか?");
                err.Append(txtSaveDirectory.Text);
                var result =
                    MessageBox.Show(
                        err.ToString(),
                        @"保存先フォルダ",
                        MessageBoxButtons.YesNoCancel,
                        MessageBoxIcon.Information);
                if (result == DialogResult.Yes)
                {
                    Directory.CreateDirectory(txtSaveDirectory.Text);
                }
                else if (result == DialogResult.No)
                {
                    MessageBox.Show(@"「保存先ディレクトリ」には存在するフォルダを指定してください。");
                    return;
                }
                else
                {
                    return;
                }
            }
            if (IsInvalidFileNameFormat())
            {
                MessageBox.Show(
                    @"ファイル名のフォーマットが間違っています。",
                    @"ファイル名",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            Option.Instance().SaveDirectory  = txtSaveDirectory.Text;
            Option.Instance().FileNameFormat = txtFileNameFormat.Text;
            Option.Instance().ImageFormat    = ((KeyValuePair <string, ImageFormat>)cmbImageFormat.SelectedItem).Value;
            // 後処理
            //            op.DoAfterProcessing = chkDoAfterProcessing.Checked;
            //            op.DoResize = chkDoResize.Checked;
            //            op.WidthBiggerSrc = int.Parse(txtWidthBiggerSrc.Text);
            //            op.WidthBiggerDest = int.Parse(txtWidthBiggerDest.Text);
            //            op.WidthLessSrc = int.Parse(txtWidthLessSrc.Text);
            //            op.WidthLessDest = int.Parse(txtWidthLessDest.Text);
            //            op.HeightBiggerSrc = int.Parse(txtHeightBiggerSrc.Text);
            //            op.HeightBiggerDest = int.Parse(txtHeightBiggerDest.Text);
            //            op.HeightLessSrc = int.Parse(txtHeightLessSrc.Text);
            //            op.HeightLessDest = int.Parse(txtHeightLessDest.Text);
            //            op.KeepAspect = chkKeepAspect.Checked;
            //            op.AspectType = ((KeyValuePair<string, AspectType>)cmbKeepAspect.SelectedItem).Value;
            //            op.DoAfterEdit = chkDoAfterEdit.Checked;
            //            op.DoAfterEditPath = txtDoAfterEdit.Text;
            //            op.Save();
            Option.Save();
            Close();
        }
예제 #2
0
파일: Option.cs 프로젝트: rabbitka/RabiShot
 /// <summary>
 /// 設定した値を保存する。
 /// </summary>
 public static void Save()
 {
     if (_instance == null)
     {
         throw new InvalidOperationException("インスタンスが生成されていません。");
     }
     _instance.Save(FileName);
 }