public void Repeal(Tool tool) { if (!MatchUtils.IsEmpty(this.Target) && this.Target.Enable && this.Enable) { if (!MatchUtils.IsEmpty(this.action) && !MatchUtils.IsEmpty(tool) && this.action.Contains(tool)) { if (!tool.Allow) { lock (this.action) { this.action.Remove(tool); } } else { lock (this.action) { this.active -= ( Array.IndexOf(this.action.Where(x => x.Allow).ToArray(), tool) > this.active ? ( this.action.Remove(tool) ? 0 : 0 ) : ( this.action.Remove(tool) ? 1 : 0 ) ); } // 重绘控件 this.Redraw(); } } } }
/// <summary> /// 获取面积 /// </summary> /// <param name="fun"></param> public void Square(Action <double> fun) { if (!MatchUtils.IsEmpty(this.Target) && !MatchUtils.IsEmpty(this.Handle) && !MatchUtils.IsEmpty(fun)) { double sqr = 0.0; { List <GPoint> fit4r = this.Fit4r(this.route); for (int i = 0, l = fit4r.Count - 1; i < l; i++) { if (l == i + 1) { sqr += fit4r[i].X * fit4r[0].Y - fit4r[i].Y * fit4r[0].X; } else { sqr += fit4r[i].X * fit4r[i + 1].Y - fit4r[i].Y * fit4r[i + 1].X; } } } // 回调面积 try { fun.Invoke(Math.Round(Math.Abs(0.5 * sqr * Math.Pow(this.Target.Netmap.Deg2sc() / (this.Target.Netmap.Craft * WMaper.Units.M), 2)) * 100) / 100.0); } catch (Exception e) { throw e; } finally { fun = null; } } }
public AbReport(ExecuteResult[] results, ExecuteScenario executeScenario, string scalingType) { ScalingType = scalingType; ScenarioName = executeScenario.ScenarioName; RequestCount = executeScenario.ProcessCount * executeScenario.WorkerPerProcess * executeScenario.ExecutePerWorker; Concurrency = executeScenario.WorkerPerProcess; TotalRequests = results.Length; CompleteRequests = results.Where(x => !x.HasError).Count(); FailedRequests = results.Where(x => x.HasError).Count(); // Time to complete all requests. // * Get sum of IWorkerReciever.Execute time on each workerId, max execution time will be actual execution time. TimeTaken = results.GroupBy(x => x.WorkerId).Select(xs => xs.Sum(x => x.Elapsed.TotalSeconds)).Max(); // The average time spent per request. The first value is calculated with the formula `concurrency * timetaken * 1000 / done` while the second value is calculated with the formula `timetaken * 1000 / done` TimePerRequest = TimeTaken * 1000 / RequestCount; // percentile requires sort before calculate var sortedResultsElapsedMs = results.Select(x => x.Elapsed.TotalMilliseconds).OrderBy(x => x).ToArray(); var percecs = new[] { 0.5, 0.66, 0.75, 0.80, 0.90, 0.95, 0.98, 0.99, 1.00 }; Percentiles = percecs.Select((x, i) => { var percent = (int)(x * 100); var value = (int)MatchUtils.Percentile(sortedResultsElapsedMs, x); return(i != percecs.Length - 1 ? new PercentileData(percent, value, null) : new PercentileData(percent, value, "(longest request)")); }) .ToArray(); }
public sealed override void Remove() { if (!MatchUtils.IsEmpty(this.Target) && this.Target.Enable && this.Enable) { if (this.Obscure(this.Target.Listen.SwapEvent, this.Redraw)) { bool wipe = true; try { this.Target.Canvas.Children.Remove(this.Handle); } catch { wipe = false; } finally { if (!wipe) { this.Observe(this.Target.Listen.SwapEvent, this.Redraw, 0); } else { this.Target.Widget.Genre = null; { this.Facade = null; this.Handle = null; this.Target = null; } } } } } }
/// <summary> /// 获取周长 /// </summary> /// <param name="fun"></param> public void Length(Action <double> fun) { if (!MatchUtils.IsEmpty(this.Target) && !MatchUtils.IsEmpty(this.Handle) && !MatchUtils.IsEmpty(fun)) { double sum = 0.0; { for (int i = 0, l = this.route.Count; i < l; i++) { if (l == i + 1) { sum += this.route[i].Distance(this.Target, this.route[0]); } else { sum += this.route[i].Distance(this.Target, this.route[i + 1]); } } } // 回调长度 try { fun.Invoke(Math.Round(sum * 100) / 100.0); } catch (Exception e) { throw e; } finally { fun = null; } } }
private static string GetMatchAsString(MatchGroup match) { var sb = new StringBuilder(); MatchUtils.AppendMatchToStringBuilder(sb, match); return(sb.ToString()); }
/// <summary> /// 获取ContentPresenter /// </summary> /// <param name="obj"></param> /// <returns></returns> private DependencyVisual GenreBox_SelectionVisual <DependencyVisual>(DependencyObject obj) where DependencyVisual : DependencyObject { if (!MatchUtils.IsEmpty(obj)) { DependencyObject root = null; DependencyVisual leaf = null; { for (int i = 0, l = VisualTreeHelper.GetChildrenCount(obj); i < l; i++) { if (!MatchUtils.IsEmpty(root = VisualTreeHelper.GetChild(obj, i))) { if (root is DependencyVisual) { return((DependencyVisual)root); } else { if (!MatchUtils.IsEmpty(leaf = this.GenreBox_SelectionVisual <DependencyVisual>(root))) { return(leaf); } } } } } } return(null); }
private static void CreateMatch(Queue <Player> queue, IHostingEnvironment hostingEnvironment) { int playersAdded = 0; var match = new MatchGroup(); var accumulator = new TempAccumulator(); // 1) Add players from priority queue (if any) while (playersAdded < playersPerMatch && topPriorityQueue.Count > 0) { var player = topPriorityQueue.Dequeue(); playersAdded = AddPlayerToMatch(playersAdded, match, accumulator, player); } // 2) Add players from proper queue while (playersAdded < playersPerMatch) { var player = queue.Dequeue(); playersAdded = AddPlayerToMatch(playersAdded, match, accumulator, player); } MatchUtils.UpdateMatchStats(accumulator, match, playersAdded, currentMatchNumber); matches.Add(match); WriteMatchToFile(match, hostingEnvironment); currentMatchNumber++; }
private static int AddPlayerToMatch(int playersAdded, MatchGroup match, TempAccumulator accumulator, Player player) { MatchUtils.UpdateMatchCounters(accumulator, player); playersAdded++; match.Players.Add(player); return(playersAdded); }
/// <summary> /// 移除对象 /// </summary> public sealed override void Remove() { if (!MatchUtils.IsEmpty(this.Target) && this.Target.Enable && this.Enable && !MatchUtils.IsEmpty(this.handle)) { if (this.Obscure(this.Target.Listen.ZoomEvent, this.Redraw)) { if (!this.Obscure(this.Target.Listen.SwapEvent, this.Redraw)) { this.Observe(this.Target.Listen.ZoomEvent, this.Redraw); } else { if (!this.Target.Symbol.Draw.Remove(this.Index)) { this.Observe(this.Target.Listen.ZoomEvent, this.Redraw); this.Observe(this.Target.Listen.SwapEvent, this.Redraw); } else { // 擦除图形 this.handle.Earse(); { this.Facade = null; this.handle = null; this.Target = null; } } } } } }
/// <summary> /// 绘制对象 /// </summary> /// <param name="msg"></param> public sealed override void Redraw(Msger msg) { if (!MatchUtils.IsEmpty(this.Target) && !MatchUtils.IsEmpty(this.Target.Netmap) && !MatchUtils.IsEmpty(this.Facade) && this.Target.Enable && this.Enable) { if (MatchUtils.IsEmpty(msg)) { this.Redraw(); } else { if (!MatchUtils.IsEmpty(this.handle)) { // Swap Event. if (this.Target.Listen.ZoomEvent.Equals(msg.Chan)) { this.Redraw(); return; } // Swap Event. if (this.Target.Listen.SwapEvent.Equals(msg.Chan)) { if (!(msg.Info as Geog).Cover) { this.Redraw(); } } } } } }
/// <summary> /// 置顶对象 /// </summary> public void Summit() { if (!MatchUtils.IsEmpty(this.Target) && !MatchUtils.IsEmpty(this.handle) && this.Target.Enable && this.Enable) { this.handle.Front(); } }
public sealed override void Remove() { if (!MatchUtils.IsEmpty(this.Target) && this.Target.Enable && this.Enable) { bool wipe = true; try { this.Target.Canvas.Children.Remove(this.Handle); } catch { wipe = false; } finally { if (wipe) { this.Target.Widget.Tools = null; { this.Facade = null; this.Handle = null; this.Target = null; } } } } }
public void Select(int tool) { if (!MatchUtils.IsEmpty(this.Target) && this.Target.Enable && this.Enable) { if (this.active != tool && tool > -1) { Tool item = null; try { item = this.action.Where(x => x.Allow).ElementAt(tool); } catch { item = null; } finally { if (item != null) { this.Select(item); } } } } }
/// <summary> /// 菜单弹出事件处理函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnContextMenuOpeningEventListener(object sender, ContextMenuEventArgs e) { if (!MatchUtils.IsEmpty(cache)) { cache.OnContextMenuOpening(e); } }
/// <summary> /// 滚动鼠标滚轮事件处理函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnMouseWheelEventListener(object sender, MouseWheelEventArgs e) { if (!MatchUtils.IsEmpty(cache)) { cache.OnMouseWheel(e); } }
/// <summary> /// 清空配置对象 /// </summary> public void Clear() { if (!MatchUtils.IsEmpty(this.config)) { this.config.Clear(); } }
public Wave(Option option) : this() { if (!MatchUtils.IsEmpty(option)) { // 用户配置 if (option.Exist("Index")) { this.Index = option.Fetch <string>("Index"); } if (option.Exist("Group")) { this.Group = option.Fetch <string>("Group"); } if (option.Exist("Title")) { this.Title = option.Fetch <string>("Title"); } if (option.Exist("Mouse")) { this.Mouse = option.Fetch <Cursor>("Mouse"); } if (option.Exist("Matte")) { this.Matte = option.Fetch <bool>("Matte"); } if (option.Exist("Amend")) { this.Amend = option.Fetch <bool>("Amend"); } if (option.Exist("Alpha")) { this.Alpha = option.Fetch <int>("Alpha"); } if (option.Exist("Thick")) { this.Thick = option.Fetch <int>("Thick"); } if (option.Exist("Arrow")) { this.Arrow = option.Fetch <bool>("Arrow"); } if (option.Exist("Arise")) { this.Arise = option.Fetch <Arise>("Arise"); } if (option.Exist("Color")) { this.Color = option.Fetch <Color>("Color"); } if (option.Exist("Style")) { this.Style = option.Fetch <GLinear>("Style"); } if (option.Exist("Route")) { this.Route = option.Fetch <List <Coord> >("Route"); } } }
/// <summary> /// 鼠标弹起事件处理函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnMouseUpEventListener(object sender, MouseButtonEventArgs e) { if (!MatchUtils.IsEmpty(cache)) { cache.OnMouseUp(e); } }
/// <summary> /// 获取面积 /// </summary> /// <param name="fun"></param> public void Square(Action <double> fun) { if (!MatchUtils.IsEmpty(this.Target) && !MatchUtils.IsEmpty(this.Handle) && !MatchUtils.IsEmpty(fun)) { // 回调面积 try { if (MatchUtils.IsEmpty(this.extra)) { fun.Invoke(0.0); } else { fun.Invoke(Math.Round(this.extra.X * this.extra.Y * 400) / 100.0); } } catch (Exception e) { throw e; } finally { fun = null; } } }
public Geoq(Option option) : this() { if (!MatchUtils.IsEmpty(option)) { // 用户配置 if (option.Exist("Index")) { this.Index = option.Fetch <string>("Index"); } if (option.Exist("Group")) { this.Group = option.Fetch <string>("Group"); } if (option.Exist("Title")) { this.Title = option.Fetch <string>("Title"); } if (option.Exist("Allow")) { this.Allow = option.Fetch <bool>("Allow"); } if (option.Exist("Cover")) { this.Cover = option.Fetch <bool>("Cover"); } if (option.Exist("Alarm")) { this.Alarm = option.Fetch <bool>("Alarm"); } if (option.Exist("Speed")) { this.Speed = option.Fetch <int>("Speed"); } if (option.Exist("Alpha")) { this.Alpha = option.Fetch <int>("Alpha"); } if (option.Exist("Level")) { this.Level = option.Fetch <int>("Level"); } if (option.Exist("Close")) { this.Close = option.Fetch <int>("Close"); } if (option.Exist("Start")) { this.Start = option.Fetch <int>("Start"); } if (option.Exist("Extent")) { this.Extent = option.Fetch <Bound>("Extent"); } if (option.Exist("Path")) { this.Path = option.Fetch <Func <String> >("Path"); } } }
private void WebClient_DownLoadDataCompleted(Object sender, DownloadDataCompletedEventArgs e) { if (!e.Cancelled) { BitmapImage result = null; { if (e.Error == null) { byte[] icon = e.Result; if (!MatchUtils.IsEmpty(icon) && this.cache.Store(this.path, icon)) { result = ImageUtils.Format(icon); } } } // 回调结果 if (MatchUtils.IsEmpty(this.expect)) { this.action.DynamicInvoke(new Object[] { result }); } else { this.action.DynamicInvoke(new Object[] { result }.Concat(this.expect).ToArray()); } } }
/// <summary> /// 重绘提示 /// </summary> /// <param name="msg"></param> public sealed override void Redraw(WMaper.Meta.Radio.Msger msg) { if (!MatchUtils.IsEmpty(this.Target) && !MatchUtils.IsEmpty(this.Target.Netmap) && this.Target.Enable && this.Enable) { if (MatchUtils.IsEmpty(msg)) { this.Redraw(); } else { if (!MatchUtils.IsEmpty(this.Facade) && !MatchUtils.IsEmpty(this.handle)) { if (this.Target.Listen.DragEvent.Equals(msg.Chan) || this.Target.Listen.ZoomEvent.Equals(msg.Chan) || ( this.Target.Listen.SwapEvent.Equals(msg.Chan) && !(msg.Info as Geog).Cover )) { this.handle.Dispatcher.BeginInvoke(new Action(() => { if (!MatchUtils.IsEmpty(this.handle)) { this.handle.Visibility = ( this.matte || !this.Viewble(this.arise, this.point) ? Visibility.Collapsed : Visibility.Visible ); { (this.handle as WMaper.Misc.View.Core.Tips).Adjust(); } } })); } } } } }
/// <summary> /// 重绘提示 /// </summary> public sealed override void Redraw() { if (!MatchUtils.IsEmpty(this.Target) && !MatchUtils.IsEmpty(this.Target.Netmap) && this.Target.Enable && this.Enable) { if (MatchUtils.IsEmpty(this.handle)) { this.Target.Vessel.Tips.Children.Add( this.handle = new Misc.View.Core.Tips(this) ); } // 绘制图形 this.handle.Dispatcher.BeginInvoke(new Action(() => { if (!MatchUtils.IsEmpty(this.handle)) { this.handle.Visibility = ( this.matte || !this.Viewble(this.arise, this.point) ? Visibility.Collapsed : Visibility.Visible ); { (this.handle as WMaper.Misc.View.Core.Tips).Build(); } } })); } }
/// <summary> /// 提示置前 /// </summary> public void Summit() { if (!MatchUtils.IsEmpty(this.Target) && !MatchUtils.IsEmpty(this.Facade) && this.Target.Enable && this.Enable) { this.Target.Vessel.Tips.Children.Add(this.handle); } }
/// <summary> /// 布局适应函数 /// </summary> public void Resize() { if (!MatchUtils.IsEmpty(this.Target.Center)) { this.Moveto(this.Target.Center, false); } }
/// <summary> /// 判断图层是否在显示范围内 /// </summary> /// <param name="arise">显示范围</param> /// <param name="point">显示坐标</param> /// <returns></returns> protected bool Viewble(Arise arise, Coord point) { if (!MatchUtils.IsEmpty(this.target) && !MatchUtils.IsEmpty(this.target.Netmap)) { bool permit = true; { if (!MatchUtils.IsEmpty(point)) { Bound bound = this.target.Viewbox(false); { permit = !MatchUtils.IsEmpty(bound) ? bound.Contain(this.target, point) : false; } } if (!MatchUtils.IsEmpty(arise) && permit) { double scale = this.target.Netmap.Deg2sc(); { permit = scale > 0 ? (arise.Min <= 0.0 || scale <= arise.Min) && (arise.Max <= 0.0 || scale >= arise.Max) : false; } } } return(permit); } return(false); }
public sealed override void Redraw() { if (!MatchUtils.IsEmpty(this.Target) && !MatchUtils.IsEmpty(this.Target.Netmap) && !MatchUtils.IsEmpty(this.Facade) && this.Target.Enable && this.Enable) { bool hide = this.Matte || !this.Viewble(this.Arise); { if (!MatchUtils.IsEmpty(this.Handle)) { if (!(this.Handle.Matte = hide)) { GWave v_wave = this.Handle as GWave; { v_wave.Mouse = this.Mouse; v_wave.Title = this.Title; v_wave.Alpha = this.Alpha; v_wave.Color = this.color; v_wave.Thick = this.thick; v_wave.Style = this.style; v_wave.Arrow = this.arrow; v_wave.Route = this.Fit4r(this.route); } } // 重绘图形 this.Facade.Dispatcher.BeginInvoke(new Action(() => { if (!MatchUtils.IsEmpty(this.Handle)) { this.Handle.Paint(); } })); } else { if (!((this.Handle = this.Target.Sketch.CreateWave()).Matte = hide)) { GWave v_wave = this.Handle as GWave; { v_wave.Mouse = this.Mouse; v_wave.Title = this.Title; v_wave.Alpha = this.Alpha; v_wave.Color = this.color; v_wave.Thick = this.thick; v_wave.Style = this.style; v_wave.Arrow = this.arrow; v_wave.Route = this.Fit4r(this.route); } // 绘制图形 this.Facade.Dispatcher.BeginInvoke(new Action(() => { if (!MatchUtils.IsEmpty(this.Handle)) { v_wave.Paint(); } })); } } } } }
private string W2arr(String w) { return(String.Join("", new string[] { w, "?SERVICE=", this.Service, "&VERSION=", this.Version, "&REQUEST=", this.Request, "&TRANSPARENT=TRUE&LAYERS=", !MatchUtils.IsEmpty(this.Layer) ? String.Join(",", this.Layer) : "", "&STYLES=", !MatchUtils.IsEmpty(this.Style) ? String.Join(",", this.Style) : "", "&WIDTH=" + this.Block.Wide, "&HEIGHT=" + this.Block.High, "&FORMAT=", this.Format, ( !MatchUtils.IsEmpty(this.Query) ? "&" + this.Q2req(this.Query) : "" ) })); }
private void SlideFullCtrl_MouseLeftButtonDown(object obj, MouseButtonEventArgs evt) { if (evt.ClickCount == 1) { if (!MatchUtils.IsEmpty(this.slide.Target) && !MatchUtils.IsEmpty(this.slide.Target.Netmap) && !MatchUtils.IsEmpty(this.slide.Target.Netmap.Factor)) { // 捕获光标 if (this.SlideFullCtrl.CaptureMouse() && (evt.Handled = true)) { int count = this.slide.Target.Netmap.Factor.Length, route = count * 7 - 4, level = -1; { Point mpoint = new Point(); MouseEventHandler mevent = null; MouseButtonEventHandler sevent = null; // 绑定事件 this.slide.Target.Facade.MouseMove += (mevent = new MouseEventHandler(delegate(object moveObj, MouseEventArgs moveEvt) { if (!MatchUtils.IsEmpty(mpoint = moveEvt.GetPosition(this.SlideFullBar)) && mpoint.Y < route && mpoint.Y > 0) { level = Convert.ToInt32(Math.Floor(mpoint.Y / 7)); // 滑块位置 { Canvas.SetTop(this.SlideFullMask, level * 7 + 6); Canvas.SetTop(this.SlideFullCtrl, level * 7 + 3); } } })); this.slide.Target.Facade.MouseLeftButtonUp += (sevent = new MouseButtonEventHandler(delegate(object stopObj, MouseButtonEventArgs stopEvt) { // 注销事件 try { this.slide.Target.Facade.MouseMove -= mevent; this.slide.Target.Facade.MouseLeftButtonUp -= sevent; } catch { } finally { // 释放光标 this.SlideFullCtrl.ReleaseMouseCapture(); { if (level > -1) { // 缩放地图 this.slide.Target.Netmap.Zoomto(count - level - 1); } } // 释放内存 mevent = null; sevent = null; } })); } } } } }