private void UpdateLayout() { Layout.ClearLayout(); var index = 0; foreach (var componentLog in Parameters.ComponentLogs) { using (Layout.BeginGroupBox(new GroupBox { Text = $"Component {++index}" })) { var module = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList }; module.Items.AddRange(Apex.EnumUtil.GetValuesCombo <LogModule>()); module.SelectedItem = componentLog.LoggingModule; module.SelectedIndexChanged += (object sender, EventArgs e) => { componentLog.LoggingModule = (LogModule)module.SelectedItem; }; var level = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList }; level.Items.AddRange(Apex.EnumUtil.GetValuesCombo <LogLevel>()); level.SelectedItem = componentLog.LoggingLevel; level.SelectedIndexChanged += (object sender, EventArgs e) => { componentLog.LoggingLevel = (LogLevel)level.SelectedItem; }; var delete = new Button { Text = "Delete Module" }; delete.Click += (object sender, EventArgs e) => { DeleteModule(componentLog); }; using (Layout.BeginRow()) { Layout.AddControl(new Label { Text = "Logging Module" }); Layout.AddControl(module); } using (Layout.BeginRow()) { Layout.AddControl(new Label { Text = "Logging Level" }); Layout.AddControl(level); } Layout.AddControl(delete); } } Layout.AddControl(btnNew); Layout.ProcessLayout(); }
public void RefreshTraces() { Layout.ClearLayout(); foreach (var trace in Parent.NetworkParameters.Traces) { using (Layout.BeginGroupBox(new GroupBox { Text = trace.Name })) { if (trace.Attributes != null) { foreach (var traceAttribute in trace.Attributes) { using (Layout.BeginRow()) { Layout.AddControl(new Label() { Text = traceAttribute.ToString() }); } } } using (Layout.BeginRow()) { var editButton = new Button() { Text = "Edit" }; editButton.Click += (object sender, EventArgs e) => { EditTrace(trace); }; var deleteButton = new Button() { Text = "Delete" }; deleteButton.Click += (object sender, EventArgs e) => { DeleteTrace(trace); }; Layout.AddControl(editButton); Layout.AddControl(deleteButton); } } } Layout.ProcessLayout(); }
public void RefreshPlots() { Layout.ClearLayout(); foreach (var plot in Parent.NetworkParameters.Plots) { using (Layout.BeginGroupBox(new GroupBox { Text = $"{plot.Name} ({plot.Width}x{plot.Height})" })) { foreach (var attribute in plot.Attributes) { using (Layout.BeginRow()) { Layout.AddControl(new Label() { Text = attribute.ToString() }); } } using (Layout.BeginRow()) { var editButton = new Button() { Text = "Edit" }; editButton.Click += (object sender, EventArgs e) => { EditPlot(plot); }; var deleteButton = new Button() { Text = "Delete" }; deleteButton.Click += (object sender, EventArgs e) => { DeletePlot(plot); }; Layout.AddControl(editButton); Layout.AddControl(deleteButton); } } } Layout.ProcessLayout(); }
public void LoadTrace(Trace Trace, bool New = true) { // Don't update link if the trace was updated by this form. if (New) { // Clone object and keep a reference to the original so we can quit without saving. TraceLink = Trace; CurrentTrace = new Trace(Trace); Trace = CurrentTrace; } txtName.Text = Trace.Name; txtStartTime.Text = Trace.StartTime.ToString(); txtEndTime.Text = Trace.EndTime.ToString(); chkStartTime.Checked = Trace.CommonStartTime; chkEndTime.Checked = Trace.CommonEndTime; if (Trace.Attributes == null) { Trace.Attributes = new List <TraceAttribute>(); } if (Trace.Attributes.Count == 0) { AddAttribute(Trace); } Layout.ClearLayout(); using (Layout.BeginRow()) { Layout.AddControl(lblName); Layout.AddControl(txtName); } using (Layout.BeginRow()) { Layout.AddControl(chkStartTime); Layout.AddControl(txtStartTime); } using (Layout.BeginRow()) { Layout.AddControl(chkEndTime); Layout.AddControl(txtEndTime); } using (Layout.BeginPanel(pnlAttributes)) { var index = 0; foreach (var attribute in Trace.Attributes) { using (Layout.BeginGroupBox(new GroupBox { Text = $"Attribute {++index}" })) { var attributeCombo = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList }; var elementCombo = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList }; var code = new TextBox { Text = attribute.Code, Enabled = attribute.IncrementMode == TraceAttribute.Increment.Custom }; var deleteButton = new Button { Text = "Delete Attribute" }; var evaluationCombo = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList }; #region "Element Source" elementCombo.Items.AddRange(Parent.Parent.Items.ToArray()); elementCombo.SelectedItem = attribute.Element; elementCombo.SelectedValueChanged += (object sender, EventArgs e) => { attribute.Element = (IDrawable)elementCombo.SelectedItem; LoadTrace(Trace, false); }; if (attribute.Element is Node || attribute.Element is Domain) { attributeCombo.Items.AddRange(new string[] { "MacTx", "MacTxDrop", "MacRx", "PhyTxEnd", "PhyTxDrop", "PhyRxEnd", "PhyRxDrop", "Tx", "Rx", "SendOutgoing", "UnicastForward", "LocalDeliver", "Enqueue", "Dequeue", "Drop" }); } else if (attribute.Element is Link) { attributeCombo.Items.AddRange(new string[] { "MacTx", "MacTxDrop", "MacRx", "PhyTxBegin", "PhyTxEnd", "PhyTxDrop", "PhyRxEnd", "PhyRxDrop", "Enqueue", "Dequeue", "Drop" }); } else if (attribute.Element is Stream) { attributeCombo.Items.AddRange(new string[] { "Tx", "Rx", "CongestionWindow" }); } attributeCombo.SelectedItem = attribute.TraceSource; // Element type has changed the old source no longer exists. if (attributeCombo.SelectedIndex == -1) { attributeCombo.SelectedIndex = 0; attribute.TraceSource = attributeCombo.SelectedItem as string; } using (Layout.BeginRow()) { Layout.AddControl(new Label { Text = "Element Source" }); Layout.AddControl(elementCombo); } #endregion if (attribute.Element is Stream) { Layout.AddControl(new Label { Text = $"Direction: {(attribute.Element as Stream).StartNode.Text} -> {(attribute.Element as Stream).EndNode.Text}" }); } if (attribute.Element is Link) { var start = attribute.LinkReverse ? (attribute.Element as Link).EndNode : (attribute.Element as Link).StartNode; var end = attribute.LinkReverse ? (attribute.Element as Link).StartNode : (attribute.Element as Link).EndNode; var direction = new Label { Text = $"Direction: {start.Text} -> {end.Text}" }; var reverse = new CheckBox { Text = "Reverse", Checked = attribute.LinkReverse }; reverse.CheckedChanged += (object sender, EventArgs e) => { attribute.LinkReverse = reverse.Checked; direction.Text = $"Direction: {(reverse.Checked ? end.Text : start.Text)} -> {(reverse.Checked ? start.Text : end.Text)}"; }; using (Layout.BeginRow()) { Layout.AddControl(direction); Layout.AddControl(reverse); } } #region "Attribute Source" attributeCombo.SelectedValueChanged += (object sender, EventArgs e) => { attribute.TraceSource = attributeCombo.SelectedItem as string; code.Text = attribute.Code; }; using (Layout.BeginRow()) { Layout.AddControl(new Label { Text = "Attribute Source" }); Layout.AddControl(attributeCombo); } #endregion #region "Delete Row" using (Layout.BeginRow()) { deleteButton.Click += (object sender, EventArgs e) => { DeleteAttribute(Trace, attribute); }; Layout.AddControl(new Label { Text = "Evaluation Code" }); Layout.AddControl(deleteButton); } #endregion #region "Evaluation" code.TextChanged += (object sender, EventArgs e) => { if ((sender as TextBox).Enabled) { attribute.Code = (sender as TextBox).Text; } }; evaluationCombo.Items.AddRange(new object[] { TraceAttribute.Increment.PacketIncrement, TraceAttribute.Increment.PacketDecrement, TraceAttribute.Increment.PacketSizeIncrement, TraceAttribute.Increment.PacketSizeDecrement, TraceAttribute.Increment.Custom }); evaluationCombo.SelectedItem = attribute.IncrementMode; evaluationCombo.SelectedValueChanged += (object sender, EventArgs e) => { attribute.IncrementMode = (TraceAttribute.Increment)evaluationCombo.SelectedItem; code.Enabled = attribute.IncrementMode == TraceAttribute.Increment.Custom; code.Text = attribute.Code; }; using (Layout.BeginRow()) { Layout.AddControl(evaluationCombo); Layout.AddControl(code); } #endregion } } } var btnAddAttribute = new Button { Text = "Add attribute" }; btnAddAttribute.Click += (object sender, EventArgs e) => { AddAttribute(Trace); LoadTrace(Trace, false); }; Layout.AddControl(btnAddAttribute); using (Layout.BeginRow()) { Layout.AddControl(btnSave); Layout.AddControl(btnDelete); } Layout.ProcessLayout(); // Shrink attributes panel so it doesn't go off the bottom of the form. if (btnSave.Bottom > ClientSize.Height) { pnlAttributes.Height -= (btnSave.Bottom - ClientSize.Height); pnlAttributes.Left -= 8; pnlAttributes.Width += 16; btnAddAttribute.Top = pnlAttributes.Bottom + 6; btnSave.Top = btnAddAttribute.Bottom + 6; btnDelete.Top = btnAddAttribute.Bottom + 6; Apex.ControlUtil.ShowScrollBar(pnlAttributes.Handle, Apex.ControlUtil.ScrollBarDirection.Horizontal, false); } }
public void LoadPlot(Plot Plot, bool New = true) { var controlPairs = new Tuple <Control, Control>[] { new Tuple <Control, Control>(lblName, txtName), new Tuple <Control, Control>(lblLegend, cmbLegend), new Tuple <Control, Control>(pnlWidth, pnlHeight), new Tuple <Control, Control>(lblXAxis, txtXAxis), new Tuple <Control, Control>(lblYAxis, txtYAxis), new Tuple <Control, Control>(lblY2Axis, txtY2Axis) }; // Don't update link if the plot was updated by this form. if (New) { // Clone object and keep a reference to the original so we can quit without saving. PlotLink = Plot; CurrentPlot = new Plot(Plot); Plot = CurrentPlot; } txtName.Text = Plot.Name; cmbLegend.SelectedItem = Plot.LegendLocation; txtWidth.Text = Plot.Width.ToString(); txtHeight.Text = Plot.Height.ToString(); txtXAxis.Text = Plot.XAxisLabel; txtYAxis.Text = Plot.YAxisLabel; txtY2Axis.Text = Plot.Y2AxisLabel; chkDisabled.Checked = Plot.Disabled; if (Plot.Attributes.Count == 0) { AddAttribute(Plot); } Layout.ClearLayout(); if (this.Width > 500) { for (int i = 0; i < controlPairs.Length; i += 2) { using (Layout.BeginRow()) { Layout.AddControl(controlPairs[i].Item1); Layout.AddControl(controlPairs[i].Item2); if (controlPairs.Length > i + 1) { Layout.AddControl(controlPairs[i + 1].Item1); Layout.AddControl(controlPairs[i + 1].Item2); } } } } else { foreach (var pair in controlPairs) { using (Layout.BeginRow()) { Layout.AddControl(pair.Item1); Layout.AddControl(pair.Item2); } } } using (Layout.BeginPanel(pnlAttributes)) { var index = 0; foreach (var attribute in Plot.Attributes) { using (Layout.BeginGroupBox(new GroupBox { Text = $"Attribute {++index}" })) { var cmbParameter = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList }; cmbParameter.Items.AddRange(Parent.Parent.NetworkParameters.Traces.ToArray()); cmbParameter.SelectedItem = attribute.TraceParameter; cmbParameter.SelectedIndexChanged += (object sender, EventArgs e) => { attribute.TraceParameter = (Trace)cmbParameter.SelectedItem; }; var cmbAveragingType = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList }; cmbAveragingType.Items.AddRange(Apex.EnumUtil.GetValuesCombo <PlotAttribute.Averaging>()); cmbAveragingType.SelectedItem = attribute.AveragingType; cmbAveragingType.SelectedIndexChanged += (object sender, EventArgs e) => { attribute.AveragingType = (PlotAttribute.Averaging)cmbAveragingType.SelectedItem; }; var cmbPlotType = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList }; cmbPlotType.Items.AddRange(Apex.EnumUtil.GetValuesCombo <PlotAttribute.PlotType>()); cmbPlotType.SelectedItem = attribute.Type; cmbPlotType.SelectedIndexChanged += (object sender, EventArgs e) => { attribute.Type = (PlotAttribute.PlotType)cmbPlotType.SelectedItem; }; var txtWindowSize = new TextBox { Text = attribute.WindowWidth.ToString() }; txtWindowSize.KeyPress += Apex.InputFiltering.FilterNumeric; txtWindowSize.TextChanged += (object sender, EventArgs e) => { attribute.WindowWidth = float.Parse(txtWindowSize.Text); }; var txtModulo = new TextBox { Text = attribute.ModuloValue.ToString(), Enabled = attribute.ModuloEnabled }; txtModulo.KeyPress += Apex.InputFiltering.FilterNumeric; txtModulo.TextChanged += (object sender, EventArgs e) => { attribute.ModuloValue = float.Parse(txtModulo.Text); }; var chkModulo = new CheckBox { Text = "Modulo", Checked = attribute.ModuloEnabled }; chkModulo.CheckedChanged += (object sender, EventArgs e) => { attribute.ModuloEnabled = chkModulo.Checked; txtModulo.Enabled = chkModulo.Checked; }; var txtMin = new TextBox { Text = attribute.MinValue.ToString(), Enabled = attribute.MinEnabled }; txtMin.KeyPress += Apex.InputFiltering.FilterNumeric; txtMin.TextChanged += (object sender, EventArgs e) => { attribute.MinValue = float.Parse(txtMin.Text); }; var chkMin = new CheckBox { Text = "Min", Checked = attribute.MinEnabled }; chkMin.CheckedChanged += (object sender, EventArgs e) => { attribute.MinEnabled = chkMin.Checked; txtMin.Enabled = chkMin.Checked; }; var txtMax = new TextBox { Text = attribute.MaxValue.ToString(), Enabled = attribute.MaxEnabled }; txtMax.KeyPress += Apex.InputFiltering.FilterNumeric; txtMax.TextChanged += (object sender, EventArgs e) => { attribute.MaxValue = float.Parse(txtMax.Text); }; var chkMax = new CheckBox { Text = "Max", Checked = attribute.MaxEnabled }; chkMax.CheckedChanged += (object sender, EventArgs e) => { attribute.MaxEnabled = chkMax.Checked; txtMax.Enabled = chkMax.Checked; }; var txtScaleData = new TextBox { Text = attribute.ScaleDataCommand, Enabled = attribute.ScaleData }; txtScaleData.TextChanged += (object sender, EventArgs e) => { attribute.ScaleDataCommand = txtScaleData.Text; }; var chkScaleData = new CheckBox { Text = "Scale Data", Checked = attribute.ScaleData }; chkScaleData.CheckedChanged += (object sender, EventArgs e) => { attribute.ScaleData = chkScaleData.Checked; txtScaleData.Enabled = chkScaleData.Checked; }; var chkY2 = new CheckBox { Text = "Use Y2 Axis", Checked = attribute.UseY2Axis }; chkY2.CheckedChanged += (object sender, EventArgs e) => { attribute.UseY2Axis = chkY2.Checked; }; var chkShowPoints = new CheckBox { Text = "Show Points", Checked = attribute.ShowPoints }; chkShowPoints.CheckedChanged += (object sender, EventArgs e) => { attribute.ShowPoints = chkShowPoints.Checked; }; var chkShowLines = new CheckBox { Text = "Show Lines", Checked = attribute.ShowLines }; chkShowLines.CheckedChanged += (object sender, EventArgs e) => { attribute.ShowLines = chkShowLines.Checked; }; var btnDeleteAttribute = new Button { Text = "Delete Attribute" }; btnDeleteAttribute.Click += (object sender, EventArgs e) => { DeleteAttribute(Plot, attribute); }; // Put twice as much stuff on one line if there is space. if (this.Width > 500) { using (Layout.BeginRow()) { Layout.AddControl(new Label { Text = "Traced Parameter" }); Layout.AddControl(cmbParameter); Layout.AddControl(new Label { Text = "Window Width" }); Layout.AddControl(txtWindowSize); } using (Layout.BeginRow()) { Layout.AddControl(new Label { Text = "Averaging Type" }); Layout.AddControl(cmbAveragingType); Layout.AddControl(new Label { Text = "Plot Type" }); Layout.AddControl(cmbPlotType); } using (Layout.BeginRow()) { Layout.AddControl(chkModulo); Layout.AddControl(txtModulo); Layout.AddControl(chkScaleData); Layout.AddControl(txtScaleData); } using (Layout.BeginRow()) { Layout.AddControl(chkMin); Layout.AddControl(txtMin); Layout.AddControl(chkMax); Layout.AddControl(txtMax); } using (Layout.BeginRow()) { Layout.AddControl(chkY2); Layout.AddControl(chkShowPoints); Layout.AddControl(chkShowLines); Layout.AddControl(btnDeleteAttribute); } } else { using (Layout.BeginRow()) { Layout.AddControl(new Label { Text = "Traced Parameter" }); Layout.AddControl(cmbParameter); } using (Layout.BeginRow()) { Layout.AddControl(new Label { Text = "Window Width" }); Layout.AddControl(txtWindowSize); } using (Layout.BeginRow()) { Layout.AddControl(new Label { Text = "Averaging Type" }); Layout.AddControl(cmbAveragingType); } using (Layout.BeginRow()) { Layout.AddControl(new Label { Text = "Plot Type" }); Layout.AddControl(cmbPlotType); } using (Layout.BeginRow()) { Layout.AddControl(chkModulo); Layout.AddControl(txtModulo); } using (Layout.BeginRow()) { Layout.AddControl(chkScaleData); Layout.AddControl(txtScaleData); } using (Layout.BeginRow()) { Layout.AddControl(chkMin); Layout.AddControl(txtMin); } using (Layout.BeginRow()) { Layout.AddControl(chkMax); Layout.AddControl(txtMax); } using (Layout.BeginRow()) { Layout.AddControl(chkY2); Layout.AddControl(chkShowPoints); } using (Layout.BeginRow()) { Layout.AddControl(chkShowLines); Layout.AddControl(btnDeleteAttribute); } } } } } var btnAddAttribute = new Button { Text = "Add attribute" }; btnAddAttribute.Click += (object sender, EventArgs e) => { AddAttribute(Plot); LoadPlot(Plot, false); }; Layout.AddControl(btnAddAttribute); using (Layout.BeginRow()) { Layout.AddControl(btnSave); Layout.AddControl(btnDelete); } Layout.ProcessLayout(); // Shrink attributes panel so it doesn't go off the bottom of the form. if (btnSave.Bottom > ClientSize.Height) { pnlAttributes.Height -= (btnSave.Bottom - ClientSize.Height); pnlAttributes.Left -= 8; pnlAttributes.Width += 16; btnAddAttribute.Top = pnlAttributes.Bottom + 6; btnSave.Top = btnAddAttribute.Bottom + 6; btnDelete.Top = btnAddAttribute.Bottom + 6; Apex.ControlUtil.ShowScrollBar(pnlAttributes.Handle, Apex.ControlUtil.ScrollBarDirection.Horizontal, false); } }