BioGTK  6.7.0
A .NET library & program for annotating, editing various microscopy imaging formats using Bioformats supported images. Including whole slide, pyramidal, and series.
Loading...
Searching...
No Matches
ComboPicker.cs
1using Gtk;
2using System;
3using System.Collections.Generic;
4using System.IO;
5using System.Linq;
6using System.Text;
7using System.Threading.Tasks;
8
9namespace BioGTK
10{
11 public class ComboPicker : Dialog
12 {
13 #region Properties
14 private Builder _builder;
15
16#pragma warning disable 649
17 [Builder.Object]
18 private Gtk.Button okBut;
19 [Builder.Object]
20 private Gtk.Button cancelBut;
21 [Builder.Object]
22 private Gtk.ComboBox comboBox;
23 [Builder.Object]
24 private Gtk.Label label;
25#pragma warning restore 649
26
27 #endregion
28
29 #region Constructors / Destructors
30 string selection;
31 Type ens;
35 public static ComboPicker Create(string[] sts)
36 {
37 Builder builder = new Builder(new FileStream(System.IO.Path.GetDirectoryName(Environment.ProcessPath) + "/" + "Glade/ComboPicker.glade", FileMode.Open));
38 return new ComboPicker(builder, builder.GetObject("comboPicker").Handle, sts);
39 }
40
44 public static ComboPicker Create(string l,string[] sts)
45 {
46 Builder builder = new Builder(new FileStream(System.IO.Path.GetDirectoryName(Environment.ProcessPath) + "/" + "Glade/ComboPicker.glade", FileMode.Open));
47 return new ComboPicker(builder, builder.GetObject("comboPicker").Handle,l, sts);
48 }
49
53 public static ComboPicker Create(Type ems)
54 {
55 Builder builder = new Builder(new FileStream(System.IO.Path.GetDirectoryName(Environment.ProcessPath) + "/" + "Glade/ComboPicker.glade", FileMode.Open));
56 return new ComboPicker(builder, builder.GetObject("comboPicker").Handle, ems);
57 }
58 /* The constructor for the ComboPicker class. */
59 protected ComboPicker(Builder builder, IntPtr handle, Type ems) : base(handle)
60 {
61 _builder = builder;
62 builder.Autoconnect(this);
63 okBut.ButtonPressEvent += OkBut_ButtonPressEvent;
64 cancelBut.ButtonPressEvent += CancelBut_ButtonPressEvent;
65 ens = ems;
66 List<string> sts = new List<string>();
67 Array ar = Enum.GetValues(ems);
68 foreach (Enum s in ar)
69 {
70 sts.Add(s.ToString());
71 }
72 var states = new ListStore(typeof(string));
73 //We add button states to buttonState box.
74 foreach (string val in sts)
75 {
76 states.AppendValues(val);
77 }
78 // Set the model for the ComboBox
79 comboBox.Model = states;
80 // Set the text column to display
81 var renderer2 = new CellRendererText();
82 comboBox.PackStart(renderer2, false);
83 comboBox.AddAttribute(renderer2, "text", 0);
84 comboBox.Active = 0;
85 App.ApplyStyles(this);
86 }
87 /* The constructor for the ComboPicker class. */
88 protected ComboPicker(Builder builder, IntPtr handle, string[] sts) : base(handle)
89 {
90 _builder = builder;
91 builder.Autoconnect(this);
92 okBut.ButtonPressEvent += OkBut_ButtonPressEvent;
93 cancelBut.ButtonPressEvent += CancelBut_ButtonPressEvent;
94 var states = new ListStore(typeof(string));
95 //We add button states to buttonState box.
96 foreach (string val in sts)
97 {
98 states.AppendValues(val);
99 }
100 // Set the model for the ComboBox
101 comboBox.Model = states;
102 // Set the text column to display
103 var renderer2 = new CellRendererText();
104 comboBox.PackStart(renderer2, false);
105 comboBox.AddAttribute(renderer2, "text", 0);
106 comboBox.Active = 0;
107 App.ApplyStyles(this);
108 }
109 /* The constructor for the ComboPicker class. */
110 protected ComboPicker(Builder builder, IntPtr handle,string l, string[] sts) : base(handle)
111 {
112 _builder = builder;
113 builder.Autoconnect(this);
114 okBut.ButtonPressEvent += OkBut_ButtonPressEvent;
115 cancelBut.ButtonPressEvent += CancelBut_ButtonPressEvent;
116 var states = new ListStore(typeof(string));
117 //We add button states to buttonState box.
118 foreach (string val in sts)
119 {
120 states.AppendValues(val);
121 }
122 // Set the model for the ComboBox
123 comboBox.Model = states;
124 // Set the text column to display
125 var renderer2 = new CellRendererText();
126 comboBox.PackStart(renderer2, false);
127 comboBox.AddAttribute(renderer2, "text", 0);
128 comboBox.Active = 0;
129 App.ApplyStyles(this);
130 }
131
136 private void CancelBut_ButtonPressEvent(object o, ButtonPressEventArgs args)
137 {
138 Respond(ResponseType.Cancel);
139 Hide();
140 }
141
142 private void OkBut_ButtonPressEvent(object o, ButtonPressEventArgs args)
143 {
144 Respond(ResponseType.Ok);
145 Hide();
146 }
147
148 /* A property that returns the selected index of the combobox. */
149 public int SelectedIndex
150 {
151 get { return comboBox.Active; }
152 }
153 #endregion
154
155 }
156}
static ComboPicker Create(string[] sts)
static ComboPicker Create(Type ems)
static ComboPicker Create(string l, string[] sts)
Definition ML.cs:17