private void UpdatePacketDisplay() { LogPacket p = GetCurrentPacket(); if (p == null) { return; } if (!_newStyleLogViewer) { frameEditorControl.ReadOnly = ReadOnly; } frameEditorControl.SetFrame(p.Frame, null, ColorValueConverter.ToColor(p.Color)); if (p.Frame.IsBasic || (ReadOnly && !_newStyleLogViewer)) { toolStripButtonConvertToBytes.Enabled = false; } else { toolStripButtonConvertToBytes.Enabled = true; } if (_newStyleLogViewer) { toolStripButtonSave.Enabled = IsFrameModified(); toolStripButtonRevert.Enabled = IsFrameModified(); } toolStripLabelPosition.Text = String.Format(CANAPE.Properties.Resources.PacketLogViewerForm_Header, _index + 1, _packets.Count, p.Tag, p.Network, p.Timestamp.ToString()); }
private void UpdateChart() { chartTagDetails.SuspendLayout(); string[] keys; long[] values; string tooltip; Color[] colors; if (comboBoxTagStatisticsType.SelectedIndex == 0) { keys = _bytag.Select(p => p.Key).ToArray(); values = _bytag.Select(p => p.Value.LongCount()).ToArray(); colors = _bytag.Select(p => ColorValueConverter.ToColor(p.Value.First().Color)).ToArray(); tooltip = Properties.Resources.TagStatisticsChartControl_CountToolTip; } else { keys = _bytag.Select(p => p.Key).ToArray(); values = _bytag.Select(p => p.Value.Sum(x => x.Length)).ToArray(); colors = _bytag.Select(p => ColorValueConverter.ToColor(p.Value.First().Color)).ToArray(); tooltip = Properties.Resources.TagStatisticsChartControl_ByteCountToolTip; } chartTagDetails.Series["Tags"].Points.DataBindXY(keys, values); chartTagDetails.Series["Tags"].ToolTip = tooltip; chartTagDetails.Series["Tags"].IsValueShownAsLabel = true; for (int i = 0; i < chartTagDetails.Series["Tags"].Points.Count; ++i) { chartTagDetails.Series["Tags"].Points[i].Color = colors[i]; } chartTagDetails.ResumeLayout(); }
void Graph_EditPacketEvent(object sender, EditPacketEventArgs e) { if (InvokeRequired) { Invoke(new EventHandler <EditPacketEventArgs>(Graph_EditPacketEvent), sender, e); } else { using (EditPacketForm frm = new EditPacketForm()) { frm.Frame = e.Frame; frm.Selector = e.SelectPath; frm.DisplayColor = ColorValueConverter.ToColor(e.Color); frm.DisplayTag = e.Tag; frm.ShowDisableEditor = true; frm.ShowReadOnly = true; if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { e.Frame = frm.Frame; } if (frm.DisableEditor) { if (e.Sender != null) { e.Sender.Enabled = false; } } } } }
public override void PaintValue(PaintValueEventArgs e) { if (e.Value is ColorValue) { using (Brush brush = new SolidBrush(ColorValueConverter.ToColor((ColorValue)e.Value))) { e.Graphics.FillRectangle(brush, e.Bounds); } } }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { if ((value is ColorValue) && (provider != null)) { IWindowsFormsEditorService service = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService; if (service != null) { using (ColorDialog frm = new ColorDialog()) { frm.Color = ColorValueConverter.ToColor((ColorValue)value); if (frm.ShowDialog() == DialogResult.OK) { value = ColorValueConverter.FromColor(frm.Color); } } } } return(value); }
EditPacketForm CreateEditor(EditPacketEventArgs e) { if (InvokeRequired) { return((EditPacketForm)Invoke(new Func <EditPacketEventArgs, EditPacketForm>(CreateEditor), e)); } else { EditPacketForm frm = new EditPacketForm(); frm.Frame = e.Frame; frm.Selector = e.SelectPath; frm.DisplayColor = ColorValueConverter.ToColor(e.Color); frm.DisplayTag = e.Tag; frm.ShowDisableEditor = true; frm.ShowReadOnly = true; frm.Show(); frm.Activate(); return(frm); } }