private void buttonNewFile_Click(object sender, RoutedEventArgs e) { XamDialogWindow win = CreateDialogWindow(150); win.Header = "创建文件"; StackPanel stack = new StackPanel(); stack.VerticalAlignment = VerticalAlignment.Center; stack.Margin = new Thickness(10); Label label = new Label(); label.Content = "请输入文件名"; stack.Children.Add(label); TextBox txtName = new TextBox(); txtName.Text = "文本文件.txt"; stack.Children.Add(txtName); StackPanel stackButton = new StackPanel(); stackButton.Orientation = Orientation.Horizontal; stackButton.HorizontalAlignment = HorizontalAlignment.Center; stack.Children.Add(stackButton); Button btnOK = new Button(); btnOK.Content = "创建"; btnOK.Padding = new Thickness(10, 0, 10, 0); btnOK.Margin = new Thickness(10); stackButton.Children.Add(btnOK); Button btnCancel = new Button(); btnCancel.Content = "取消"; btnCancel.Padding = new Thickness(10, 0, 10, 0); btnCancel.Margin = new Thickness(10); stackButton.Children.Add(btnCancel); FadeOutWindow(); win.Content = stack; win.IsModal = true; windowContainer.Children.Add(win); txtName.Focus(); btnOK.Click += delegate { VFS.Directory dir = vfs.NewDirectory(currentDirectory); if (dir.Contains(txtName.Text)) { System.Windows.Forms.MessageBox.Show("该文件或文件夹已存在", "创建失败", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtName.Focus(); return; } try { VFS.File file = vfs.NewFile(currentDirectory + txtName.Text, VFS.FileMode.CreateNew); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "创建失败", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtName.Focus(); return; } win.Close(); windowContainer.Children.Remove(win); FadeInWindow(); Reload(); }; btnCancel.Click += delegate { win.Close(); windowContainer.Children.Remove(win); FadeInWindow(); }; }
private void buttonRename_Click(object sender, RoutedEventArgs e) { var item = (DirectoryItem)listView.SelectedItem; if (item == null) { return; } XamDialogWindow win = CreateDialogWindow(150); win.Header = "重命名"; StackPanel stack = new StackPanel(); stack.VerticalAlignment = VerticalAlignment.Center; stack.Margin = new Thickness(10); Label label = new Label(); label.Content = "请输入新文件" + (item.isDirectory ? "夹" : "") + "名"; stack.Children.Add(label); TextBox txtName = new TextBox(); txtName.Text = item.name; stack.Children.Add(txtName); StackPanel stackButton = new StackPanel(); stackButton.Orientation = Orientation.Horizontal; stackButton.HorizontalAlignment = HorizontalAlignment.Center; stack.Children.Add(stackButton); Button btnOK = new Button(); btnOK.Content = "重命名"; btnOK.Padding = new Thickness(10, 0, 10, 0); btnOK.Margin = new Thickness(10); stackButton.Children.Add(btnOK); Button btnCancel = new Button(); btnCancel.Content = "取消"; btnCancel.Padding = new Thickness(10, 0, 10, 0); btnCancel.Margin = new Thickness(10); stackButton.Children.Add(btnCancel); FadeOutWindow(); win.Content = stack; win.IsModal = true; windowContainer.Children.Add(win); txtName.Focus(); btnOK.Click += delegate { VFS.Directory dir = vfs.NewDirectory(currentDirectory); if (dir.Contains(txtName.Text)) { System.Windows.Forms.MessageBox.Show("新文件或文件夹名已存在", "重命名失败", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtName.Focus(); return; } try { dir.Rename(item.name, txtName.Text); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "重命名失败", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtName.Focus(); return; } win.Close(); windowContainer.Children.Remove(win); FadeInWindow(); Reload(); }; btnCancel.Click += delegate { win.Close(); windowContainer.Children.Remove(win); FadeInWindow(); }; }
private void HandleOnSettingTaskClickedEvent(object sender,Manager.Common.Settings.TaskScheduler taskScheduler) { RunSettingTaskDetail control = new RunSettingTaskDetail(taskScheduler); XamDialogWindow window = new XamDialogWindow(); window.FontSize = 12; window.StartupPosition = StartupPosition.Center; window.IsModal = false; window.Header = "任务详细"; window.Width = 455; window.Height = 345; window.Content = control; window.Show(); this.MainFrame.Children.Add(window); window.BringToFront(); control.OnExited += new RoutedEventHandler(delegate(object sender2, RoutedEventArgs e2) { window.Close(); }); }
private void listView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { const int bufferSize = 4096; var item = (DirectoryItem)listView.SelectedItem; if (item == null) { return; } if (item.isDirectory) { if (item.name == ".") { Reload(); return; } if (item.name == "..") { GoUp(); return; } if (history.Count - historyNeedle - 1 > 0) { history.RemoveRange(historyNeedle + 1, history.Count - historyNeedle - 1); } var newDir = currentDirectory + item.name + "/"; if (LoadDirectory(newDir)) { history.Add(newDir); historyNeedle++; buttonForward.IsEnabled = (historyNeedle + 1 < history.Count); buttonBack.IsEnabled = (historyNeedle - 1 >= 0); } } else { // 读取文件内容到临时变量 String tempFileName = System.IO.Path.GetTempFileName() + System.IO.Path.GetExtension(item.path); using (System.IO.BinaryWriter writer = new System.IO.BinaryWriter(new System.IO.FileStream(tempFileName, System.IO.FileMode.Create))) { var file = vfs.NewFile(item.path, VFS.FileMode.Open); byte[] buffer = new byte[bufferSize]; int count; while ((count = (int)file.Read(buffer, 0, (uint)buffer.Length)) != 0) { writer.Write(buffer, 0, count); } } FadeOutWindow(); XamDialogWindow win = CreateDialogWindow(); win.Header = "VFS"; Label label = new Label(); label.Content = "正在等待应用程序关闭, 文件内容将在程序关闭后自动更新..."; label.VerticalContentAlignment = VerticalAlignment.Center; label.HorizontalAlignment = HorizontalAlignment.Center; win.Content = label; win.IsModal = true; windowContainer.Children.Add(win); Utils.ProcessUITasks(); // 调用系统默认程序打开 var process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo(tempFileName); process.EnableRaisingEvents = true; process.Start(); try { process.WaitForExit(); } catch (Exception ex) { } // 在关闭后,读取内容写回文件系统 using (System.IO.BinaryReader reader = new System.IO.BinaryReader(new System.IO.FileStream(tempFileName, System.IO.FileMode.Open))) { var file = vfs.NewFile(item.path, VFS.FileMode.Create); byte[] buffer = new byte[bufferSize]; int count; while ((count = reader.Read(buffer, 0, buffer.Length)) != 0) { file.Write(buffer, 0, (uint)count); } } win.Close(); windowContainer.Children.Remove(win); FadeInWindow(); Reload(); UpdateInfo(); } }
private void Close(XamDialogWindow commonDialogWin) { if (commonDialogWin != null) { commonDialogWin.WindowState = Infragistics.Controls.Interactions.WindowState.Hidden; commonDialogWin.Close(); this._LayoutContainer.Children.Remove(commonDialogWin); commonDialogWin = null; } }
private void ButtonTool_Click(object sender, RoutedEventArgs e) { XamDialogWindow win = new XamDialogWindow() { Width = 350, Height = 150, StartupPosition = StartupPosition.Center, CloseButtonVisibility = Visibility.Collapsed }; win.Header = "格式化"; StackPanel stack = new StackPanel(); stack.VerticalAlignment = VerticalAlignment.Center; stack.Margin = new Thickness(10); Label label = new Label(); label.Content = "您确认要格式化文件系统吗?"; stack.Children.Add(label); StackPanel stackButton = new StackPanel(); stackButton.Orientation = Orientation.Horizontal; stackButton.HorizontalAlignment = HorizontalAlignment.Center; stack.Children.Add(stackButton); Button btnOK = new Button(); btnOK.Content = "格式化"; btnOK.Padding = new Thickness(10, 0, 10, 0); btnOK.Margin = new Thickness(10); stackButton.Children.Add(btnOK); Button btnCancel = new Button(); btnCancel.Content = "取消"; btnCancel.Padding = new Thickness(10, 0, 10, 0); btnCancel.Margin = new Thickness(10); stackButton.Children.Add(btnCancel); //FadeOutWindow(); win.Content = stack; win.IsModal = true; grid.Children.Add(win); btnOK.Click += delegate { VFS.Format(); currentDir = VFS.ROOT_DIR; recorder.Add(currentDir); listView.ItemsSource = VFS.ROOT_DIR.directoryData; url.Text = currentDir.GetPath(); win.Close(); grid.Children.Remove(win); }; btnCancel.Click += delegate { win.Close(); grid.Children.Remove(win); }; }
private void ButtonTool_Rename(object sender, RoutedEventArgs e) { Information inf = (Information)listView.SelectedItem; if (inf == null) { System.Windows.Forms.MessageBox.Show("请先选中文件或者文件夹", "选中失败", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } XamDialogWindow win = new XamDialogWindow() { Width = 350, Height = 150, StartupPosition = StartupPosition.Center, CloseButtonVisibility = Visibility.Collapsed }; win.Header = "重命名"; StackPanel stack = new StackPanel(); stack.VerticalAlignment = VerticalAlignment.Center; stack.Margin = new Thickness(10); Label label = new Label(); label.Content = "请输入新的名称:"; stack.Children.Add(label); TextBox txtName = new TextBox(); txtName.Text = inf.name; stack.Children.Add(txtName); StackPanel stackButton = new StackPanel(); stackButton.Orientation = Orientation.Horizontal; stackButton.HorizontalAlignment = HorizontalAlignment.Center; stack.Children.Add(stackButton); Button btnOK = new Button(); btnOK.Content = "确认"; btnOK.Padding = new Thickness(10, 0, 10, 0); btnOK.Margin = new Thickness(10); stackButton.Children.Add(btnOK); Button btnCancel = new Button(); btnCancel.Content = "取消"; btnCancel.Padding = new Thickness(10, 0, 10, 0); btnCancel.Margin = new Thickness(10); stackButton.Children.Add(btnCancel); //FadeOutWindow(); win.Content = stack; win.IsModal = true; grid.Children.Add(win); btnOK.Click += delegate { String name = Utils.GetLegalCopyName(txtName.Text, currentDir); inf.entry.SetName(name); foreach (var v in currentDir.directoryData) { if (inf.name == v.name) { inf.name = name; ICollectionView view = CollectionViewSource.GetDefaultView(listView.ItemsSource); view.Refresh(); break; } } win.Close(); grid.Children.Remove(win); }; btnCancel.Click += delegate { win.Close(); grid.Children.Remove(win); }; }
private void ButtonToolDelete(object sender, RoutedEventArgs e) { XamDialogWindow win = new XamDialogWindow() { Width = 350, Height = 150, StartupPosition = StartupPosition.Center, CloseButtonVisibility = Visibility.Collapsed }; win.Header = "删除"; StackPanel stack = new StackPanel(); stack.VerticalAlignment = VerticalAlignment.Center; stack.Margin = new Thickness(10); Label label = new Label(); Information inf = (Information)listView.SelectedItem; if (inf == null) { System.Windows.Forms.MessageBox.Show("请先选中要删除文件或者文件夹", "删除失败", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } label.Content = "您确认要删除该" + (inf.extension == "文本文件" ? "文件" : "文件夹") + "吗?"; stack.Children.Add(label); StackPanel stackButton = new StackPanel(); stackButton.Orientation = Orientation.Horizontal; stackButton.HorizontalAlignment = HorizontalAlignment.Center; stack.Children.Add(stackButton); Button btnOK = new Button(); btnOK.Content = "删除"; btnOK.Padding = new Thickness(10, 0, 10, 0); btnOK.Margin = new Thickness(10); stackButton.Children.Add(btnOK); Button btnCancel = new Button(); btnCancel.Content = "取消"; btnCancel.Padding = new Thickness(10, 0, 10, 0); btnCancel.Margin = new Thickness(10); stackButton.Children.Add(btnCancel); //FadeOutWindow(); win.Content = stack; win.IsModal = true; grid.Children.Add(win); btnOK.Click += delegate { inf.entry.DeleteData(); currentDir.directory.Remove(inf.entry); currentDir.directoryData.Remove(inf); win.Close(); grid.Children.Remove(win); }; btnCancel.Click += delegate { win.Close(); grid.Children.Remove(win); }; }
private void CloseDialog() { dialog.Close(); }