※上記の広告は60日以上更新のないWIKIに表示されています。更新することで広告が下部へ移動します。


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace ReplayFolderSelecter
{
    public partial class Form1 : Form
    {
        private EntryManager em = new EntryManager();
 
        private CurrentReplayFolder current = new CurrentReplayFolder();
 
        #region update
 
        private static void _checkMBACReplayFolder()
        {
            if (!Directory.Exists(Util.REPLAY_FOLDER))
            {
                MessageBox.Show("MBACのカレントリプレイフォルダが見つかりません", "ERROR");
                Environment.Exit(0);
            }
        }
 
        private void UpdateEntry()
        {
            _checkMBACReplayFolder();
            em.Update();
            string[] nicknames = em.GetNicknames();
 
            entryListBox.Items.Clear();
            entryListBox.Items.AddRange(nicknames);
 
            moveComboBox.Items.Clear();
            moveComboBox.Items.AddRange(nicknames);
 
            swapButton.Enabled = false;
            renameButton.Enabled = false;
            dissoluteButton.Enabled = false;
            moveButton.Enabled = false;
        }
 
        private void UpdateCurrent()
        {
            _checkMBACReplayFolder();
            current.Update();
            currentFolderText.Text = current.Nickname;
 
            replayListBox.Items.Clear();
            replayListBox.Items.AddRange(current.Replays);
 
            repRenameText.Text = "";
            repRenameButton.Enabled = false;
            repDeleteButton.Enabled = false;
 
            headerButton.Enabled = false;
            moveButton.Enabled = false;
        }
 
        private void updateButton_Click(object sender, EventArgs e)
        {
            UpdateEntry();
            UpdateCurrent();
        }
 
        #endregion
 
        public Form1()
        {
            InitializeComponent();
            UpdateEntry();
            UpdateCurrent();
        }
 
        #region タブ1枚目
 
        private void currentButton_Click(object sender, EventArgs e)
        {
            RenameDialog rd = new RenameDialog(current.Nickname);
            if (rd.ShowDialog() == DialogResult.OK)
            {
                current.Nickname = rd.GetResult();
                currentFolderText.Text = current.Nickname;
            }
        }
 
        private void renameButton_Click(object sender, EventArgs e)
        {
            int i = entryListBox.SelectedIndex;
            RenameDialog rd = new RenameDialog(em.GetNickname(i));
            if (rd.ShowDialog() == DialogResult.OK)
            {
                em.SetNickname(rd.GetResult(), i);
                UpdateEntry();
            }
        }
 
        private void swapButton_Click(object sender, EventArgs e)
        {
            int i = entryListBox.SelectedIndex;
            em.SwapFolder(i);
            UpdateEntry();
            UpdateCurrent();
        }
 
        private void newButton_Click(object sender, EventArgs e)
        {
            em.CreateFolder();
            UpdateEntry();
        }
 
        private void dissoluteButton_Click(object sender, EventArgs e)
        {
            int i = entryListBox.SelectedIndex;
            em.DissoluteFolder(i);
            UpdateEntry();
            UpdateCurrent();
        }
 
        #endregion
 
        #region タブ2枚目
 
        private void headerButton_Click(object sender, EventArgs e)
        {
            string repname = (string)replayListBox.SelectedItem;
            HeaderDialog.ShowInstance(repname);
        }
 
        private void moveButton_Click(object sender, EventArgs e)
        {
            string repname = (string)replayListBox.SelectedItem;
            em.MoveReplay(repname, moveComboBox.SelectedIndex);
            UpdateCurrent();
        }
 
        private void repRenameButton_Click(object sender, EventArgs e)
        {
            string oldname = (string)replayListBox.SelectedItem;
            current.RenameReplay(oldname, repRenameText.Text);
            UpdateCurrent();
        }
 
        private void repDeleteButton_Click(object sender, EventArgs e)
        {
            string repname = (string)replayListBox.SelectedItem;
            current.RemoveReplay(repname);
            UpdateCurrent();
        }
 
        #endregion
 
        #region on/off
 
        private void entryListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            bool f = (entryListBox.SelectedIndex >= 0);
            swapButton.Enabled = f;
            renameButton.Enabled = f;
            dissoluteButton.Enabled = f;
        }
 
        private void replayListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            bool f = (replayListBox.SelectedIndex >= 0);
            headerButton.Enabled = f;
            repDeleteButton.Enabled = f;
            moveButton.Enabled = (f && moveComboBox.SelectedIndex >= 0);
            repRenameButton.Enabled = (f && repRenameText.Text.Length > 0);
        }
 
        private void repRenameText_TextChanged(object sender, EventArgs e)
        {
            repRenameButton.Enabled =
                (replayListBox.SelectedIndex >= 0 && repRenameText.Text.Length > 0);
        }
 
        private void moveComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            moveButton.Enabled =
                (moveComboBox.SelectedIndex >= 0 && replayListBox.SelectedIndex >= 0);
        }
 
        #endregion
}
 






添付ファイル