~ubuntu-branches/ubuntu/wily/openmcdf/wily

« back to all changes in this revision

Viewing changes to src/TESTOpenMCDF/Utils.cs

  • Committer: Package Import Robot
  • Author(s): Mathieu Malaterre
  • Date: 2013-04-08 11:02:15 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130408110215-aleqo4zhjc3qgxnb
Tags: 1.5.4-1
* New upstream: 1.5.4
  - Use Hexbox for hexadecimal viewing

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.Collections.Generic;
 
3
using System.Text;
 
4
using System.Windows.Forms;
 
5
using System.Drawing;
 
6
using OpenMcdf;
 
7
 
 
8
namespace StructuredStorageExplorer
 
9
{
 
10
    class Utils
 
11
    {
 
12
        public static DialogResult InputBox(string title, string promptText, ref string value)
 
13
        {
 
14
            Form form = new Form();
 
15
            Label label = new Label();
 
16
            TextBox textBox = new TextBox();
 
17
            Button buttonOk = new Button();
 
18
            Button buttonCancel = new Button();
 
19
 
 
20
            form.Text = title;
 
21
            label.Text = promptText;
 
22
            textBox.Text = value;
 
23
 
 
24
            buttonOk.Text = "OK";
 
25
            buttonCancel.Text = "Cancel";
 
26
            buttonOk.DialogResult = DialogResult.OK;
 
27
            buttonCancel.DialogResult = DialogResult.Cancel;
 
28
 
 
29
            label.SetBounds(9, 20, 372, 13);
 
30
            textBox.SetBounds(12, 36, 372, 20);
 
31
            buttonOk.SetBounds(228, 72, 75, 23);
 
32
            buttonCancel.SetBounds(309, 72, 75, 23);
 
33
 
 
34
            label.AutoSize = true;
 
35
            textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
 
36
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
 
37
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
 
38
 
 
39
            form.ClientSize = new Size(396, 107);
 
40
            form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
 
41
            form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
 
42
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
 
43
            form.StartPosition = FormStartPosition.CenterScreen;
 
44
            form.MinimizeBox = false;
 
45
            form.MaximizeBox = false;
 
46
            form.AcceptButton = buttonOk;
 
47
            form.CancelButton = buttonCancel;
 
48
 
 
49
            DialogResult dialogResult = form.ShowDialog();
 
50
            value = textBox.Text;
 
51
            return dialogResult;
 
52
        }
 
53
 
 
54
        public static bool IsStreamTreeNode(TreeNode node)
 
55
        {
 
56
            return ((CFItem)node.Tag).IsStream;
 
57
        }
 
58
    }
 
59
 
 
60
 
 
61
 
 
62
 
 
63
}