public static float[] GetDashPattern(this LineStyle style) { DoubleCollection dashArray = style.GetStrokeDashArray(); if (dashArray == null) { return(null); } return(dashArray.Select(i => (float)i).ToArray()); }
public MainWindowVM() { _flooder = new Flooder(); _flooder.PropertyChanged += flooder_PropertyChanged; FlooderIsRunning = Visibility.Hidden; LatestResult = null; HistoryResult = null; Target = "<enter hostname here>"; PacketSizeOctets = 1250; BandwidthOctets = 125000; DestPort = 7; TargetIP = null; ReadyToRun = false; TargetResolveResult = ""; TargetPingResult = ""; GoCommand = new GoCommand(() => { if (IsRunning) { _flooder.Stop(); } else { _flooder.Start(); } IsRunning = !IsRunning; }, true); SelectedWANFrameType = new WANFrameType("Ethernet", 26); UseWANFrameBwCalc = false; FindMaxMTU(); DoubleCollection BandwidthTicksBits = new DoubleCollection(); BandwidthTicksBits.Add(1000000); BandwidthTicksBits.Add(1536000); BandwidthTicksBits.Add(1536000 * 2); BandwidthTicksBits.Add(5000000); BandwidthTicksBits.Add(1536000 * 3); BandwidthTicksBits.Add(1536000 * 4); BandwidthTicksBits.Add(10000000); BandwidthTicksBits.Add(20000000); BandwidthTicksBits.Add(50000000); BandwidthTicksBits.Add(100000000); BandwidthTicksBits.Add(200000000); BandwidthTicksBits.Add(500000000); BandwidthTicksBits.Add(1000000000); /* The below math formula causes the following to happen on the slider control: * From 0 to 1 megabit/sec (1000000 bits/sec), the scale is linear. * From 1 megabit/sec to 1 gigabit/sec, the scale is logarithmic. * The formula first converts the above numbers from bits/sec to octets/sec. * Then it takes the Log base 10 of that octets/sec number. * Finally, it aligns the start of the log scale with the linear scale, by subtracting Log base 10 of 1 megabit/sec (125,000 octets/sec), minus 1. */ BandwidthTicks = new DoubleCollection(BandwidthTicksBits.Select(x => { return(Math.Log10(x / 8) - (Math.Log10(125000) - 1)); })); PacketSizeTicks = new DoubleCollection(); PacketSizeTicks.Add(64); PacketSizeTicks.Add(576); PacketSizeTicks.Add(1250); PacketSizeTicks.Add(1500); PacketSizeTicks.Add(9000); }