//Navigate and change state if something is not normal
        public void Navigate(UserControl nextPage, object state)
        {
            this.Content = nextPage;
            if (nextPage is Buildings_report)
            {
                this.Width = 1200;
                CenterWindowOnScreen();
            }
            else
            {
                this.Width  = 800;
                this.Height = 600;
                CenterWindowOnScreen();
            }
            ISwitchable s = nextPage as ISwitchable;

            if (s != null)
            {
                s.UtilizeState(state);
            }
            else
            {
                throw new ArgumentException("NextPage is not ISwitchable! "
                                            + nextPage.Name.ToString());
            }
        }
Example #2
0
        private Object HandleTurnOffRequest(JObject request)
        {
            string DeviceID = (string)request["payload"]["appliance"]["applianceId"];

            ErrorLog.Notice("Turning off device {0}\n", DeviceID);
            Appliance   device           = DeviceList.GetDevice(DeviceID);
            ISwitchable switchableDevice = device as ISwitchable;

            if (switchableDevice != null)
            {
                switchableDevice.Off();
            }
            // TODO: return an error if not switchable
            return(new Response()
            {
                Header = new Header()
                {
                    Namespace = "Alexa.ConnectedHome.Control",
                    Name = DirectiveName.TurnOffConfirmation,
                    PayloadVersion = "2",
                    MessageID = Guid.NewGuid(),
                },
                Payload = new Dictionary <string, string> {
                },
            });
        }
        public override GameObject CreateLever(PointF p, ISwitchable obj, bool isOn = false, float size = 1.0f)
        {
            RogueLever rl = new RogueLever(p, obj, isOn, size);

            AddGameObject(rl);
            return(rl);
        }
Example #4
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        //EnemyShip enemy = other.gameObject.GetComponent<EnemyShip>();
        //if (enemy != null)
        //{
        //    enemy.shootingEnabled = true;
        //}
        //else
        //{
        //    BossShip boss = other.gameObject.GetComponent<BossShip>();
        //    if (boss != null)
        //    {
        //        boss.shootingEnabled = true;
        //    }
        //}
        ISwitchable obj = other.gameObject.GetComponent <ISwitchable>();

        if (obj != null)
        {
            obj.SwitchOn();
        }

        //other.gameObject.GetComponent<EnemyShip>().shootingEnabled = true;
        //Debug.Log("коллизия!");
    }
Example #5
0
        public static Switch CreateSwitch(ISwitchable switchable)
        {
            var openCommand  = new OpenSwitchCommand(switchable);
            var closeCommand = new CloseSwitchCommand(switchable);
            var returnSwitch = new Switch(openCommand, closeCommand);

            return(returnSwitch);
        }
Example #6
0
    public override void TurnOff(ISwitchable parent)
    {
        var level = FindObjectOfType <LevelGrid>();

        if (this != null)
        {
            level.PlaceBlockByTypeId(transform.position, (int)Blocks.Repeller);
        }
    }
Example #7
0
        public ActionResult Switch(int id)
        {
            IDictionary <int, Applience> applienceDictionary = (SortedDictionary <int, Applience>)Session["Apps"];
            ISwitchable app = applienceDictionary[id];

            app.OnOff();

            return(RedirectToAction("Index"));
        }
Example #8
0
        public void SubscribeTo(ISwitchable aSwitchable)
        {
            if (aSwitchable == null)
                throw new ArgumentNullException("Need to supply a valid Node.");

            if (aSwitchable.State != this.State)
                SwitchStates();

            aSwitchable.StateSwitched += SubscribedStateSwitched;
        }
Example #9
0
 // Start is called before the first frame update
 void Start()
 {
     if (!(switchableComponent is ISwitchable))
     {
         Debug.LogError("Not Switchable!");
     }
     else
     {
         switchableElement = (ISwitchable)switchableComponent;
     }
     spriteRenderer = GetComponent <SpriteRenderer>();
 }
Example #10
0
 public void Navigate(UserControl nextPage, object state)
 {
     Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
     {
         this.Content            = nextPage;
         ISwitchable switchable1 = nextPage as ISwitchable;
         if (switchable1 == null)
         {
             throw new ArgumentException("NextPage is not ISwitchable! " + nextPage.Name.ToString(CultureInfo.InvariantCulture));
         }
         switchable1.UtilizeState(state);
     }));
 }
Example #11
0
        public void Navigate(UserControl nextPage, object state)
        {
            base.Content = nextPage;

            ISwitchable switchable = nextPage as ISwitchable;

            if (switchable == null)
            {
                throw new ArgumentException("NextPage is not ISwitchable! " + nextPage.Name.ToString());
            }

            switchable.UtilizeState(state);
        }
Example #12
0
 static void ISwitchMethod(ISwitchable dev, int x)
 {
     if (x == 0)
     {
         dev.Off();
         dev.ViewState();
     }
     else
     {
         dev.On();
         dev.ViewState();
     }
 }
Example #13
0
        public void Switch(ISwitchable device)
        {
            if (device.IsOn)
            {
                device.TurnOff();
            }
            else
            {
                device.TurnOn();
            }

            device.IsOn = !device.IsOn;
        }
Example #14
0
 public void TurnOn(ISwitchable parent)
 {
     if (!_parents.Contains(parent))
     {
         _parents.Add(parent);
         IsOn = true;
         if (_parents.Count == 1)
         {
             OnTurnedOn();
             GetComponent <SpriteRenderer>().sprite = _onSprite;
             TurnOnNeighbours();
         }
     }
 }
Example #15
0
        public void Navigate(UserControl nextPage, object State)
        {
            this.Content = nextPage;
            ISwitchable s = nextPage as ISwitchable;

            if (s != null)
            {
                s.UtilizeState(State);
            }
            else
            {
                throw new ArgumentException("NextPage is not ISwitchable! " + nextPage.Name.ToString());
            }
        }
Example #16
0
 public void TurnOff(ISwitchable parent)
 {
     if (_parents.Count > 0 && _parents.Contains(parent))
     {
         _parents.Remove(parent);
     }
     if (_parents.Count == 0)
     {
         IsOn = false;
         OnTurnedOff();
         GetComponent <SpriteRenderer>().sprite = _offSprite;
         TurnOffNeighbours();
     }
 }
Example #17
0
        public void Navigate(UserControl newPage, object data, StateMessage msg)
        {
            this.Content = newPage;
            ISwitchable i = newPage as ISwitchable;

            if (i != null)
            {
                i.UtilizeState(data, msg);
            }
            else
            {
                throw new ArgumentException("NewPage is not Switchable!");
            }
        }
Example #18
0
		// Use this for initialization
		void Awake () {

		
			_activatableObject = this.GetComponent(typeof(ISwitchable)) as ISwitchable;

			// Activate is we are activating on start
			// Deactivate if it is not supposed to be active on start
			if (_isActiveOnStart) {
				Activate();
			}
			else {
				Deactivate();
			}

		}
Example #19
0
        internal void Navigate(UserControl newPage, object state)
        {
            pageHolder.Child = newPage;

            ISwitchable s = newPage as ISwitchable;

            if (s != null)
            {
                s.UtiliseState(state);
            }
            else
            {
                throw new ArgumentException("New page " + newPage.Name.ToString() + "is not ISwitchable");
            }
        }
Example #20
0
        public RogueLever(PointF p, ISwitchable switchableObject = null, bool isOn = false, float scale = 1.0f)
            : base(GetDefaultTexture(), p, GetDefaultSize(), GameObjectType.Obstacle)
        {
            Size = new SizeF(Size.Width * scale, Size.Height * scale);

            SwitchableObject = switchableObject;
            IsOn             = isOn;
            if (isOn)
            {
                BitmapPath = @"Button_ON.png";
            }
            else
            {
                BitmapPath = @"Button_OFF.png";
            }
        }
Example #21
0
 // Start is called before the first frame update
 void Start()
 {
     foreach (GameObject el in input)
     {
         if (el == null)
         {
             screens.Add(null);
             continue;
         }
         ISwitchable found = el.GetComponent <ISwitchable>();
         if (found != null)
         {
             screens.Add(found);
             found.Close();
         }
     }
     screens[active].Open();
 }
        // when loading views, with this apparently one can pass parameters to other views
        public void Navigate(UserControl nextPage, object state)
        {
            //load page
            this.Content = nextPage;
            // use ISwitchable interface
            ISwitchable s = nextPage as ISwitchable;

            // check if s is not null
            if (s != null)
            {
                s.UtilizeState(state);
            }
            else
            {
                throw new ArgumentException("NextPage is not ISwitchable! "
                                            + nextPage.Name.ToString());
            }
        }
Example #23
0
        public void Navigate(UserControl nextPage, object state)
        {
            var prevPage = this.Content;

            if (prevPage is IDisposable)
            {
                (prevPage as IDisposable).Dispose();
            }
            this.Content = nextPage;
            ISwitchable s = nextPage as ISwitchable;

            if (s != null)
            {
                s.UtilizeState(state);
            }
            else
            {
                throw new ArgumentException("NextPage is not ISwitchable! "
                                            + nextPage.Name.ToString());
            }
        }
Example #24
0
        static void Main(string[] args)
        {
            MessWithOnOff <Light> messer = new MessWithOnOff <Light>();

            messer.Flip(new Light());

            List <Person> group = new List <Person> {
                new Person {
                    Name = "Bob", Age = 50
                },
                new Person {
                    Name = "Tom", Age = 30
                }
            };

            group.Sort();
            //int[] arr = { 1, 2, 3, 4, 5 };
            //test(ref arr[3]);
            //Console.WriteLine(arr[3]);
            //IEnumerable<string> names = new string[] { "John", "Bob", "Tom" };
            Light       a = new Light();
            ISwitchable b = a;
            I38Faucet   c = a;

            //a.TurnOn();
            b.TurnOn();
            c.TurnOn();
            IEnumerable <ISwitchable> switchPanel = new List <ISwitchable> {
                new Light(), new Light()
            };

            switchPanel = new List <Light> {
                new Light(), new Light()
            };



            Console.ReadLine();
        }
Example #25
0
    // Use this for initialization
    void Start()
    {
        // finds the player
        player = GameObject.Find("Player");

        // adds all of the switchables to the list
        // all switchables MUST follow the following naming convention:
        // switchable[switch#]_[index#]
        switchables = new ArrayList(numberOfSwitchables);
        for (int i = 0; i < numberOfSwitchables; i++)
        {
            GameObject component = GameObject.Find("switchable" + switchNo + "_" + i);
            if (!(component == null))
            {
                ISwitchable switchable = component.GetComponent("ISwitchable") as ISwitchable;
                if (!(switchable == null))
                {
                    switchables.Add((ISwitchable)switchable);
                }
            }
        }
    }
Example #26
0
        public void Navigate(UserControl view)
        {
            if (currentView != null)
            {
                currentView.Destroy();
            }

            if (view.Name == "MainScreen")
            {
                buttonBack.Visibility = Visibility.Collapsed;
            }
            else
            {
                buttonBack.Visibility = Visibility.Visible;
            }

            helpContent.Visibility = Visibility.Hidden;
            currentView            = view as ISwitchable;
            currentViewName        = view.Name;
            mainContent.Children.Clear();
            mainContent.Children.Add(view);
            //if ("PlayerScreen".Equals(currentViewName))
            //    ((player)view).nextToPlay(0);
        }
Example #27
0
 public OpenSwitchCommand(ISwitchable switchable)
 {
     _switchable = switchable;
 }
Example #28
0
 public OpenSwitchCommand(ISwitchable switchable) this.switchable = switchable;
Example #29
0
 public CloseSwitchCommand(ISwitchable switchable) this.switchable = switchable;
 public CloseSwitchCommand(ISwitchable switchable)
 {
     this.switchable = switchable;
 }
Example #31
0
 public void AddSwitchable(ISwitchable switchable)
 {
     Switchables.Add(switchable);
 }
Example #32
0
 public void SetTertiarySwitch(ISwitchable switchable)
 => privateMessageSwitch = switchable;
 public OpenSwitchCommand(ISwitchable switchable)
 {
     this.switchable = switchable;
 }
Example #34
0
        public RogueLever(PointF p, ISwitchable switchableObject = null, bool isOn = false, float scale = 1.0f)
            : base(GetDefaultTexture(), p, GetDefaultSize(), GameObjectType.Obstacle)
        {
            Size = new SizeF(Size.Width * scale, Size.Height * scale);

            SwitchableObject = switchableObject;
            IsOn = isOn;
            if (isOn)
            {
                BitmapPath = @"Button_ON.png";
            }
            else
            {
                BitmapPath = @"Button_OFF.png";
            }
        }
 public override GameObject CreateLever(PointF p, ISwitchable obj, bool isOn = false, float size = 1.0f)
 {
     RogueLever rl = new RogueLever(p, obj, isOn, size);
     AddGameObject(rl);
     return rl;
 }
Example #36
0
 public OpenSwitchCommand(ISwitchable switchable)
 {
     _switchable = switchable;
 }
Example #37
0
		static void Main(string[] args)
		{
			Random rnd = new Random();

			Console.Write("Введите номер задания:\t");
			int taskNum = Int32.Parse(Console.ReadLine());
			switch (taskNum)
			{
				default:
					Console.WriteLine("Задание с таким номером не реализовано.");
					break;
				case 1:
					Console.WriteLine("Задание {0}:", taskNum);
					{
						ISwitchable[] dev = new ISwitchable[2];
						dev[0] = new TvSet();
						dev[1] = new Fridge();
						for (int i = 0; i < dev.Length; i++)
						{
							Console.WriteLine(dev[i].ToString());
							dev[i].TurnOn();
							Console.WriteLine(dev[i].ToString());
						}
					}
					break;
				case 2:
					Console.WriteLine("Задание {0}:", taskNum);
					{
						AnotherNamespace.NS obj = new AnotherNamespace.NS();
						Console.WriteLine(obj);
					}
					break;
				case 3:
					Console.WriteLine("Задание {0}:", taskNum);
					{
						int i;
						Task3 obj = new Task3();
						for (i = 0; i < 3; i++)
						{
							obj[i] = i;
						}
						for (i = -1; i < 4; i++)
						{
							Console.WriteLine("obj[{0}] = {1}", i, obj[i]);
						}
					}
					break;
				case 4:
					Console.WriteLine("Задание {0}:", taskNum);
					{
						Console.WriteLine(CheckChildrenCount("Кто-то", null));
						Console.WriteLine(CheckChildrenCount("Нулевой", 0));
						Console.WriteLine(CheckChildrenCount("Вася", 3));
					}
					break;
				case 5:
					Console.WriteLine("Задание {0}:", taskNum);
					{
						var anon = new { P1 = 2, Name = "имя", Unknown = new { f**k = "you"} };
						Console.WriteLine("anon = \t\t{0}\t({1})", anon, anon.GetType());
						Console.WriteLine("anon.P1 = \t{0}\t({1})", anon.P1, anon.P1.GetType());
						Console.WriteLine("anon.Name = \t{0}\t({1})", anon.Name, anon.Name.GetType());
						Console.WriteLine("anon.Unknown = \t{0}\t({1})", anon.Unknown, anon.Unknown.GetType());
						Console.WriteLine("anon.Unknown.f**k = \t{0}\t({1})", anon.Unknown.f**k, anon.Unknown.f**k.GetType());
					}
					break;
				case 6:
					Console.WriteLine("Задание {0}:", taskNum);
					{
						Menu.Show();
					}
					break;
			}
		}
 public PowerOnCommand(ISwitchable switcher)
 {
     this._switcher = switcher;
 }
Example #39
0
 public CloseSwitchCommand(ISwitchable switchable)
 {
     _switchable = switchable;
 }
Example #40
0
 public void SetSecondarySwitch(ISwitchable switchable)
 => cncnetLobbySwitch = switchable;
		public DisposableAdapter(ISwitchable switchableItem)
		{
			this.switchableItem = switchableItem;
			switchableItem.On();
		}
 public override GameObject CreateLever(PointF p, ISwitchable obj, bool isOn = false, float size = 1.0f)
 {
     throw new NotImplementedException();
 }