예제 #1
0
		public static void Main (string[] args)
		{
			MenuContainer container;
			Menu mainMenu = new Menu("Main menu");
			Menu subMenu = new Menu("Sub menu");
			Menu subSubMenu = new Menu ("sub sub Menu");

			IStep turnOnStep = new StepContainer (TurnOn, "Turning On", "Error turning on", "Turned on sucesfully");
			IStep turnOffStep = new StepContainer (TurnOff, "Turning Off", "Error turning off");

			subSubMenu.AddItem( new ItemWithCheckBoxStep("Turned on", false, "Device", new CheckBoxStep(turnOnStep, turnOffStep), OnTurnOnChanged  ));
			subSubMenu.AddItem (new MonoBrickQuestion());
			subSubMenu.AddItem( new ItemWithBrickInfo());

			subMenu.AddItem (subSubMenu);
			subMenu.AddItem( new ItemWithCharacterInput("Name", "Enter Name", "Anders", OnNameChanged, false, true, true));
			subMenu.AddItem( new ItemWithNumericInput("Age", 29, OnAgeChanged, 0, 100));
			subMenu.AddItem( new ItemWithCheckBox("Loves C#", true, OnCheckedChanged));

			mainMenu.AddItem (subMenu);
			mainMenu.AddItem (new ItemWithProgramList ("Programs"));
			
			container = new MenuContainer(mainMenu);
			container.Show (true);
		}
예제 #2
0
		public static void Main (string[] args)
		{
			settings = new EmailSettings ();
			settings.Load ();
			Menu settingMenu = new Menu ("Settings");
			settingMenu.AddItem (new ItemWithCharacterInput ("User Name", "User Name", settings.UserSettings.User, OnUserChanged, false, true, false));
			settingMenu.AddItem (new ItemWithCharacterInput ("SMTP", "SMTP Server", settings.UserSettings.Smtp, OnSMTPChanged, false, true, false));
			settingMenu.AddItem (new ItemWithCharacterInput ("Password", "SMTP Password", settings.UserSettings.Password, OnPasswordChanged, true, true, false));
			settingMenu.AddItem (new ItemWithNumericInput("Port Number", settings.UserSettings.Port, OnPortNmberChanged, 1, 49151));
			settingMenu.AddItem (new ItemWithCheckBox("Enable SSL", settings.UserSettings.EnableSsl, OnEnableSslChanged));

			Menu menu = new Menu ("E-Mail Client");
			menu.AddItem (settingMenu);
			menu.AddItem (new ItemWithCharacterInput ("To", "To", emailTo, (emailAddress) => emailTo = emailAddress, false, true, false ));
			menu.AddItem (new ItemWithCharacterInput ("Subject", "Subject", subject, (newSubject) => subject = newSubject, false, true, false ));
			menu.AddItem (new ItemWithCharacterInput ("Message", "Message", "", (newMessage) => message = newMessage));
			menu.AddItem (new ItemWithDialog<StepDialog>(new StepDialog( "Sending mail ", new List<IStep>{SendStep}), "Send mail")); 
			MenuContainer container = new MenuContainer (menu);
			container.Show (true);
		}
예제 #3
0
		public static void Main (string[] args)
		{
			if (!File.Exists (SuspendFile))
			{
				File.Create (SuspendFile);
			}
			FileSystemWatcher watcher = new FileSystemWatcher();
			watcher.Path = Path.GetDirectoryName(SuspendFile);
			watcher.NotifyFilter = NotifyFilters.LastWrite;
			watcher.Filter = Path.GetFileName(SuspendFile);
			watcher.Changed += OnSuspendFileChanged;
			watcher.EnableRaisingEvents = true;

			Menu menu = new Menu ("Main Menu");

			menu.AddItem(new ItemWithProgramList ("Programs", false));
			menu.AddItem(new ItemWiFiOptions ());
			menu.AddItem(new ItemWithSettings ());
			menu.AddItem(new ItemWithUpdateDialog ());
			//menu.AddItem(new ItemWithWebserver ());
			menu.AddItem(new ItemWithBrickInfo ());
			menu.AddItem(new ItemWithTurnOff ());

			container = new FirmwareMenuContainer (menu);

			Bitmap monoLogo = Bitmap.FromResouce(Assembly.GetExecutingAssembly(), "monologo.bitmap");
			Lcd.DrawBitmap (monoLogo, new Point ((int)(Lcd.Width - monoLogo.Width) / 2, 5));					
			Rectangle textRect = new Rectangle (new Point (0, Lcd.Height - (int)Font.SmallFont.maxHeight - 2), new Point (Lcd.Width, Lcd.Height - 2));

			Lcd.WriteTextBox (Font.SmallFont, textRect, "Initializing...", true, Lcd.Alignment.Center);
			Lcd.Update ();
			WiFiDevice.TurnOff ();
			ProgramManager.CreateSDCardFolder();
			Lcd.WriteTextBox (Font.SmallFont, textRect, "Loading settings...", true, Lcd.Alignment.Center);
			Lcd.Update ();
			FirmwareSettings.Load ();
			Lcd.WriteTextBox (Font.SmallFont, textRect, "Applying settings...", true, Lcd.Alignment.Center);
			Lcd.Update ();						
			if (FirmwareSettings.GeneralSettings.ConnectToWiFiAtStartUp) 
			{
				Lcd.WriteTextBox (Font.SmallFont, textRect, "Connecting to WiFi...", true, Lcd.Alignment.Center);
				Lcd.Update ();						
				if (WiFiDevice.TurnOn (FirmwareSettings.WiFiSettings.SSID, FirmwareSettings.WiFiSettings.Password, FirmwareSettings.WiFiSettings.Encryption, 40000)) 
				{
					if (FirmwareSettings.GeneralSettings.CheckForSwUpdatesAtStartUp)
					{
						container.Show (3); //show the menu container with the update dialog
						return;
					} 
					else 
					{
						var dialog = new InfoDialog ("Connected Successfully " + WiFiDevice.GetIpAddress ());
						dialog.Show ();
					} 
				} 
				else 
				{
					var dialog = new InfoDialog ("Failed to connect to WiFI Network");
					dialog.Show ();
				}
			}
			container.Show ();	
		}