当前位置: 首页>>代码示例>>C#>>正文


C# Switch类代码示例

本文整理汇总了C#中Switch的典型用法代码示例。如果您正苦于以下问题:C# Switch类的具体用法?C# Switch怎么用?C# Switch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Switch类属于命名空间,在下文中一共展示了Switch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            var nodeSwitch1 = new Switch();
            var node1 = new Node();
            var nodeSwitch2 = new Switch();
            var node2 = new Node();
            var andGate1 = new AndGate();
            var node3 = new Node();

            Console.WriteLine(node3.State);

            node1.SubscribeTo(nodeSwitch1);
            node2.SubscribeTo(nodeSwitch2);

            andGate1.Input1.SubscribeTo(node1);
            andGate1.Input2.SubscribeTo(node2);

            node3.SubscribeTo(andGate1);

            Console.WriteLine(node3.State);
            nodeSwitch1.SwitchStates();
            Console.WriteLine(node3.State);
            nodeSwitch2.SwitchStates();
            Console.WriteLine(node3.State);
            nodeSwitch2.SwitchStates();
            Console.WriteLine(node3.State);

            Console.ReadKey();
        }
开发者ID:timsmith339,项目名称:circuit-builder,代码行数:29,代码来源:Program.cs

示例2: IpacDriver

 public IpacDriver(Switch[] state)
 {
     _keysnif = new KeySniffer();
     _keysnif.KeyDown += new KeySniffer.KeyPress(_keysnif_KeyDown);
     _keysnif.KeyUp += new KeySniffer.KeyPress(_keysnif_KeyUp);
     _state = state;
 }
开发者ID:poodull,项目名称:PinBrain,代码行数:7,代码来源:IpacDriver.cs

示例3: CustomSwitchCell

        //public static BindableProperty nameProperty = BindableProperty.Create<CustomSwitchCell, Thickness>(d => d.Padding, default(Thickness));
        //public static BindableProperty toggleProperty = BindableProperty.Create<CustomSwitchCell, Thickness>(d => d.Padding, default(Thickness));

        public CustomSwitchCell()
        {
            var stack = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                Padding = new Thickness(30, 0, 30, 5),
                Spacing = 0
            };

            var NameLabel = new Label();
            NameLabel.HorizontalOptions = LayoutOptions.FillAndExpand;
            NameLabel.VerticalOptions = LayoutOptions.CenterAndExpand;
            NameLabel.FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label));
            NameLabel.LineBreakMode = LineBreakMode.NoWrap;
            NameLabel.TextColor = Color.Black;
            NameLabel.SetBinding(Label.TextProperty, "Name");

            stack.Children.Add(NameLabel);

            var ToggleSwitch = new Switch();
            ToggleSwitch.HorizontalOptions = LayoutOptions.End;
            ToggleSwitch.VerticalOptions = LayoutOptions.CenterAndExpand;
            ToggleSwitch.SetBinding(Switch.IsToggledProperty, "IsSelected");
            stack.Children.Add(ToggleSwitch);

            View = stack;
        }
开发者ID:patsy02,项目名称:KompetansetorgetXamarin,代码行数:30,代码来源:CustomSwitchCell.cs

示例4: RobotConsole

        /// <summary>
        /// Initialisiert die Roboter-Konsole mit den dazugehörigen LED's und Schalter.
        /// </summary>
        public RobotConsole(RunMode runMode)
        {
            if (!Constants.IsWinCE) runMode = RunMode.Virtual;

            if (runMode == RunMode.Virtual)
            {
                digitalIn = new DigitalInSim();
                digitalOut = new DigitalOutSim();

            }
            else
            {
              //  digitalIn = new DigitalInHW(Constants.IOConsoleSWITCH);
                digitalIn = new DigitalInHW(Constants.IOConsoleSWITCH);
                digitalOut = new DigitalOutHW(Constants.IOConsoleLED);
            }

            this.leds = new Led[4];
            for (int i = 0; i < this.leds.Length; i++)
            {
                leds[i] = new Led(digitalOut,(Leds)i);
            }

            this.blinkingLeds = new BlinkingLed[4];
            for (int i = 0; i < this.blinkingLeds.Length; i++)
            {
                blinkingLeds[i] = new BlinkingLed(digitalOut, (BlinkingLeds)i);
            }

            this.switches = new Switch[4];
            for (int i = 0; i < this.switches.Length; i++)
            {
                switches[i] = new Switch(digitalIn, (Switches)i);
            }
        }
开发者ID:michaelpantic,项目名称:Robot,代码行数:38,代码来源:RobotConsole.cs

示例5: HalloweenScene1

        public HalloweenScene1(IEnumerable<string> args)
        {
            hours = new OperatingHours("Hours");
            georgeStrobeLight = new StrobeDimmer("George Strobe");
            spiderLight = new StrobeColorDimmer("Spider Light");
            skullsLight = new Dimmer("Skulls");
            cobWebLight = new Dimmer("Cob Web");
            blinkyEyesLight = new Switch("Blinky Eyes");
            rgbLightRight = new StrobeColorDimmer("Light Right");
            georgeLight = new StrobeColorDimmer("George Light");
            leftSkeletonLight = new StrobeColorDimmer("Skeleton Light");
            georgeMotor = new MotorWithFeedback("George Motor");
            candyLight = new StrobeColorDimmer("Candy Light");
            spiderLift = new Switch("Slider Lift");
            smokeMachine = new Switch("Smoke Machine");
            spiderEyes = new Switch("Spider Eyes");
            pressureMat = new DigitalInput("Pressure Mat");
            testButton = new DigitalInput("Test");

            pulsatingEffect1 = new Effect.Pulsating("Pulse FX 1", S(2), 0.1, 0.4);
            pulsatingEffect2 = new Effect.Pulsating("Pulse FX 2", S(2), 0.3, 0.5);
            candyPulse = new Effect.Pulsating("Candy Pulse", S(3), 0.01, 0.1);
            flickerEffect = new Effect.Flicker("Flicker", 0.4, 0.6);

            audioPlayer = new Physical.NetworkAudioPlayer(
                Properties.Settings.Default.NetworkAudioPlayerIP,
                Properties.Settings.Default.NetworkAudioPlayerPort);
        }
开发者ID:HakanL,项目名称:animatroller,代码行数:28,代码来源:HalloweenScene1.cs

示例6: CreateInteractiveEntities

 /// <summary>
 /// Creates the bonuses, obstacles and power ups contained in a level.
 /// </summary>
 /// <param name="interactiveEntityDescriptions">A list of interactive entity descriptions.</param>
 /// <param name="physicsWorld">The physics world to create the entities in.</param>
 /// <param name="interactiveEntities">An empty list to store the interactive entities in.</param>
 /// <param name="mineCart">The mine cart entity.</param>
 /// <param name="cartSwitch">The switch entity.</param>
 /// <param name="spriteBatch">The sprite batch to use for rendering.</param>
 /// <param name="contentManager">The game's content manager.</param>
 public static void CreateInteractiveEntities(List<InteractiveEntityDescription> interactiveEntityDescriptions, ref World physicsWorld, ref List<InteractiveEntity> interactiveEntities, ref MineCart mineCart, ref Switch cartSwitch, SpriteBatch spriteBatch, ContentManager contentManager)
 {
     if (interactiveEntities.Count == 0)
     {
         foreach (InteractiveEntityDescription description in interactiveEntityDescriptions)
         {
             if (EntityConstants.PowerUpNames.Contains(description.Name))
             {
                 interactiveEntities.Add(new PowerUp(ref physicsWorld, spriteBatch, contentManager, description, EntitySettingsLoader.GetPowerUpSettings(description.Name)));
             }
             else if (EntityConstants.BonusNames.Contains(description.Name) || EntityConstants.ObstacleNames.Contains(description.Name))
             {
                 interactiveEntities.Add(new BonusOrObstacle(ref physicsWorld, spriteBatch, contentManager, description, EntitySettingsLoader.GetObstacleOrBonusSetting(description.Name)));
             }
             else if (description.Name == EntityConstants.CartBody)
             {
                 mineCart = new MineCart(spriteBatch, contentManager, ref physicsWorld, description.Position, 100.0f, 240.0f, 350.0f, 80.0f, -80.0f);
             }
             else if (description.Name == EntityConstants.Switch)
             {
                 cartSwitch = new Switch(spriteBatch, contentManager, ref physicsWorld, description.Position, mineCart);
             }
         }
     }
 }
开发者ID:K-Cully,项目名称:SticKart,代码行数:35,代码来源:LevelFactory.cs

示例7: Start

 // Use this for initialization
 void Start()
 {
     //Set state of object
     bIsUnlocked = false;
     switchKey = GameObject.FindWithTag("Switch").GetComponent<Switch>();
     switchKey2 = GameObject.FindWithTag("Switch").GetComponent<Switch>();
 }
开发者ID:ChrisC64,项目名称:SeniorProject,代码行数:8,代码来源:TwoKeyDoor.cs

示例8: SwitchDemoPage

        public SwitchDemoPage()
        {
            Label header = new Label
            {
                Text = "Switch",
                Font = Font.SystemFontOfSize(50, FontAttributes.Bold),
                HorizontalOptions = LayoutOptions.Center
            };

            Switch switcher = new Switch
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            switcher.Toggled += switcher_Toggled;

            label = new Label
            {
                Text = "Switch is now False",
                Font = Font.SystemFontOfSize(NamedSize.Large),
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            // Build the page.
            this.Content = new StackLayout
            {
                Children = 
                {
                    header,
                    switcher,
                    label
                }
            };
        }
开发者ID:nrogoff,项目名称:xamarin-forms-samples,代码行数:35,代码来源:SwitchDemoPage.cs

示例9: ControlsToData

        protected override void ControlsToData()
        {
            if (_item == null)
                _item = new Switch();
            base.ControlsToData();
            if (((Switch)_item).Interface == null)
                ((Switch)_item).Interface = new Interface();
            if (((Switch)_item).Interface.Ports == null)
                ((Switch)_item).Interface.Ports = new List<Port>();
            ((Switch)_item).Interface.Ports.Clear();
            foreach (ListViewItem lvi in lvInterface.Items)
            {
                var port = lvi.Tag as Port;
                if (port is PhysicalInterfacePortsPort)
                {
                    var p = new Port
                    {
                        direction = port.direction,
                        directionSpecified = port.directionSpecified,
                        Extension = port.Extension,
                        name = port.name,
                        type = port.type,
                        typeSpecified = port.typeSpecified
                    };
                    port = p;
                }

                ((Switch)_item).Interface.Ports.Add(port);
            }

            List<SwitchRelaySetting> srsList =
                (from ListViewItem lvi in lvSwitchRelays.Items select lvi.Tag as SwitchRelaySetting).ToList();

            ((Switch)_item).Connections = srsList;
        }
开发者ID:UtrsSoftware,项目名称:ATMLWorkBench,代码行数:35,代码来源:SwitchControl.cs

示例10: SaveToDictionaryCS

        public SaveToDictionaryCS()
        {
            var labelStyle = new Style(typeof(Label))
            {
                Setters = {
                new Setter { Property = Label.XAlignProperty, Value = TextAlignment.End },
                new Setter { Property = Label.YAlignProperty, Value = TextAlignment.Center },
                new Setter { Property = Label.WidthRequestProperty, Value = 150 }
                }
            };

            var labelName = new Label { Text = "Name:", Style = labelStyle };
            entryName = new Entry { Placeholder = "Input your name", HorizontalOptions = LayoutOptions.FillAndExpand };
            var labelBirthday = new Label { Text = "Birthday:", Style = labelStyle };
            pickerBirthday = new DatePicker { Date = new DateTime(1990, 1, 1) };
            var labelLike = new Label { Text = "Like Xamarin?", Style = labelStyle };
            switchLike = new Switch { };
            var saveButton = new Button { Text = "Save", HorizontalOptions = LayoutOptions.FillAndExpand };
            saveButton.Clicked += saveButton_Clicked;
            var loadButton = new Button { Text = "Load", HorizontalOptions = LayoutOptions.FillAndExpand };
            loadButton.Clicked += loadButton_Clicked;
            var clearButton = new Button { Text = "Clear", HorizontalOptions = LayoutOptions.FillAndExpand };
            clearButton.Clicked += clearButton_Clicked;
            resultLabel = new Label { Text = "", FontSize = 30 };

            Title = "Save to dictionary (C#)";
            Content = new StackLayout
            {
                Padding = 10,
                Spacing = 10,
                Children = {
                    new Label { Text = "DataSave Sample", FontSize = 40, HorizontalOptions = LayoutOptions.Center },
                    new StackLayout {
                        Orientation = StackOrientation.Horizontal,
                        Children = {
                            labelName, entryName
                        }
                    },
                    new StackLayout {
                        Orientation = StackOrientation.Horizontal,
                        Children = {
                            labelBirthday, pickerBirthday
                        }
                    },
                    new StackLayout {
                        Orientation = StackOrientation.Horizontal,
                        Children = {
                            labelLike, switchLike
                        }
                    },
                    new StackLayout {
                        Orientation = StackOrientation.Horizontal,
                        Children = {
                            saveButton, loadButton, clearButton
                        }
                    },
                    resultLabel
                }
            };
        }
开发者ID:zcccust,项目名称:Study,代码行数:60,代码来源:SaveToDictionaryCS.cs

示例11: HalloweenScene2013

        public HalloweenScene2013(IEnumerable<string> args)
        {
            buttonTestHand = new DigitalInput("Hand");
            buttonTestHead = new DigitalInput("Head");
            buttonTestDrawer1 = new DigitalInput("Drawer 1");
            buttonTestDrawer2 = new DigitalInput("Drawer 2");
            buttonRunSequence = new DigitalInput("Run Seq!");
            buttonTestSound = new DigitalInput("Test Sound");
            buttonTestPopEyes = new DigitalInput("Pop Eyes");
            buttonTestPopUp = new DigitalInput("Pop Up");

            switchHand = new Switch("Hand");
            switchHead = new Switch("Head");
            switchDrawer1 = new Switch("Drawer 1");
            switchDrawer2 = new Switch("Drawer 2");
            switchPopEyes = new Switch("Pop Eyes");
            switchPopUp = new Switch("Pop Up");

            audioPlayer = new AudioPlayer("Audio Player");

            raspberry.DigitalInputs[0].Connect(buttonTestHand);
            raspberry.DigitalInputs[1].Connect(buttonTestHead);
            raspberry.DigitalInputs[2].Connect(buttonTestDrawer1);
            raspberry.DigitalInputs[3].Connect(buttonTestDrawer2);
            raspberry.DigitalInputs[7].Connect(buttonRunSequence);
            raspberry.DigitalOutputs[7].Connect(switchHand);
            raspberry.DigitalOutputs[2].Connect(switchHead);
            raspberry.DigitalOutputs[5].Connect(switchDrawer1);
            raspberry.DigitalOutputs[6].Connect(switchDrawer2);
            raspberry.DigitalOutputs[3].Connect(switchPopEyes);
            raspberry.DigitalOutputs[4].Connect(switchPopUp);

            raspberry.Connect(audioPlayer);
        }
开发者ID:HakanL,项目名称:animatroller,代码行数:34,代码来源:HalloweenScene2013.cs

示例12: GetAnimatedSwitch

        public static StackLayout GetAnimatedSwitch(FlexPie flexPie)
        {
            Label label = new Label();

            label.Text = "Animated?";

            label.VerticalOptions = LayoutOptions.FillAndExpand;
            label.HorizontalOptions = LayoutOptions.FillAndExpand;

            Switch toggleSwitch = new Switch();

            toggleSwitch.IsToggled = true;

            toggleSwitch.Toggled += (e, sender) =>
            {
                Switch sentSwitch = (Switch) e;

                flexPie.IsAnimated = sentSwitch.IsToggled;
            };

            StackLayout stack = new StackLayout();

            stack.Orientation = StackOrientation.Horizontal;

            stack.Children.Add(label);
            stack.Children.Add(toggleSwitch);

            return stack;
        }
开发者ID:techShubham,项目名称:Xamarin.Forms-Samples,代码行数:29,代码来源:Switches.cs

示例13: NightFever

        public NightFever()
        {
            for (int i = 0; i < MaxPlayers; i++)
            {
                Players[i] = new Player();
            }

            /* Lamp Definitions */
            Lamps[0] = new Lamp("Player 1 Lamp", FEZ_Pin.Digital.LED);
            Lamps[1] = new Lamp("Player 2 Lamp", FEZ_Pin.Digital.Di50);

            /* Relay Definitions */
            Relays[0] = new Relay("Knocker",0);
            Relays[1] = new Relay("Locked Ball Eject",1);
            Relays[2] = new Relay("Ball Return",2);
            Relays[3] = new Relay("Left Bank Reset",3);
            Relays[4] = new Relay("Right Bank Reset", 4);

            /* Switch Definitions */
            Switches[0] = new Switch("Ball Detect", FEZ_Pin.Interrupt.LDR, "","", Port.InterruptMode.InterruptEdgeBoth);
            Switches[1] = new Switch("Outer Left Drain", FEZ_Pin.Interrupt.Di43, "", "", Port.InterruptMode.InterruptEdgeLow);
            Switches[2] = new Switch("Left Coin Insert", FEZ_Pin.Interrupt.Di7, "ADDCREDIT 1:PLAYSOUND CreditSound.wav", "", Port.InterruptMode.InterruptEdgeLow);
            Switches[3] = new Switch("Right Coin Insert", FEZ_Pin.Interrupt.Di38, "ADDCREDIT 2:PLAYSOUND CreditSound.wav", "", Port.InterruptMode.InterruptEdgeLow);
            Switches[4] = new Switch("Credit Button", FEZ_Pin.Interrupt.Di35, "ADDCREDIT 1:PLAYSOUND CreditSound.wav", "", Port.InterruptMode.InterruptEdgeLow);
            Switches[5] = new Switch("Start Button", FEZ_Pin.Interrupt.Di30, "", "", Port.InterruptMode.InterruptEdgeLow);
        }
开发者ID:VIDGuide,项目名称:PandaPinball,代码行数:26,代码来源:NightFever.cs

示例14: App

		public App ()
		{
			var stringSettingEntry = new Entry ();
			stringSettingEntry.SetBinding (Entry.TextProperty, nameof (SettingsViewModel.SomeStringSetting));

			var boolSettingSwitch = new Switch ();
			boolSettingSwitch.SetBinding (Switch.IsToggledProperty, nameof (SettingsViewModel.SomeBoolSetting));

			// The root page of your application
			MainPage = new ContentPage {
				Content = new StackLayout {
					VerticalOptions = LayoutOptions.Center,
					Children = {
						new Label {
							Text = "Some String"
						},
						stringSettingEntry,
						new Label {
							Text = "Some Bool"
						},
						boolSettingSwitch,
					}
				}
			};

			MainPage.BindingContext = new SettingsViewModel ();
		}
开发者ID:patridge,项目名称:demos-xamarin.forms-tour,代码行数:27,代码来源:X.FPluginDemo.cs

示例15: RobotConsole

        /// <summary>
        /// Initialisiert die Roboter-Konsole mit den dazugehörigen LED's und Schalter.
        /// </summary>
        public RobotConsole(RunMode aRunMode)
        {
            if (aRunMode == RunMode.Virtual)
            {
                digitalIn = new DigitalInSim();
                digitalOut = new DigitalOutSim();
            }
            else
            {
                digitalIn = new DigitalInHW(Constants.IOConsoleSWITCH);
                digitalOut = new DigitalOutHW(Constants.IOConsoleLED);
            }

            this.leds = new Led[4];
            for (int i = 0; i < this.leds.Length; i++)
            {
                leds[i] = new Led((Leds)i, digitalOut);
                if (i % 2 == 0)
                {
                    leds[i].LedEnabled = false;
                }
            }

            this.switches = new Switch[4];
            for (int i = 0; i < this.switches.Length; i++)
            {
                switches[i] = new Switch((Switches)i, digitalIn);
                switches[i].SwitchStateChanged += new EventHandler<SwitchEventArgs>(RobotConsole_SwitchStateChanged);
            }
        }
开发者ID:maesi,项目名称:prgsy,代码行数:33,代码来源:RobotConsole.cs


注:本文中的Switch类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。