/// <summary> /// 鼠标坐标转像素坐标 /// </summary> /// <param name="cur">鼠标坐标</param> /// <returns>像素坐标</returns> public sealed override Pixel Cur2px(Pixel cur) { if (MatchUtils.IsEmpty(cur)) { return(null); } else { Pixel cur2px = this.Crd2px(this.Target.Center); try { return(!MatchUtils.IsEmpty(cur2px) ? new Pixel( cur.X + cur2px.X - this.Target.Screen.L - this.Target.Screen.X, cur.Y + cur2px.Y - this.Target.Screen.T - this.Target.Screen.Y ) : null); } catch { return(null); } } }
/// <summary> /// 移除地标 /// </summary> public sealed override void Remove() { if (!MatchUtils.IsEmpty(this.Target) && this.Target.Enable && this.Enable) { if (this.Obscure(this.Target.Listen.DragEvent, this.Redraw)) { if (!this.Obscure(this.Target.Listen.ZoomEvent, this.Redraw)) { this.Observe(this.Target.Listen.DragEvent, this.Redraw); } else { if (!this.Obscure(this.Target.Listen.SwapEvent, this.Redraw)) { this.Observe(this.Target.Listen.DragEvent, this.Redraw); this.Observe(this.Target.Listen.ZoomEvent, this.Redraw); } else { if (!this.Target.Symbol.Mark.Remove(this.Index)) { this.Observe(this.Target.Listen.DragEvent, this.Redraw); this.Observe(this.Target.Listen.ZoomEvent, this.Redraw); this.Observe(this.Target.Listen.SwapEvent, this.Redraw); } else { this.Target.Vessel.Mark.Children.Remove(this.handle); { this.Facade = null; this.handle = null; this.Target = null; } } } } } } }
/// <summary> /// 点集合地理坐标转化为Canvas坐标 /// </summary> /// <param name="way"></param> /// <returns></returns> protected List <GPoint> Fit4r(List <Coord> way) { List <GPoint> fit = new List <GPoint>(); // 坐标转换 { if (!MatchUtils.IsEmpty(way)) { GPoint point = null; { foreach (Coord crd in way) { if (!MatchUtils.IsEmpty(point = this.Fit4p(crd))) { fit.Add(point); } } } } } return(fit); }
/// <summary> /// 强制绘制 /// </summary> /// <param name="obj"></param> /// <param name="evt"></param> private void Paint(object obj, EventArgs evt) { if (this.make) { this.make = false; { if (Visibility.Visible.Equals(this.Visibility)) { Pixel pixel = null; try { pixel = this.mark.Target.Netmap.Crd2px(this.mark.Point); } catch (NullReferenceException) { pixel = null; } finally { if (MatchUtils.IsEmpty(pixel)) { this.Visibility = Visibility.Collapsed; } else { double devX = !MatchUtils.IsEmpty(this.mark.Calib) ? this.mark.Calib.X : 0, devY = !MatchUtils.IsEmpty(this.mark.Calib) ? this.mark.Calib.Y : 0, wide = (this.MarkGrid.ActualWidth - this.MarkImage.ActualWidth) * 0.5, high = this.MarkGrid.ActualHeight - this.MarkImage.ActualHeight - ( !MatchUtils.IsEmpty(this.mark.Frame) ? this.mark.Frame.Thick : 0 ); // 调整位置 { Canvas.SetTop(this, Math.Round(pixel.Y - this.mark.Target.Netmap.Nature.Y - devY - high)); Canvas.SetLeft(this, Math.Round(pixel.X - this.mark.Target.Netmap.Nature.X - devX - wide)); } } } } } } }
/// <summary> /// 执行创建线程,执行结束清除 /// </summary> /// <param name="thread">线程</param> /// <param name="reactor">线程取消管理</param> public void Attach(MagicThread thread, CancellationTokenSource reactor) { if (!this.IsDestroy && !reactor.IsCancellationRequested) { // 加入线程集合 lock (this.taskLibrary) { if (this.taskLibrary.ContainsKey(thread.Key)) { { thread.Reactor = null; } return; } else { { thread.Reactor = reactor; } this.taskLibrary.Add(thread.Key, thread); } } // 启动线程 if (!MatchUtils.IsEmpty(thread.Reactor)) { (this.taskFactory.StartNew(thread.Fun, reactor.Token, thread.Policy != TaskCreationOptions.PreferFairness ? thread.Policy : this.taskOptions, this.taskProvide)).ContinueWith((task) => { // 线程执行完在集合中删除 lock (this.taskLibrary) { if (this.taskLibrary.ContainsKey(thread.Key)) { this.taskLibrary.Remove(thread.Key); } } }); } } }
/// <summary> /// 控件重绘函数 /// </summary> public sealed override void Redraw() { if (!MatchUtils.IsEmpty(this.Target) && this.Target.Enable && this.Enable) { if (MatchUtils.IsEmpty(this.Handle)) { this.Target.Canvas.Children.Add( this.Handle = new Misc.View.Plug.Scale(this, 50) ); } // 绘制图形 WMaper.Misc.View.Plug.Scale v_scale = this.Handle as WMaper.Misc.View.Plug.Scale; { v_scale.Dispatcher.BeginInvoke(new Action(() => { if (!MatchUtils.IsEmpty(this.Handle)) { v_scale.Build(); } })); } } }
private void Dimen(Bound bnd, Nature geo) { if (!MatchUtils.IsEmpty(bnd.Min) && !MatchUtils.IsEmpty(bnd.Max)) { double deg = 0.0; try { deg = this.Factor[this.Level]; } catch { deg = 0.0; } finally { if (deg > 0) { geo.W = Math.Floor((bnd.Max.Lng - bnd.Min.Lng) / deg / this.block.Wide) * this.block.Wide; geo.H = Math.Floor((bnd.Min.Lat - bnd.Max.Lat) / deg / this.block.High) * this.block.High; } } } }
/// <summary> /// 控件重绘函数 /// </summary> /// <param name="msg"></param> public sealed override void Redraw(Msger msg) { if (!MatchUtils.IsEmpty(this.Target) && 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.ZoomEvent.Equals(msg.Chan) || this.Target.Listen.SwapEvent.Equals(msg.Chan)) { if (!this.simple) { this.Redraw(); } } } } } }
/// <summary> /// GenreBoxGrid进入事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GenreBoxGrid_MouseEnter(object sender, MouseEventArgs e) { if (!MatchUtils.IsEmpty(this.genre.Target) && this.genre.Target.Enable && this.genre.Enable) { this.GenreBoxGrid.Visibility = Visibility.Visible; { switch ((string)this.GenreBoxGrid.Tag) { case "MAP": { this.GenreMap.Source = this.FindResource("left".Equals(this.genre.Anchor) ? "GENRE_03" : "GENRE_02") as ImageSource; break; } case "LAP": { this.GenreLap.Source = this.FindResource("left".Equals(this.genre.Anchor) ? "GENRE_06" : "GENRE_05") as ImageSource; break; } } } } }
public void Dispose() { if (!MatchUtils.IsEmpty(this.dragEvent)) { this.dragEvent.Dispose(); { this.dragEvent = null; } } if (!MatchUtils.IsEmpty(this.zoomEvent)) { this.zoomEvent.Dispose(); { this.zoomEvent = null; } } if (!MatchUtils.IsEmpty(this.swapEvent)) { this.swapEvent.Dispose(); { this.swapEvent = null; } } }
/// <summary> /// 强制绘制 /// </summary> /// <param name="obj"></param> /// <param name="evt"></param> private void Paint(object obj, EventArgs evt) { if (this.make) { this.make = false; { if (Visibility.Visible.Equals(this.Visibility)) { Pixel pixel = this.tips.Target.Netmap.Crd2px(this.tips.Point); try { pixel = this.tips.Target.Netmap.Crd2px(this.tips.Point); } catch (NullReferenceException) { pixel = null; } finally { if (MatchUtils.IsEmpty(pixel)) { this.Visibility = Visibility.Collapsed; } else { double devX = !MatchUtils.IsEmpty(this.tips.Drift) ? this.tips.Drift.X : 0, devY = !MatchUtils.IsEmpty(this.tips.Drift) ? this.tips.Drift.Y : 0; { Canvas.SetTop(this, Math.Round(devY + pixel.Y - this.tips.Target.Netmap.Nature.Y - this.TipsGrid.ActualHeight)); Canvas.SetLeft(this, Math.Round(devX + pixel.X - this.tips.Target.Netmap.Nature.X - this.TipsGrid.ActualWidth * 0.5)); } } } } } } }
/// <summary> /// 获取图像数据 /// </summary> public void DownLoad() { if (!this.token.IsCancellationRequested) { if (this.cache.IsExist(this.path)) { Object[] result = { ImageUtils.Format(this.cache.Fetch(this.path) as byte[]) }; if (MatchUtils.IsEmpty(this.expect)) { this.action.DynamicInvoke(result); } else { this.action.DynamicInvoke(result.Concat(this.expect).ToArray()); } } else { using (WebClient http = new WebClient()) { http.Headers.Set("User-Agent", "Windows NT"); { this.token.Register(() => { this.thread.Attach(new MagicThread(StampUtils.GetSequence(), http.CancelAsync)); }); // 注册回调 { http.DownloadDataCompleted += new DownloadDataCompletedEventHandler(this.WebClient_DownLoadDataCompleted); } http.DownloadDataAsync(new Uri(this.path)); } } } } }
/// <summary> /// 构建缩放控件 /// </summary> public void Build() { // 判断类型 if (this.slide.Simple) { if (!this.ready && (this.ready = true)) { this.SlideLite.Visibility = Visibility.Visible; this.SlideFull.Visibility = Visibility.Collapsed; { // 设置位置 if ("left".Equals(this.slide.Anchor)) { Canvas.SetTop(this, 18); Canvas.SetLeft(this, 18); } else { Canvas.SetTop(this, 18); Canvas.SetRight(this, 53); } } } } else { if (!this.ready && (this.ready = true)) { this.SlideFull.Visibility = Visibility.Visible; this.SlideLite.Visibility = Visibility.Collapsed; { // 设置位置 if ("left".Equals(this.slide.Anchor)) { Canvas.SetTop(this, 18); Canvas.SetLeft(this, 18); } else { Canvas.SetTop(this, 18); Canvas.SetRight(this, 66); } } } // 绘制层级 if (!MatchUtils.IsEmpty(this.slide.Target) && !MatchUtils.IsEmpty(this.slide.Target.Netmap) && !MatchUtils.IsEmpty(this.slide.Target.Netmap.Factor)) { int level = this.slide.Target.Netmap.Level, count = this.slide.Target.Netmap.Factor.Length, range = count - level; { this.SlideFullBar.Height = (count + 1) * 7 - 1; // 滑块位置 Canvas.SetTop(this.SlideFullMask, range * 7 - 1); Canvas.SetTop(this.SlideFullCtrl, range * 7 - 4); } } else { this.SlideFullBar.Height = 0; // 滑块位置 Canvas.SetTop(this.SlideFullMask, 0); Canvas.SetTop(this.SlideFullCtrl, 0); } } }
/// <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 void Dispose() { if (!MatchUtils.IsEmpty(this.tile)) { Geog[] a_tile = this.tile.Values.ToArray(); for (int i = a_tile.Length - 1; i > -1; i--) { try { a_tile[i].Remove(); } catch { continue; } finally { a_tile[i] = null; } } // 释放内存 this.tile.Clear(); { this.tile = null; } } if (!MatchUtils.IsEmpty(this.pile)) { Geog[] a_pile = this.pile.Values.ToArray(); for (int i = a_pile.Length - 1; i > -1; i--) { try { a_pile[i].Remove(); } catch { continue; } finally { a_pile[i] = null; } } // 释放内存 this.pile.Clear(); { this.pile = null; } } if (!MatchUtils.IsEmpty(this.note)) { Note[] a_note = this.note.Values.ToArray(); for (int i = a_note.Length - 1; i > -1; i--) { try { a_note[i].Remove(); } catch { continue; } finally { a_note[i] = null; } } // 释放内存 this.note.Clear(); { this.note = null; } } if (!MatchUtils.IsEmpty(this.draw)) { Geom[] a_draw = this.draw.Values.ToArray(); for (int i = a_draw.Length - 1; i > -1; i--) { try { a_draw[i].Remove(); } catch { continue; } finally { a_draw[i] = null; } } // 释放内存 this.draw.Clear(); { this.draw = null; } } if (!MatchUtils.IsEmpty(this.mark)) { Mark[] a_mark = this.mark.Values.ToArray(); for (int i = a_mark.Length - 1; i > -1; i--) { try { a_mark[i].Remove(); } catch { continue; } finally { a_mark[i] = null; } } // 释放内存 this.mark.Clear(); { this.mark = null; } } if (!MatchUtils.IsEmpty(this.tips)) { Tips[] a_tips = this.tips.Values.ToArray(); for (int i = a_tips.Length - 1; i > -1; i--) { try { a_tips[i].Remove(); } catch { continue; } finally { a_tips[i] = null; } } // 释放内存 this.tips.Clear(); { this.tips = null; } } }
/// <summary> /// 鼠标移动事件处理函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnMouseMoveEventListener(object sender, MouseEventArgs e) { AShape shape = null; try { HitTestResult target = VisualTreeHelper.HitTest(this.canvas, e.GetPosition(this.canvas)); if (!MatchUtils.IsEmpty(target) && !MatchUtils.IsEmpty(target.VisualHit)) { shape = (target.VisualHit as DrawingVisual).GetValue(MagicGraphic.Nexus) as AShape; } } catch { shape = null; } finally { if (!MatchUtils.IsEmpty(shape)) { this.canvas.Cursor = shape.Mouse; this.canvas.ToolTip = shape.Title; try { shape.OnMouseMove(e); } finally { if (!shape.Equals(cache)) { try { if (!MatchUtils.IsEmpty(cache)) { cache.OnMouseLeave(e); } } finally { (cache = shape).OnMouseEnter(e); } } } } else { this.canvas.Cursor = null; this.canvas.ToolTip = null; try { if (!MatchUtils.IsEmpty(cache)) { cache.OnMouseLeave(e); } } finally { cache = null; } } } }
/// <summary> /// 构造函数 /// </summary> /// <param name="facade">地图面板</param> /// <param name="option">地图配置</param> public Maper(Panel facade, Option option) { if (!MatchUtils.IsEmpty(this.facade = facade) && !MatchUtils.IsEmpty(this.option = option) && ( this.enable = true )) { // 初始光标 this.facade.Cursor = (this.sharer = new Share()).FreeCur; { // 初始参数 this.ramble = this.option.Exist("Ramble") ? this.option.Fetch <bool>("Ramble") : true; this.assets = new Assets( this.option.Exist("Assets") ? this.option.Fetch <string>("Assets") : null ); } // 初始缓存 this.screen = new Screen( this.facade ); this.symbol = new Symbol(); this.widget = new Widget(); this.listen = new Listen(); { this.listen.DragEvent = new Event(this); this.listen.ZoomEvent = new Event(this); this.listen.SwapEvent = new Event(this); } // 初始尺寸 Binding wide = new Binding(); wide.Source = this.facade; wide.Mode = BindingMode.OneWay; wide.Path = new PropertyPath("ActualWidth"); Binding high = new Binding(); high.Source = this.facade; high.Mode = BindingMode.OneWay; high.Path = new PropertyPath("ActualHeight"); // 初始画布 (this.canvas = new Canvas()).Background = new SolidColorBrush(Color.FromRgb(229, 227, 223)); { // 裁切显示区 this.canvas.ClipToBounds = true; // 自适应宽度 this.canvas.SetBinding(Canvas.WidthProperty, wide); // 自适应高度 this.canvas.SetBinding(Canvas.HeightProperty, high); } // 初始地图集 this.vessel = new Atlas(10); { // 自适应宽度 this.vessel.SetBinding(UserControl.WidthProperty, wide); // 自适应高度 this.vessel.SetBinding(UserControl.HeightProperty, high); } // 实例化图层 this.canvas.Children.Add(this.vessel); this.facade.Children.Add(this.canvas); // 初始化画笔 this.sketch = new MagicGraphic(this.vessel.Draw); { // 初始化线程 this.thread = new MagicThreadFactory(); // 初始化缓存 this.memory = new MagicCache( "MaperCache_" + StampUtils.GetTimeStamp(), 300, 75, TimeSpan.Parse("00:10:00") ); } // 初始化布局 this.facade.SizeChanged += (obj, evt) => { if (!this.screen.W.Equals(this.facade.ActualWidth) || !this.screen.H.Equals(this.facade.ActualHeight)) { // 调整屏幕大小 this.screen.X = (this.screen.W = this.facade.ActualWidth) / 2; this.screen.Y = (this.screen.H = this.facade.ActualHeight) / 2; // 调整地图大小 if (!MatchUtils.IsEmpty(this.netmap)) { this.netmap.Resize(); } } }; // 初始化漫游 this.facade.MouseLeftButtonDown += new MouseButtonEventHandler(delegate(object downObj, MouseButtonEventArgs downEvt) { if (!MatchUtils.IsEmpty(this.netmap) && this.netmap.Enable && this.enable && this.ramble && ( downEvt.Handled = downEvt.ClickCount.Equals(1) )) { if (Mouse.Capture(this.facade, CaptureMode.SubTree)) { Point spoint = downEvt.GetPosition(this.facade), epoint = new Point(); { // 拖拽光标 this.facade.Cursor = this.sharer.DragCur; { MouseEventHandler mevent = null; MouseButtonEventHandler sevent = null; // 绑定事件 this.facade.MouseMove += (mevent = new MouseEventHandler(delegate(object moveObj, MouseEventArgs moveEvt) { // 捕捉光标 if (this.manual = !(MatchUtils.IsEmpty(epoint = moveEvt.GetPosition(this.facade)) || Point.Equals(spoint, epoint))) { Canvas.SetTop(this.vessel, this.netmap.Nature.T - (epoint.Y = (spoint.Y - epoint.Y))); Canvas.SetLeft(this.vessel, this.netmap.Nature.L - (epoint.X = (spoint.X - epoint.X))); } })); this.facade.MouseLeftButtonUp += (sevent = new MouseButtonEventHandler(delegate(object stopObj, MouseButtonEventArgs stopEvt) { // 恢复光标 this.facade.Cursor = this.sharer.FreeCur; { stopEvt.Handled = true; try { this.facade.MouseMove -= mevent; this.facade.MouseLeftButtonUp -= sevent; } catch { } finally { // 释放光标 Mouse.Capture(this.facade, CaptureMode.None); try { if (!MatchUtils.IsEmpty(this.center) && this.manual) { this.Netmap.Moveto(this.netmap.Crd2px(this.center).Offset(new Pixel(epoint.X, epoint.Y))); } } catch { } finally { this.manual = false; { spoint.X = 0; spoint.Y = 0; epoint.X = 0; epoint.Y = 0; } mevent = null; sevent = 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)) { // 回调长度 try { fun.Invoke(0.0); } catch (Exception e) { throw e; } finally { fun = null; } } }
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)) { GRect v_rect = this.Handle as GRect; { v_rect.Mouse = this.Mouse; v_rect.Title = this.Title; v_rect.Alpha = this.Alpha; v_rect.Color = this.color; v_rect.Thick = this.thick; v_rect.Style = this.style; v_rect.Stuff = this.stuff; v_rect.Slope = this.slope; v_rect.Extra = this.Fit4e(this.extra); v_rect.Point = this.Fit4p(this.point); } } // 重绘图形 this.Facade.Dispatcher.BeginInvoke(new Action(() => { if (!MatchUtils.IsEmpty(this.Handle)) { this.Handle.Paint(); } })); } else { if (!((this.Handle = this.Target.Sketch.CreateRect()).Matte = hide)) { GRect v_rect = this.Handle as GRect; { v_rect.Mouse = this.Mouse; v_rect.Title = this.Title; v_rect.Alpha = this.Alpha; v_rect.Color = this.color; v_rect.Thick = this.thick; v_rect.Style = this.style; v_rect.Stuff = this.stuff; v_rect.Slope = this.slope; v_rect.Extra = this.Fit4e(this.extra); v_rect.Point = this.Fit4p(this.point); } // 绘制图形 this.Facade.Dispatcher.BeginInvoke(new Action(() => { if (!MatchUtils.IsEmpty(this.Handle)) { v_rect.Paint(); } })); } } } } }
public bool Compare(Maper drv, Coord crd) { return(!MatchUtils.IsEmpty(drv) && !MatchUtils.IsEmpty(drv.Netmap) ? this.Compare(drv, drv.Netmap.Crd2px(crd)) : false); }
public Rect(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("Slope")) { this.Slope = option.Fetch <double>("Slope"); } if (option.Exist("Arise")) { this.Arise = option.Fetch <Arise>("Arise"); } if (option.Exist("Stuff")) { this.Stuff = option.Fetch <Color>("Stuff"); } if (option.Exist("Color")) { this.Color = option.Fetch <Color>("Color"); } if (option.Exist("Extra")) { this.Extra = option.Fetch <GExtra>("Extra"); } if (option.Exist("Point")) { this.Point = option.Fetch <Coord>("Point"); } if (option.Exist("Style")) { this.Style = option.Fetch <GLinear>("Style"); } } }
public double Distance(Maper drv, Coord crd) { return(!MatchUtils.IsEmpty(drv) && !MatchUtils.IsEmpty(drv.Netmap) ? this.Distance(drv, drv.Netmap.Crd2px(crd)) : 0.0); }
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(); } })); } } } } }
public double Distance(Maper drv, Pixel pel) { return(!MatchUtils.IsEmpty(drv) && !MatchUtils.IsEmpty(drv.Netmap) ? System.Math.Sqrt(System.Math.Pow(this.x - pel.x, 2) + System.Math.Pow(this.y - pel.y, 2)) / drv.Netmap.Craft * drv.Netmap.Deg2sc() * 0.0254 : 0.0); }
/// <summary> /// 是否相交 /// </summary> /// <param name="crd"></param> /// <param name="fun"></param> public void Within(Coord crd, Action <bool> fun) { if (!MatchUtils.IsEmpty(this.Target) && !MatchUtils.IsEmpty(this.Handle) && !MatchUtils.IsEmpty(fun) && !MatchUtils.IsEmpty(crd)) { // 回调相交 try { fun.Invoke(false); } catch (Exception e) { throw e; } finally { fun = null; } } }
/// <summary> /// 构造函数 /// </summary> /// <param name="option"></param> public Tips(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("Alpha")) { this.Alpha = option.Fetch <int>("Alpha"); } if (option.Exist("Arise")) { this.Arise = option.Fetch <Arise>("Arise"); } if (option.Exist("Color")) { this.Color = option.Fetch <Color>("Color"); } if (option.Exist("Gauge")) { this.Gauge = option.Fetch <Gauge>("Gauge"); } if (option.Exist("Drift")) { this.Drift = option.Fetch <Drift>("Drift"); } if (option.Exist("Point")) { this.Point = option.Fetch <Coord>("Point"); } if (option.Exist("Quote")) { this.Quote = option.Fetch <Object>("Quote"); } if (option.Exist("Scrap")) { this.Scrap = option.Fetch <Action>("Scrap"); } if (option.Exist("Fonts")) { this.Fonts = option.Fetch <WMaper.Meta.Fonts>("Fonts"); } } }
public void Dispose() { if (!MatchUtils.IsEmpty(this.thread)) { this.thread.Destroy(); { this.thread = null; } } if (!MatchUtils.IsEmpty(this.widget)) { this.widget.Dispose(); { this.widget = null; } } if (!MatchUtils.IsEmpty(this.symbol)) { this.symbol.Dispose(); { this.symbol = null; } } if (!MatchUtils.IsEmpty(this.listen)) { this.listen.Dispose(); { this.listen = null; } } if (!MatchUtils.IsEmpty(this.vessel)) { this.vessel.Dispose(); { this.vessel = null; } } if (!MatchUtils.IsEmpty(this.option)) { this.option.Clear(); { this.option = null; } } if (!MatchUtils.IsEmpty(this.sharer)) { this.sharer.Dispose(); { this.sharer = null; } } if (!MatchUtils.IsEmpty(this.canvas)) { this.canvas.Children.Clear(); { this.canvas = null; } } if (!MatchUtils.IsEmpty(this.facade)) { this.facade.Children.Clear(); { this.facade = null; } } // 内存释放 { this.assets = null; this.screen = null; this.center = null; this.sketch = null; this.netmap = null; } }
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)) { GText v_text = this.Handle as GText; { } } // 重绘图形 this.Facade.Dispatcher.BeginInvoke(new Action(() => { if (!MatchUtils.IsEmpty(this.Handle)) { this.Handle.Paint(); } })); } else { if (!((this.Handle = this.Target.Sketch.CreateText()).Matte = hide)) { GText v_text = this.Handle as GText; { } // 绘制图形 this.Facade.Dispatcher.BeginInvoke(new Action(() => { if (!MatchUtils.IsEmpty(this.Handle)) { v_text.Paint(); } })); } } } } }
/// <summary> /// 清空舞台 /// </summary> public void ClearStage() { // 几何对象 AShape shape = null; // 图形对象 DrawingVisual brush = null; for (int i = this.panel.AmountVisual() - 1; i > -1; i--) { if (!MatchUtils.IsEmpty(brush = this.panel.ObtainVisual(i) as DrawingVisual) && !MatchUtils.IsEmpty(shape = brush.GetValue(MagicGraphic.Nexus) as AShape)) { shape.Earse(); { shape = null; brush = null; } } } }
/// <summary> /// 构建控件 /// </summary> public void Build() { // 清空控件 this.ToolsImg.Source = null; { this.ToolsList.Items.Clear(); } // 重绘控件 Tool[] toolsData = null; try { lock (this.tools.Action) { toolsData = this.tools.Action.Where(x => x.Allow).ToArray(); } } catch { toolsData = null; } finally { if (!MatchUtils.IsEmpty(toolsData)) { ListBoxItem toolsItem = null; { for (int i = 0, l = toolsData.Length; i < l; i++) { (toolsItem = new ListBoxItem()).Style = this.FindResource( this.tools.Active == i ? "TOOLS_LIST_SEL" : "TOOLS_LIST_DEF" ) as Style; { toolsItem.DataContext = toolsData[i]; } // 添加数据 this.ToolsList.Items.Add(toolsItem); } } } } // 激活控件 if (!this.ready) { // 设置位置 if ("left".Equals(this.tools.Anchor)) { this.ToolsList.Style = this.FindResource("TOOLS_LIST_LEFT") as Style; { Canvas.SetTop(this, 108); Canvas.SetLeft(this, 18); } } else { this.ToolsList.Style = this.FindResource("TOOLS_LIST_RIGHT") as Style; { Canvas.SetTop(this, 108); Canvas.SetRight(this, 53); } } // 初始工具 if (this.ToolsList.Items.Count > 0) { this.Apply(this.tools.Active); } } else { // 更新图标 if (this.ToolsList.Items.Count > 0) { ImageSource toolsImg = null; try { toolsImg = ((Tool)((ListBoxItem)this.ToolsList.Items.GetItemAt(this.tools.Active)).DataContext).Press; } catch { toolsImg = null; } finally { if (toolsImg != null) { this.ToolsImg.Source = toolsImg; } } } } }