Example #1
0
 void Connect()
 {
     if (server != null)
     {
         server.Connect();
         if (Connected)
         {
             server.IsNewSwitch   += IsNewSwitch;
             server.IsNewNumber   += IsNewNumber;
             server.IsNewText     += IsNewText;
             server.IsDelProperty += IsDelProperty;
             server.QueryProperties();
             DevicesConnected.Size = new Size(495, 395);
             this.Controls.Clear();
             this.Controls.Add(DevicesConnected);
             this.ClientSize      = new Size(500, 400);
             this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
         }
     }
 }
Example #2
0
        public INDIChooser(string address = "127.0.0.1", int port = 7624)
        {
            Int32 y = 15;
            Label l = new Label();

            l.Text              = "Connect to address:";
            l.Location          = new Point(5, y);
            l.Size              = new Size(190, 23);
            y                  += 33;
            Address.BorderStyle = BorderStyle.FixedSingle;
            Address.Name        = "address";
            Address.Text        = address + ":" + port.ToString();
            Address.Location    = new Point(5, y);
            Address.Size        = new Size(190, 23);
            y                  += 33;
            Controls.Add(Address);
            Controls.Add(l);
            Button b = new Button();

            b.FlatStyle = FlatStyle.Flat;
            b.Text      = "Connect";
            b.Location  = new Point(5, y);
            b.Size      = new Size(190, 23);
            y          += 33;
            b.Click    += delegate
            {
                Device.Items.Clear();
                client              = new INDIClient(Address.Text);
                client.DeviceAdded += Indi_DeviceAdded;
                client.Connect();
                if (client.Connected)
                {
                    client.QueryProperties();
                }
            };
            Controls.Add(b);
            DeviceType.FlatStyle = FlatStyle.Flat;
            DeviceType.Text      = "Select device";
            DeviceType.Size      = new Size(190, 23);
            DeviceType.Location  = new Point(5, y);
            string[] types = Enum.GetNames(typeof(DRIVER_INTERFACE));
            DeviceType.Items.AddRange(types);
            DeviceType.DropDownStyle         = ComboBoxStyle.DropDownList;
            DeviceType.SelectedIndexChanged += Device_SelectedIndexChanged;
            y += 33;
            Controls.Add(DeviceType);
            Device.FlatStyle             = FlatStyle.Flat;
            Device.Text                  = "Select device";
            Device.Size                  = new Size(190, 23);
            Device.Location              = new Point(5, y);
            Device.DropDownStyle         = ComboBoxStyle.DropDownList;
            Device.SelectedIndexChanged += Device_SelectedIndexChanged;
            y += 33;
            Controls.Add(Device);
            b           = new Button();
            b.FlatStyle = FlatStyle.Flat;
            b.Text      = "OK";
            b.Location  = new Point(5, y);
            b.Size      = new Size(190, 23);
            y          += 33;
            b.Click    += delegate
            {
                if (client == null || !client.Connected)
                {
                    MessageBox.Show("Not Connected to any server!", "ERROR");
                }
                else if (deviceSelected == "")
                {
                    MessageBox.Show("No device selected!", "ERROR");
                }
                else
                {
                    Close();
                }
            };
            Controls.Add(b);
            b           = new Button();
            b.FlatStyle = FlatStyle.Flat;
            b.Text      = "Cancel";
            b.Location  = new Point(5, y);
            b.Size      = new Size(190, 23);
            y          += 33;
            b.Click    += delegate
            {
                if (client != null)
                {
                    client.Disconnect();
                    client.Dispose();
                }
                client = null;
                Close();
            };
            Controls.Add(b);
            this.ClientSize      = new Size(200, y);
            this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
        }