public override object Clone() { var obj = new G_Cable() { Position = Position }; obj.OldPath.AddRange(OldPath); obj.Path.AddRange(Path); return(obj); }
private void G_Pin_OnMouseDownEvent(Vector2 arg1, MouseButtons arg2) { if (arg2 == MouseButtons.Right && Pointed) { if (!ContentView.Running) { if (ContentView.BeingPlaced == null) { if (!ContentView.Cutting) { ContentView.Cutting = true; ContentView.Wiring = false; ContentView.CurrentP1 = this; } else { ContentView.Cutting = false; if (!Equals(ContentView.CurrentP1)) { IEnumerable <G_Cable> cbs; if ((cbs = ContentView.Cables.Where(c => (c.P1.Equals(ContentView.CurrentP1) && c.P2.Equals(this)) || (c.P1.Equals(this) && c.P2.Equals(ContentView.CurrentP1)))).Count() > 0) //实际上只可能有0、1的取值 { ContentView.Cables.Remove(cbs.ElementAt(0)); } } } } } } else if (arg2 == MouseButtons.Left && Pointed) { if (!ContentView.Running) { if (ContentView.BeingPlaced == null) { if (!ContentView.Wiring) { if (ContentView.Cutting) { ContentView.Cutting = false; foreach (var t in ContentView.Cables.Where(t => t.P1.Equals(ContentView.CurrentP1) || t.P2.Equals(ContentView.CurrentP1))) { t.Signed = false; } ContentView.CurrentP1 = null; } else { List <G_Pin> pps = new List <G_Pin>(); var ps = ContentView.Components.ToArray().Select(c => { return(c.Pins); }); foreach (var p in ps) { foreach (var pp in p) { if (pp.Pointed && !pp.Equals(this)) { pps.Add(pp); } } } if (pps.Count == 0) //因为一些逻辑实现起来很麻烦,干脆多个点相叠时不允许连线 { ContentView.Cutting = false; ContentView.Wiring = true; ContentView.CurrentP1 = this; } } } else { ContentView.Wiring = false; if (!Equals(ContentView.CurrentP1)) { if (ContentView.Cables.Where(c => (c.P1.Equals(ContentView.CurrentP1) && c.P2.Equals(this)) || (c.P1.Equals(this) && c.P2.Equals(ContentView.CurrentP1))).Count() == 0) { var cb = new G_Cable { P1 = ContentView.CurrentP1, P2 = this }; cb.Path.Clear(); cb.Path.AddRange(ContentView.CurrentCablePoints); ContentView.Cables.Add(cb); } } ContentView.CurrentCablePoints.Clear(); } } } } }