public override bool Handle (State previous, Segment prevSegment, Segment newSegment, bool left) { if (newSegment != null && !newSegment.IsPalette && newSegment.Type != ElementType.None) { if (newSegment.Type == ElementType.Coil || newSegment.Type == ElementType.NotCoil || newSegment.Type == ElementType.SetCoil || newSegment.Type == ElementType.ResetCoil) { MainClass._main.BindDefaultOutputs (); } else { MainClass._main.BindDefaultInputs (); } MainClass._main.BindExistingVariables (newSegment); MainClass._main.BindFunction (newSegment); AppController.Instance.CheckUserVariables (); if (newSegment.Variables.Any ()) { int index = 0; foreach (var v in newSegment.Variables) { MainClass._main.BindElementVariables (v.Type, v.Value, index++); } for (int i = index; i < 4; i++) { MainClass._main.BindElementVariables (VariableType.Default, string.Empty, i); } } MainClass._main.DisableProperties (); } base.Handle (previous, prevSegment, newSegment, left); return true; }
public override bool Handle (State previous, Segment prevSegment, Segment newSegment, bool left) { if (prevSegment != null && (prevSegment.Type == ElementType.Line || prevSegment.Type == ElementType.Cursor || prevSegment.Type == ElementType.Properties)) { return true; } //deny add coil not to last column. if (prevSegment != null && (prevSegment.Type == ElementType.Coil || prevSegment.Type == ElementType.NotCoil || prevSegment.Type == ElementType.SetCoil || prevSegment.Type == ElementType.ResetCoil) && newSegment != null && newSegment.Position.X < (newSegment.Surface.Width )) { return true; } if (prevSegment != null) { if (prevSegment.Type == ElementType.OffTimer || prevSegment.Type == ElementType.OnTimer || prevSegment.Type == ElementType.PulseTimer || prevSegment.Type == ElementType.CycleTimer) { if (newSegment != null && (newSegment.Position.X == newSegment.Surface.Width)) { return true; } } //disable latch on last row if (newSegment != null && (prevSegment.Type == ElementType.Latch && newSegment.Surface.Height <= newSegment.Position.Y)) { return true; } //disable latch on last column if (newSegment != null && (prevSegment.Type == ElementType.Latch && newSegment.Surface.Width <= newSegment.Position.X)) { return true; } //disable latch on last column if (newSegment != null && (prevSegment.Type == ElementType.Latch && newSegment.Position.X == 0)) { return true; } if (newSegment != null) { var bottom = newSegment.Surface.Get ().FirstOrDefault (s =>s.Position.X == newSegment.Position.X && s.Position.Y == newSegment.Position.Y + 1); //disable latch if bootom segment was not empty if (prevSegment.Type == ElementType.Latch && (bottom == null || bottom.Type != ElementType.None)) { return true; } } } if (prevSegment != null && newSegment != null && prevSegment.IsPalette && !newSegment.IsPalette) { var el = prevSegment .Primitives .FirstOrDefault (p => p.Container != null); if (el != null) { var newEl = (DrawingElement)(el.Container.Clone ()); newEl.SetupContainer (); newSegment .Surface .Add(newEl, newSegment.Position) .ConnectPower() .ConnectSiblings(); } } base.Handle (previous, prevSegment, newSegment, left); return true; }
public override bool Handle (State previous, Segment prevSegment, Segment newSegment, bool left) { base.Handle (previous, prevSegment, newSegment, left); return true; }
public virtual bool Handle (State previous, Segment prevSegment, Segment newSegment, bool left) { return true; }
public override bool Handle (State previous, Segment prevSegment, Segment newSegment, bool left) { // disable not ladder lines if (RightSegment != null && newSegment != null) { if (RightSegment.Position.X > newSegment.Position.X && RightSegment.Position.Y == newSegment.Position.Y) { return true; } if (RightSegment.Position.X == newSegment.Position.X && RightSegment.Position.Y < newSegment.Position.Y) { return true; } if (RightSegment.Position == newSegment.Position) { return true; } } if (newSegment != null && newSegment.Type == ElementType.None) { if (RightSegment == null) { if (newSegment.Position.X == 0) { // left power line var con = new Connector { Center = new Point { X = 0, Y = 0.5 }, Marker = _cfg.LeftPower, Radius = 0.03, Foregraund = new Color { Red = 1, Green = 0, Blue = 0 }, ConnectedTo = new HashSet<string> () }; newSegment.Connectors.Add(con); RightSegment = newSegment; RightMarker = _cfg.LeftPower; con.Selected = true; } } } if (newSegment != null && (!newSegment.IsPalette && newSegment.Type != ElementType.None)) { if (RightSegment == null) { RightSegment = newSegment; RightMarker = left ? AppController.Instance.SelectLeftConnector (RightSegment) : AppController.Instance.SelectRightConnector (RightSegment); } else { LeftSegment = newSegment; LeftMarker = left ? AppController.Instance.SelectLeftConnector (LeftSegment) : AppController.Instance.SelectRightConnector (LeftSegment); AppController.Instance.Surface.AddPowerLine ( new Line (RightSegment.Position, LeftSegment.Position, RightMarker, LeftMarker)); } } base.Handle (previous, prevSegment, newSegment, left); return true; }