Ejemplo n.º 1
0
        private void Pattern_Load(object sender, EventArgs e)
        {
            StringBuilder lines = new StringBuilder();
            List<string> target;

            label1.Text = fileName;

            Rename rn = new Rename();
            target = rn.ShowPattern(fileName);

            listView1.View = View.List;
            listView1.GridLines = true;

            listView1.Items.Add(string.Format("{0,6} = {1}", "<0>", fileName));
            for (int i = 0; i < target.Count; i++) {
                listView1.Items.Add(string.Format("{0,6} = {1}","<" + (i+1).ToString() + ">", target[i]));
            }
            listView1.Items.Add(string.Format("{0,6} = {1}", "<f>", Path.GetFileNameWithoutExtension(fileName)));
            listView1.Items.Add(string.Format("{0,6} = {1}", "<e>", Path.GetExtension(fileName)));
            listView1.Items.Add(string.Format("{0,6} = {1}", "<n>", (idx + 1).ToString(fmt)));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///  名前変更
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbFormat_KeyDown(object sender, KeyEventArgs e)
        {
            // リターンキーを押されたとき
            if (e.KeyCode == Keys.Return) {
                // 文字が入力されていること
                if (tbFormat.Text.Length > 0) {
                    DataRow data_row;
                    // マウスカーソル変更
                    Cursor preCursor = this.Cursor;
                    this.Cursor = Cursors.WaitCursor;

                    Rename rn = new Rename(tbFormat.Text);
                    rn.Setup(renameDataGrid.Rows.Count.ToString().Length);
                    clsRename();

                    // 名前変更処理
                    for (int i = 0; i < targetDataGrid.Rows.Count; i++) {
                        data_row = dtRename.NewRow();
                        data_row["file"] = rn.convert(targetDataGrid.Rows[i].Cells["file"].Value.ToString());
                        data_row["path"] = Path.GetDirectoryName(targetDataGrid.Rows[i].Cells["path"].Value.ToString())
                            + "\\" + data_row["file"];
                        data_row["Id"] = targetDataGrid.Rows[i].Cells["Id"].Value.ToString();
                        data_row["size"] = targetDataGrid.Rows[i].Cells["size"].Value.ToString();
                        data_row["date"] = targetDataGrid.Rows[i].Cells["date"].Value.ToString();
                        dtRename.Rows.Add(data_row);
                    }
                    renameDataGrid.DataSource = dtRename;
                    clearFocus();
                    this.Cursor = preCursor;
                }
            }
        }