private void MainForm_Load(object sender, EventArgs e) { if (StartWithWindowsRegistryKey.GetValue(StartWithWindowsRegistryKeyName) != null) { StartWithWindowsCB.Checked = true; BeginInvoke((MethodInvoker)MinimizeToTray); } DashButtonListener.OnNetworkListenerStarted += OnNetworkListenerStarted; DashButtonListener.OnDashButtonClicked += OnDashButtonClicked; DashButtonListener.OnActionExceptionThrown += OnActionExceptionThrown; DashButtonListener.OnExceptionThrown += OnExceptionThrown; Log("Starting network listeners..."); Task.Run(() => { try { DashButtonListener.Start(); } catch (DashButtonCoreException dbce) { Log($"An error has occurred while starting the network listener: \n" + dbce.Message); } }); }
public MainForm() { InitializeComponent(); Size = FormSettings.FormSize; HorizontalSplitContainer.SplitterDistance = FormSettings.SplitterDistance; DashButtonListener.LoadButtons(); DashButtonsBindingList = new BindingList <DashButton>(DashButtonListener.DashButtons); DashButtonsTable.DataSource = new BindingSource(DashButtonsBindingList, null); DataGridViewButtonColumn testButtonColumn = new DataGridViewButtonColumn { Name = "Test", HeaderText = "Test", Text = "Test", UseColumnTextForButtonValue = true, AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells }; DashButtonsTable.Columns.Add(testButtonColumn); DashButtonsTable.Columns["Enabled"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; DashButtonsTable.Columns["MacAddress"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; DashButtonsTable.Columns["Description"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; DashButtonsTable.Columns["ActionUrl"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; }
public DashButtonService() { InitializeComponent(); DashButtonListener.OnNetworkListenerStarted += DashButtonListener_OnNetworkListenerStarted; DashButtonListener.OnDashButtonClicked += DashButtonListener_OnDashButtonClicked; DashButtonListener.OnActionExceptionThrown += DashButtonListener_OnActionExceptionThrown; DashButtonListener.OnExceptionThrown += DashButtonListener_OnExceptionThrown; DashButtonListener.LoadButtons(); FileSystemWatcher.Changed += DashButtonFile_Changed; FileSystemWatcher.EnableRaisingEvents = true; }
private void DashButtonFile_Changed(object sender, FileSystemEventArgs e) { if (e.FullPath.Equals(DashButtonListener.DashButtonsFilePath)) { try { DashButtonListener.LoadButtons(); EventLog.WriteEntry("Reloaded dash buttons file."); } catch (IOException) { } // Ignore if the file is in use. } }
protected override void OnStart(string[] args) { EventLog.WriteEntry("Starting network listener..."); try { DashButtonListener.Start(); EventLog.WriteEntry(DashButtonListener.DashButtons.Count + " buttons registered."); } catch (DashButtonCoreException e) { OnExceptionThrown(e); } }
private void DashButtonsTable_CellEndEdit(object sender, DataGridViewCellEventArgs e) { DashButtonListener.SaveButtons(); Log("Saved dash buttons table."); }