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
Login.cs
1using AForge;
2using Gtk;
3using javax.swing.text;
4using omero.gateway.model;
5using System;
6using System.Collections.Generic;
7using System.IO;
8using System.Linq;
9using System.Text;
10using System.Threading.Tasks;
11
12namespace BioGTK
13{
14 public class Login : Dialog
15 {
16 #region Properties
17 private Builder _builder;
18
19#pragma warning disable 649
20 [Builder.Object]
21 private Gtk.Entry usernameBox;
22 [Builder.Object]
23 private Gtk.Entry hostBox;
24 [Builder.Object]
25 private Gtk.Entry passwordBox;
26 [Builder.Object]
27 private Gtk.SpinButton portBox;
28 [Builder.Object]
29 private Gtk.Button loginBut;
30 [Builder.Object]
31 private Gtk.Button cancelBut;
32#pragma warning restore 649
33
34 #endregion
35
36 #region Constructors / Destructors
37 public static int IconWidth;
38 public static int IconHeight;
39 public List<Image> images = new List<Image>();
43 public static Login Create()
44 {
45 Builder builder = new Builder(new FileStream(System.IO.Path.GetDirectoryName(Environment.ProcessPath) + "/" + "Glade/login.glade", FileMode.Open));
46 return new Login(builder, builder.GetObject("login").Handle);
47 }
48
49 /* The constructor for the TextInput class. */
50 protected Login(Builder builder, IntPtr handle) : base(handle)
51 {
52 _builder = builder;
53 builder.Autoconnect(this);
54 App.ApplyStyles(this);
55 this.FocusInEvent += Login_FocusInEvent;
56 this.DeleteEvent += Login_DeleteEvent;
57 cancelBut.ButtonPressEvent += CancelBut_ButtonPressEvent;
58 loginBut.ButtonPressEvent += LoginButton_ButtonPressEvent;
59 portBox.Adjustment = new Adjustment(4064,0,9999,1,1,1);
60 BioLib.Settings.Load();
61 BioLib.OMERO.host = BioLib.Settings.GetSettings("host");
62 BioLib.OMERO.username = BioLib.Settings.GetSettings("username");
63 hostBox.Buffer.Text = BioLib.OMERO.host;
64 usernameBox.Buffer.Text = BioLib.OMERO.username;
65 string p = BioLib.Settings.GetSettings("port");
66 if (p != "")
67 {
68 BioLib.OMERO.port = int.Parse(p);
69 portBox.Value = BioLib.OMERO.port;
70 }
71 }
72
73 private void Login_FocusInEvent(object o, FocusInEventArgs args)
74 {
75 GrabFocus();
76 }
77
78 private void Login_DeleteEvent(object o, DeleteEventArgs args)
79 {
80 this.Hide();
81 }
82
83 private void CancelBut_ButtonPressEvent(object o, ButtonPressEventArgs args)
84 {
85 this.Hide();
86 this.Destroy();
87 }
88
89 private void LoginButton_ButtonPressEvent(object o, ButtonPressEventArgs args)
90 {
91 BioLib.OMERO.host = hostBox.Buffer.Text;
92 BioLib.OMERO.port = (int)portBox.Value;
93 BioLib.OMERO.username = usernameBox.Buffer.Text;
94 BioLib.OMERO.password = passwordBox.Buffer.Text;
95 try
96 {
97 BioLib.OMERO.Connect();
98 BioLib.Settings.AddSettings("host", BioLib.OMERO.host);
99 BioLib.Settings.AddSettings("username", BioLib.OMERO.username);
100 BioLib.Settings.AddSettings("port", BioLib.OMERO.port.ToString());
101 BioLib.Settings.Save();
102 this.DefaultResponse = ResponseType.Ok;
103 Respond(ResponseType.Ok);
104 Hide();
105 Destroy();
106 }
107 catch (Exception e)
108 {
109 var dialog = new MessageDialog(
110 null,
111 DialogFlags.Modal,
112 MessageType.Info,
113 ButtonsType.Ok,
114 "Error logging in to OMERO."
115 );
116
117 dialog.Title = "Error logging in to OMERO.";
118 dialog.Run();
119 }
120
121 }
122 #endregion
123
124
125 }
126}
static Login Create()
Definition Login.cs:43
Definition ML.cs:17
Definition Zarr.cs:20