/// <summary> /// Raised when the Flooder object updates one of its own properties. /// </summary> /// <param name="sender">Flooder object sending the message</param> /// <param name="e">Object containing name of the property that changed</param> void flooder_PropertyChanged(object sender, PropertyChangedEventArgs e) { Flooder f = (Flooder)sender; int L2Octets = 0; if (UseWANFrameBwCalc) { L2Octets = SelectedWANFrameType.Size; } if (e.PropertyName == "IsRunning") { if (f.IsRunning) { FlooderIsRunning = Visibility.Visible; } else { FlooderIsRunning = Visibility.Hidden; } } if (e.PropertyName == "LatestResult") { LatestResult = new FlooderResultVM(f.LatestResult, L2Octets); //ComputeImmediateResult(f.LatestResult); } if (e.PropertyName == "HistoryResult") { HistoryResult = new FlooderResultVM(f.HistoryResult, L2Octets); //ComputeHistoricalResult(f.HistoryResult); } }
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); }