private void ButtonOK_Click(object sender, RoutedEventArgs e) { int mptimeOut, mppacketSize, mpttl, mppacketNum, mpsendInterval; if (!int.TryParse(timeOut.Text, out mptimeOut) || mptimeOut <= 0) { MessageBox.Show("超时时间必须是正整数"); return; } if (!int.TryParse(packetSize.Text, out mppacketSize) || mppacketSize < 0) // || mppacketSize > 1472 { MessageBox.Show("包大小输入不正确"); return; } if (!int.TryParse(ttl.Text, out mpttl) || mpttl <= 0) { MessageBox.Show("TTL值输入不正确"); return; } if (!int.TryParse(packetNum.Text, out mppacketNum) || mppacketNum < 0) { MessageBox.Show("包数量输入不正确"); return; } if (!int.TryParse(sendInterval.Text, out mpsendInterval) || mpsendInterval <= 0) { MessageBox.Show("发送间隔输入不正确"); return; } //更新保存用户设置 Properties.Settings.Default["MPTimeOut"] = mptimeOut; Properties.Settings.Default["MPDataSize"] = mppacketSize; Properties.Settings.Default["MPTTL"] = mpttl; Properties.Settings.Default["MPNumber"] = mppacketNum; Properties.Settings.Default["MPInterval"] = mpsendInterval; Properties.Settings.Default["MPIsAlarm"] = isShowOpenFile.IsChecked; if ((bool)isShowOpenFile.IsChecked) { Properties.Settings.Default["MPAlarmFileUrl"] = openFileUrl.Text; } Properties.Settings.Default.Save(); //更新主页面的属性以及每个ping对象的参数 MultiPing multiPing = (MultiPing)this.Owner; multiPing.IsAlarm = (bool)isShowOpenFile.IsChecked; multiPing.alarmPlayer.SoundLocation = openFileUrl.Text; foreach (PingTarget pt in multiPing.pingTargetList1) { pt.TimeOut = mptimeOut; pt.DataSize = mppacketSize; pt.TTL = mpttl; pt.Number = mppacketNum; pt.Interval = mpsendInterval; } this.Close(); }
void BottomButton_OnClick(object sender, RoutedEventArgs e) { OldUCInCanvas = ucInCanvas; Button btn = sender as Button; int btnIndex = Grid.GetColumn(btn); if (btnIndex == btnClickedOldIndex) { return; } string btnContent = btn.Content.ToString(); if (btnContent.Equals(this.FindResource("topo").ToString())) { ucInCanvas = new TopoStart(); } else if (btnContent.Equals(this.FindResource("trap").ToString())) { } else if (btnContent.Equals(this.FindResource("portMonitor").ToString())) { ucInCanvas = new PortMonitorStart(); } else if (btnContent.Equals(this.FindResource("fiberPowerMonitor").ToString())) { } else if (btnContent.Equals(this.FindResource("peerMap").ToString())) { ucInCanvas = new PeerMapStart(); } else if (btnContent.Equals(this.FindResource("multiPing").ToString())) { // Process p = new Process(); // p.StartInfo.UseShellExecute = false; // // You can start any process, HelloWorld is a do-nothing example. // p.StartInfo.FileName = "MultiPing/MultiPing.exe"; // p.Start(); // ucInCanvas = new MultiPingStart(); Thread threadMultiPingPage = new Thread(delegate() { MultiPing.MultiPing MultiPingShow = new MultiPing.MultiPing(); MultiPingShow.ShowDialog(); }); threadMultiPingPage.SetApartmentState(ApartmentState.STA); threadMultiPingPage.IsBackground = true; threadMultiPingPage.Start(); } else if (btnContent.Equals(this.FindResource("multiBroadcast").ToString())) { } else if (btnContent.Equals(this.FindResource("config").ToString())) { ucInCanvas = new ConfigStart(); (ucInCanvas as ConfigStart).RefreshEvent += new ConfigStart.RefreshEventHandler(ConfigStart_RefreshEvent); } else if (btnContent.Equals(this.FindResource("help").ToString())) { ucInCanvas = new HelpStart(); } if (ucInCanvas != null && ucInCanvas != OldUCInCanvas) { ucInCanvas.Height = canvas.ActualHeight; ucInCanvas.Width = canvas.ActualWidth; Storyboard sbBtnClick = new Storyboard(); sbBtnClick.Completed += new EventHandler(sbBtnClick_Completed); DoubleAnimation daXOld = new DoubleAnimation(); DoubleAnimation daXNew = new DoubleAnimation(); DoubleAnimation daOpacityOld = new DoubleAnimation(); daXOld.Duration = daXNew.Duration = daOpacityOld.Duration = new Duration(TimeSpan.FromSeconds(0.5)); daOpacityOld.From = 1d; daOpacityOld.To = 0d; Storyboard.SetTarget(daOpacityOld, OldUCInCanvas); Storyboard.SetTargetProperty(daOpacityOld, new PropertyPath("Opacity")); sbBtnClick.Children.Add(daOpacityOld); if (btnClickedOldIndex < btnIndex) { //老的向左滑动,新的从右边进来 daXOld.From = 0d; daXOld.To = -1100d; daXNew.From = 1080d; daXNew.To = 0d; } else { //老的向右滑动,新的从左边进来 daXOld.From = 0d; daXOld.To = 1100d; daXNew.From = -1080d; daXNew.To = 0d; } //daXOld.DecelerationRatio = 0.5d; Storyboard.SetTarget(daXOld, OldUCInCanvas); Storyboard.SetTargetProperty(daXOld, new PropertyPath("(Canvas.Left)")); sbBtnClick.Children.Add(daXOld); //daXNew.BeginTime = TimeSpan.FromSeconds(25d); 当设置这个之后,老的原位置有拖影 // BounceEase be = new BounceEase(); // be.EasingMode = EasingMode.EaseOut; // be.Bounciness = 5; // be.Bounces = 10; // daXNew.EasingFunction = be; // ElasticEase ee = new ElasticEase(); // ee.Oscillations = 2; // ee.Springiness = 3; // ee.EasingMode = EasingMode.EaseOut; // daXNew.EasingFunction = ee; Storyboard.SetTarget(daXNew, ucInCanvas); Storyboard.SetTargetProperty(daXNew, new PropertyPath("(Canvas.Left)")); sbBtnClick.Children.Add(daXNew); canvas.Children.Add(ucInCanvas); btnClickedOldIndex = btnIndex; sbBtnClick.Begin(); } }