Esempio n. 1
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="graph">图元画板</param>
 public GRect(MagicGraphic graph)
     : base(graph, new DrawingVisual())
 {
     this.thick = 1;
     this.slope = 0;
     this.color = Colors.Red;
     this.style = GLinear.SOLID;
     this.stuff = Colors.Transparent;
 }
Esempio n. 2
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="graph">图元画板</param>
 public GPoly(MagicGraphic graph)
     : base(graph, new DrawingVisual())
 {
     this.thick = 1;
     this.color = Colors.Red;
     this.style = GLinear.SOLID;
     this.stuff = Colors.Transparent;
     this.route = new List <GPoint>();
 }
Esempio n. 3
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="graph">图元画板</param>
 public GLine(MagicGraphic graph)
     : base(graph, new DrawingVisual())
 {
     this.thick = 1;
     this.arrow = false;
     this.color = Colors.Red;
     this.style = GLinear.SOLID;
     this.route = new List <GPoint>();
 }
Esempio n. 4
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public AShape(MagicGraphic graph, DrawingVisual brush)
 {
     this.alpha = 100;
     this.title = null;
     this.matte = false;
     this.mount = false;
     this.brush = brush;
     this.graph = graph;
     this.ident = graph.Index;
     {
         this.brush.SetValue(MagicGraphic.Nexus, this);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="graph">图元画板</param>
 public GText(MagicGraphic graph)
     : base(graph, new DrawingVisual())
 {
 }
Esempio n. 6
0
 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;
     }
 }
Esempio n. 7
0
 /// <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;
                                         }
                                     }
                                 }
                             }));
                         }
                     }
                 }
             }
         });
     }
 }
Esempio n. 8
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="graph">图元画板</param>
 public GIcon(MagicGraphic graph)
     : base(graph, new DrawingVisual())
 {
     this.slope = 0;
 }