예제 #1
0
        private void Menu_Click(object sender, RoutedEventArgs e)
        {
            MenuItem menu = sender as MenuItem;

            if (menu != null)
            {
                string menuName = menu.Tag as String;
                if (menuName != null)
                {
                    switch (menuName)
                    {
                    case "renameFile":
                        DlgRename dlg = new DlgRename();
                        if (dlg.ShowDialog() == true)
                        {
                            string oldFilename = @"D:\downloads\temp\oldfile.txt";
                            if (RenameFile(oldFilename, dlg.FileName))
                            {
                                MessageBox.Show($"{oldFilename} 파일의 이름을 {System.IO.Path.Combine(System.IO.Path.GetDirectoryName(oldFilename), dlg.FileName) + System.IO.Path.GetExtension(oldFilename)}으로 변경하였습니다");
                            }
                        }
                        break;

                    case "closeAll":
                        this.Close();
                        break;

                    case "print":
                        StartPrint();
                        break;
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 선택된 이미지 파일명 변경
        /// </summary>
        private void RenamePhoto()
        {
            string    fileName = (lbxPicture.SelectedItem as ListBoxItem).Tag as String;
            DlgRename dlg      = new DlgRename(System.IO.Path.GetFileNameWithoutExtension(fileName));

            if (dlg.ShowDialog() == true)
            {
                try
                {
                    File.Move(fileName, System.IO.Path.Combine(System.IO.Path.GetDirectoryName(fileName), dlg.NewFileName) + System.IO.Path.GetExtension(fileName));
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message
                                    , "파일명 변경 오류 안내"
                                    , MessageBoxButton.OK
                                    , MessageBoxImage.Error);
                }
            }
        }