예제 #1
0
        private void sortDown_button_Click(object sender, RoutedEventArgs e)  //下ボタン
        {
            int selectedIndex = files_listview.SelectedIndex;

            if (selectedIndex < 0)
            {
                AleartWindow aleartWindow = new AleartWindow
                {
                    windowName   = "Aleart",
                    aleartDetail = "Please select arbitrary file."
                };

                aleartWindow.ShowDialog();
                return;
            }

            if (selectedIndex < files_listview.Items.Count - 1) //一番下を選択中は無効
            {
                // ファイル名変更
                RenameFile(selectedIndex + 1, "wav", true);
                RenameFile(selectedIndex + 1, "txt", true);

                RenameFile(selectedIndex, "wav", false);
                RenameFile(selectedIndex, "txt", false);

                // DB入れ替え処理
                NKernel.fileName.Clear();
                List_init();
            }
        }
예제 #2
0
        /// <summary>
        /// ファイル名を変更します
        /// </summary>
        /// <param name="index">NKernel.fileName のインデックス</param>
        /// <param name="extension">拡張子</param>
        /// <param name="isUp">上に移動か</param>
        public void RenameFile(int index, string extension, bool isUp)
        {
            string _upData = NKernel.fileName[index];
            string _upDir  = NKernel.observeDirectory + @"\" + _upData + "." + extension;
            string _upedDir;

            if (isUp)
            {
                _upedDir = NKernel.observeDirectory + @"\" + index.ToString("000") + _upData.Remove(0, 3) + "." + extension;
            }
            else
            {
                _upedDir = NKernel.observeDirectory + @"\" + (index + 2).ToString("000") + _upData.Remove(0, 3) + "." + extension;
            }

            try
            {
                File.Move(_upDir, _upedDir);
            }
            catch
            {
                AleartWindow aleartWindow = new AleartWindow
                {
                    windowName   = "Error",
                    aleartDetail = "The required files could not be found."
                };

                aleartWindow.ShowDialog();
                this.Close(); //重大なエラー
            }
        }
예제 #3
0
        private void sortSelect_button_Click(object sender, RoutedEventArgs e)  //ファイル移動ボタン
        {
            int selectedIndex = files_listview.SelectedIndex;

            if (selectedIndex < 0)
            {
                AleartWindow aleartWindow = new AleartWindow
                {
                    windowName   = "Aleart",
                    aleartDetail = "Please select arbitrary file."
                };

                aleartWindow.ShowDialog();
                return;
            }

            FileMove fileMove = new FileMove();

            fileMove.maxIndex      = NKernel.fileName.Count - 1;
            fileMove.selectedIndex = selectedIndex;
            fileMove.ShowDialog();

            if (fileMove.trueClose) //ウィンドウが正しく閉じられた場合
            {
                int toMoveIndex = fileMove.moveNum;

                if (toMoveIndex < selectedIndex)
                {
                    for (int i = selectedIndex; i > toMoveIndex - 1; i--)
                    {
                        RenameFile(i - 1, "wav", false);
                        RenameFile(i - 1, "txt", false);
                    }

                    File.Move(NKernel.observeDirectory + @"\" + NKernel.fileName[selectedIndex] + ".wav", NKernel.observeDirectory + @"\" + toMoveIndex.ToString("000") + NKernel.fileName[selectedIndex].Remove(0, 3) + ".wav");
                    File.Move(NKernel.observeDirectory + @"\" + NKernel.fileName[selectedIndex] + ".txt", NKernel.observeDirectory + @"\" + toMoveIndex.ToString("000") + NKernel.fileName[selectedIndex].Remove(0, 3) + ".txt");
                }
                else if (toMoveIndex > selectedIndex)
                {
                    for (int i = selectedIndex; i < toMoveIndex - 1; i++)
                    {
                        RenameFile(i + 1, "wav", true);
                        RenameFile(i + 1, "txt", true);
                    }

                    File.Move(NKernel.observeDirectory + @"\" + NKernel.fileName[selectedIndex] + ".wav", NKernel.observeDirectory + @"\" + toMoveIndex.ToString("000") + NKernel.fileName[selectedIndex].Remove(0, 3) + ".wav");
                    File.Move(NKernel.observeDirectory + @"\" + NKernel.fileName[selectedIndex] + ".txt", NKernel.observeDirectory + @"\" + toMoveIndex.ToString("000") + NKernel.fileName[selectedIndex].Remove(0, 3) + ".txt");
                }

                NKernel.fileName.Clear();
                List_init();
            }
        }