用于文件操作的GUI。 [英] GUI for File manipulation.

查看:45
本文介绍了用于文件操作的GUI。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Visual Studio 2013(C#)创建一个窗口表单,它将加载并显示最多5个不同的文件。每个文件有16个部分需要单独显示。一旦加载了所有5个文件,我想根据拖放的顺序从5个文件中拖放部分来创建一个新文件。



文件大小不到1MB,每个部分都有固定的地址范围。



在Windows窗体中实现这一目标的最佳方法是什么?



现在我通过使用选中的列表框来实现这一目标,但它并没有给我上述描述的灵活性。感谢您提前提供任何帮助。



***更新***

感谢您的回复。



文件通常在十六进制编辑器中查看,因此不需要在文本窗口中查看实际数据。只有16个单独的固定地址范围,如列表框中的项目。



是否可以将项目从一个列表框拖放到另一个列表框?

I would like to create a windows form using Visual Studio 2013 (C#) that will load and display up to 5 different files. Each file has 16 sections that need to be displayed separately. Once all 5 files are loaded, I would like to create a new file based on dragging and dropping sections from the 5 files in the order they where dragged and dropped.

File sizes are under 1MB and have each section has a fixed address range.

What would be the best way to achieve this in a windows form?

Right now I'm achieving this by using checked list boxes, but it does not give me the flexibility the above description would. Thank you for any help in advance.

***Update***
Thank you for the responses.

The files are normally viewed in a hex editor, so the actual data does not need to be seen in a text window. Just the 16 individual fixed address ranges, like an item in a list box.

Is it possible to drag and drop an item from one list box to another?

推荐答案

想到的是每个部分都有一个TabPage。允许用户根据需要重新排序选项卡并关闭所有不需要的选项卡。然后,Save操作会将选项卡的内容以任何顺序保存到文件中。完成。
Something that comes to mind is to have a TabPage for each section. Allow the user to reorder the tabs as desired and close any undesired tabs. Then a Save operation would save the contents of the tabs to a file in whatever order they are. Done.




假设:


Assumptions:



  1. 所有五个文件的所有部分都要一次显示。

  2. 一个部分不能移动两次。

  3. 当拖动某个部分时,它将连续放置在目标区域中(即,拖动部分的顺序是拖动的顺序)。



我会并排使用两个RichTextBox来显示各个部分。左侧的RichTextBox包含源部分;在右侧选定的部分。我会用某种类型的封闭盒(比方说是蓝点)来衬托每个文件,每个部分都有不同类型的封闭盒(比如绿点)。


I'd use two RichTextBoxes side-by-side to display the sections. The RichTextBox on the left contains the source sections; that on the right the selected sections. I would set off each file with some type of enclosing box (say, blue-dotted) and each section with a different type of enclosing box (say green-dotted).



我在传输和XFR工具 - 扩展 [ ^ ](参见扩展程序)并找到它易于实施。请注意,该文章中的左右容器是ListBoxes而不是RichTextBoxes。


I've used this type of GUI in Transfer and XFR Tools - Extensions [^] (see Extensions) and found it easy to implement. Note that the left and right containers in that article are ListBoxes not RichTextBoxes.



当使用点击时在一个部分中,我会改变光标的形状和截面框的背景颜色。请注意,您需要处理MouseDown,MouseUp和MouseMove事件。


When the use clicks within a section, I'd change the shape of the cursor and the background color of the section box. Note you will need to handle MouseDown, MouseUp, and MouseMove events.



当用户发布时鼠标按钮,并且鼠标位置在目标RichTextBox内,将源节框的内容复制到新目标节框。 (最初,当移动光标时,只显示光标;稍后当所有内容都按预期工作时,通过在移动光标时拖动选定的部分框及其内容,可以变得更加华丽。)


When the user releases the mouse button, and the mouse position is within the target RichTextBox, copy the contents of the source section box to the new target section box. (Initially, when moving the cursor, just show the cursor; later when everything works as desired, you can become more flashy by dragging the chosen section box and its contents as the cursor is moved).



通过简单地删除源部分的内容并将该部分标记为不可移动来表示已移动部分的信号。或者,你可以完全删除该部分。


Signal that a section has been moved by simply removing the contents of the source section and marking the section as immovable. Alternately, you could just remove the section entirely.


我会创建一个这样的表格:



1.一个水平拆分容器已装满,'HSplit1



2.在#1的左侧面板中,TreeView Control已完全停靠, 'DocTreeView



3.在#1另一个水平拆分容器的右侧面板中,'HSplt2



4.在#2的左侧面板中,一个TextBox停靠,'SourceTextBox



5.在#2的右侧面板中,一个TextBox停靠,'DestinationTextBox



我会像这样设置TreeView:



1.给用户一些界面来选择最多五个文件



2.为每个文件添加一个根节点



3.解析每个文件确定各部分



4.为内部链接到每个文件各部分的每个根节点创建子节点



Th e程序的运行时行为:假设TreeView正确填充



1.用户点击根节点(文件),并选择一个部分(子节点)



2.与该部分相关联的文本在'SourceTextBox



中显示3.用户可以在'SourceTextBox中选择Text并将其拖放到'DestinationTextBox。



4.应用程序将提供一些有用的界面来保存内容'DestinationTextBox,用于更改当前打开的源文件,重建TreeView等。



注意:



1.从一个TextBox(或RichTextBox)拖放到另一个TextBox(或RichTextBox)的难度在于当前选择的鼠标按下(默认鼠标按下)将导致清除选择。要解决这个问题:你需要使用以下技术:



a。除非上下文单击鼠标按钮关闭,否则不要在MouseDown中调用'DoDragDrop;示例:
I would create a Form like this:

1. one horizontal split-container docked full, 'HSplit1

2. in the left panel of #1 a TreeView Control docked full, 'DocTreeView

3. in the right panel of #1 another horizontal split-container, 'HSplt2

4. in the left panel of #2 a TextBox docked full, 'SourceTextBox

5. in the right panel of #2 a TextBox docked full, 'DestinationTextBox

I would set-up the TreeView like this:

1. give the user some interface to select up to five files

2. add a root node for each file

3. parse each file to determine the sections

4. create child-nodes for each root-node internally linked to the sections of each file

The run-time behavior of the program: assuming the TreeView is filled properly

1. the user clicks on a root-node (file), and selects a section (child-node)

2. the text associated with that section is displlayed in the 'SourceTextBox

3. the user can select Text in the 'SourceTextBox and drag-drop it into the 'DestinationTextBox.

4. the Application would provide some useful interface for saving the contents of the 'DestinationTextBox, for changing the currently opened source files, rebuilding the TreeView, etc.

Notes:

1. The difficulty with drag-dropping from one TextBox (or RichTextBox) to another is that a mouse-down (default mouse-down) on the current selection will cause the selection to be cleared. To get around this: you need to use techniques like:

a. don't call 'DoDragDrop in the MouseDown unless the context-click mouse button is down; example:
private void SourceTextBox_MouseDown(object sender, MouseEventArgs e)
{
    if (MouseButtons == MouseButtons.Right)
    {
        SourceTextBox.DoDragDrop(SourceTextBox.SelectedText, DragDropEffects.Copy);
    }
}

b。使用修改后的WndProc和'OnMouseDown;见:[ ^ ]。



2.为什么使用水平分离器?答:为了方便用户使用UI。



如果您还有其他问题,请随时提出。

b. use a modified WndProc and an over-ride of 'OnMouseDown; see: [^].

2. Why use horizontal splitters ? Answer: for the user's convenience in using the UI.

If you have further questions, please feel free to ask.


这篇关于用于文件操作的GUI。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆