Ejemplo n.º 1
0
        // --------------------------------------------------------------------
        // ファイル命名規則の変数の表示用文字列を生成
        // --------------------------------------------------------------------
        private List <String> CreateRuleVarLabels()
        {
            List <String> aLabels               = new List <String>();
            TextInfo      aTextInfo             = Thread.CurrentThread.CurrentCulture.TextInfo;
            Dictionary <String, String> aVarMap = NklCommon.CreateRuleDictionaryWithDescription();

            foreach (KeyValuePair <String, String> aVar in aVarMap)
            {
                String aKey;
                if (aVar.Key == NklCommon.RULE_VAR_ANY)
                {
                    aKey = aVar.Key;
                }
                else
                {
                    aKey = NklCommon.RULE_VAR_BEGIN + aTextInfo.ToTitleCase(aVar.Key) + NklCommon.RULE_VAR_END;
                }
                aLabels.Add(aKey + "(" + aVar.Value + ")");
            }
            return(aLabels);
        }
Ejemplo n.º 2
0
        // --------------------------------------------------------------------
        // データグリッドビューを更新
        // --------------------------------------------------------------------
        private void UpdateDataGridViewPreview(Object oDummy)
        {
            try
            {
                // 準備
                DisableComponents();
                SetCursor(Cursors.WaitCursor);

                Invoke(new Action(() =>
                {
                    // クリア
                    DataGridViewPreview.Rows.Clear();

                    // 検索
                    String[] aAllPathes = Directory.GetFiles(mFolder);

                    // マッチをリストに追加
                    FolderSettingsInDisk aFolderSettingsInDisk     = NklCommon.LoadFolderSettings(mFolder);
                    FolderSettingsInMemory aFolderSettingsInMemory = NklCommon.CreateFolderSettingsInMemory(aFolderSettingsInDisk);
                    Dictionary <String, String> aRuleMap           = NklCommon.CreateRuleDictionaryWithDescription();
                    foreach (String aPath in aAllPathes)
                    {
                        if (!mOutputSettings.TargetExts.Contains(Path.GetExtension(aPath).ToLower()))
                        {
                            continue;
                        }

                        // ファイル命名規則とフォルダー固定値を適用
                        Dictionary <String, String> aDic = NklCommon.MatchFileNameRulesAndFolderRule(Path.GetFileNameWithoutExtension(aPath), aFolderSettingsInMemory);

                        // DGV 追加
                        DataGridViewPreview.Rows.Add();
                        Int32 aIndex = DataGridViewPreview.Rows.Count - 1;

                        // ファイル
                        DataGridViewPreview.Rows[aIndex].Cells[(Int32)PreviewColumns.File].Value = Path.GetFileName(aPath);

                        // 項目と値
                        StringBuilder aSB = new StringBuilder();
                        foreach (KeyValuePair <String, String> aKvp in aDic)
                        {
                            if (aKvp.Key != NklCommon.RULE_VAR_ANY && !String.IsNullOrEmpty(aKvp.Value))
                            {
                                aSB.Append(aRuleMap[aKvp.Key] + "=" + aKvp.Value + ", ");
                            }
                        }
                        DataGridViewPreview.Rows[aIndex].Cells[(Int32)PreviewColumns.Matches].Value = aSB.ToString();

                        // 編集
                        DataGridViewPreview.Rows[aIndex].Cells[(Int32)PreviewColumns.Edit].Value = "編集";
                    }

                    // 選択解除
                    DataGridViewPreview.ClearSelection();

                    // 次の編集候補ボタン
                    UpdateButtonJump();
                }));
            }
            catch (OperationCanceledException)
            {
                ShowLogMessage(Common.TRACE_EVENT_TYPE_STATUS, "ファイル検索結果更新を中止しました。");
            }
            catch (Exception oExcep)
            {
                ShowLogMessage(TraceEventType.Error, "ファイル検索結果更新更新時エラー:\n" + oExcep.Message);
                ShowLogMessage(TraceEventType.Verbose, " スタックトレース:\n" + oExcep.StackTrace);
            }
            finally
            {
                // 後片付け
                SetCursor(Cursors.Default);
                EnableComponents();
            }
        }