Ejemplo n.º 1
0
        private void dataGridViewRoutes_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            string routeId = dataGridViewRoutes.Rows[e.RowIndex].Cells["ColumnId"].Value.ToString();

            using (FormRoute formRoute = new FormRoute(_connectionInfo, routeId))
            {
                if (formRoute.ShowDialog() == DialogResult.OK)
                {
                    RefreshRouteList();
                }
            }
        }
Ejemplo n.º 2
0
        private void Menu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            string routeId = string.Empty;

            if (dataGridViewRoutes.CurrentRow != null)
            {
                routeId = (dataGridViewRoutes.CurrentRow.Cells[ColumnId.Index].Value ?? "").ToString();
            }

            if (e.ClickedItem.Text != "Browse")
            {
                (sender as ContextMenuStrip)?.Hide();
            }

            switch (e.ClickedItem.Text)
            {
            case "Add":
                using (FormRoute formRoute = new FormRoute(_connectionInfo, null))
                {
                    if (formRoute.ShowDialog() == DialogResult.OK)
                    {
                        RefreshRouteList();
                    }
                }
                break;

            case "Refresh":
                RefreshRouteList();
                break;

            case "Start":
                _packeteer.SendAll(Constants.CommandLables.GuiPersistStartRoute, routeId);
                RefreshRouteList();
                break;

            case "Stop":
                if (MessageBox.Show(@"Stop the selected route?", Constants.TitleCaption, MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    _packeteer.SendAll(Constants.CommandLables.GuiPersistStopRoute, routeId);
                    RefreshRouteList();
                }

                break;

            case "Edit":
                using (FormRoute formRoute = new FormRoute(_connectionInfo, routeId))
                {
                    if (formRoute.ShowDialog() == DialogResult.OK)
                    {
                        RefreshRouteList();
                    }
                }
                break;

            case "Delete":
                if (MessageBox.Show(@"Delete the selected route?", Constants.TitleCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    _packeteer.SendAll(Constants.CommandLables.GuiPersistDeleteRoute, routeId);
                    RefreshRouteList();
                }
                break;
            }
        }