日期:2014-05-20 浏览次数:20989 次
private void Turn(int[] allPorts, int[] turnOffPorts, TurnTo turnTo) { bool to = turnTo == TurnTo.On ? true : false; foreach (int i in turnOffPorts) { this.Panels[i].Visible = to; } IEnumerable<int> turnOnPorts = allPorts.Except(turnOffPorts); foreach(int i in turnOnPorts) { this.Panels[i].Visible = !to; } }
public class NumberFactory { private static Dictionary<int, NumberRule> portsRule; public static Dictionary<int, NumberRule> PortsRule { get { if (portsRule == null) { portsRule = new Dictionary<int, NumberRule>(); portsRule.Add(0, new NumberRule { Ports = new int[]{ 4 }, TrunTo = TurnTo.Off, Source = 0 }); portsRule.Add(1, new NumberRule { Ports = new int[] { 3,6 }, TrunTo = TurnTo.On, Source = 1 }); portsRule.Add(2, new NumberRule { Ports = new int[] { 2,6 }, TrunTo = TurnTo.Off, Source = 2 }); portsRule.Add(3, new NumberRule { Ports = new int[] { 2,5 }, TrunTo = TurnTo.Off, Source = 3 }); portsRule.Add(4, new NumberRule { Ports = new int[] { 1,5,7 }, TrunTo = TurnTo.Off, Source = 4 }); portsRule.Add(5, new NumberRule { Ports = new int[] { 3,5 }, TrunTo = TurnTo.Off, Source = 5 }); portsRule.Add(6, new NumberRule { Ports = new int[] { 3 }, TrunTo = TurnTo.Off, Source = 6 }); portsRule.Add(7, new NumberRule { Ports = new int[] { 1,3,6 }, TrunTo = TurnTo.On, Source = 7 }); portsRule.Add(8, new NumberRule { Ports = new int[] { }, TrunTo = TurnTo.Off, Source = 8 }); portsRule.Add(9, new NumberRule { Ports = new int[] { 5 }, TrunTo = TurnTo.Off, Source = 9 }); } return portsRule; } } }