private void OnMenuItem(object sender, EventArgs e) { string[] arr = sender.ToString().Split(':'); string name = arr[arr.Length - 1]; string[] tmp = name.Split(' '); string deviceName = ""; for (int i = 0; i < tmp.Length - 1; i++) { if (i != 0) { deviceName += " " + tmp[i]; } else { deviceName += tmp[i]; } } deviceName = deviceName.Substring(1, deviceName.Length - 1); string action = "turn" + tmp[tmp.Length - 1]; int id = Telldus.GetId(deviceName); Telldus.DeviceAction(id, action); System.Diagnostics.Debug.Write(id); }
private void metroGrid1_DoubleClick(object sender, EventArgs e) { string name = GetSelected(); string action1 = "turnon"; string action2 = "turnoff"; int id = Telldus.GetId(name); Save.SaveDevice(name + " on", id, action1); Save.SaveDevice(name + " off", id, action2); Save.GetDevices(); metroGrid2.DataSource = Save.GetNoIdDevices(); }
public MainForm() { InitializeComponent(); this.BackColor = Color.FromArgb(64, 64, 64); this.Opacity = 0.85; this.ShowInTaskbar = false; this.Height = Convert.ToInt32(Screen.PrimaryScreen.WorkingArea.Size.Height * 0.7); this.Width = Convert.ToInt32(Screen.PrimaryScreen.WorkingArea.Size.Width * 0.3); Rectangle workingArea = Screen.GetWorkingArea(this); this.Location = new Point(workingArea.Right - Size.Width, workingArea.Bottom - Size.Height); System.Diagnostics.Debug.Write("Height" + this.Height); System.Diagnostics.Debug.Write("Width" + this.Width); trayIcon = new NotifyIcon(); trayIcon.Text = "Telldus"; trayIcon.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); this.Deactivate += new EventHandler(this.MainForm_Focus); this.Resize += new EventHandler(this.MainForm_Resize); this.trayIcon.MouseClick += new MouseEventHandler(this.NotifyIcon_MouseClick); this.FormClosing += new FormClosingEventHandler(this.MainForm_Resize); var list = Telldus.GetNames(); metroGrid1.RowHeadersVisible = false; metroGrid1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; metroGrid1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; metroGrid1.DataSource = list; Save.GetDevices(); var saves = Save.GetNoIdDevices(); metroGrid2.RowHeadersVisible = false; metroGrid2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; metroGrid2.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; metroGrid2.DataSource = saves; metroGrid1.DoubleClick += new EventHandler(this.metroGrid1_DoubleClick); metroGrid2.DoubleClick += new EventHandler(this.metroGrid2_DoubleClick); this.WindowState = FormWindowState.Minimized; }