protected void OnNotificationUpdated(CustomNotification notification)
 {
     if (NotificationUpdated != null)
     {
         NotificationUpdated(this, new NotificationUpdatedEventArgs(notification));
     }
 }
		private void ControlsToEvent (CustomNotification e)
		{
			EditObject.Enabled = checkbuttonEnabled.Active;
			e.Name = entryName.Text;
			e.BlinkSpeed = (BlinkSpeedEnum)comboboxBlinkSpeed.Active;
			e.Priority = (NotificationPriorityEnum)comboboxPriority.Active;
			e.Color = RgbColor.FromGdkColor (colorbuttonColor.Color.Red, colorbuttonColor.Color.Green, colorbuttonColor.Color.Blue);

			if (radiobuttonBlink.Active) {
				e.NotificationType = NotificationTypeEnum.Blink;
			} else if (radiobuttonPulse.Active) {
				e.NotificationType = NotificationTypeEnum.Pulse;
			} else {
				e.NotificationType = NotificationTypeEnum.Morph;
			}

			e.BlinkCount = (Byte)spinbuttonBlinkCount.Value;

			foreach (NotificationWidget page in Pages) {
				page.ControlsToObject (e);
			}

			e.Device = SelectedDeviceSerial;

		}
		public override void ObjectToControls (CustomNotification e)
		{
			if (!(e is BlinkstickService)) {
				return;
			}
			BlinkstickService be = e as BlinkstickService;

			entryAccessCode.Text = be.AccessCode;
		}
		public override void ControlsToObject (CustomNotification e)
		{
			if (!(e is BlinkstickService)) {
				return;
			}
			BlinkstickService be = e as BlinkstickService;

			be.AccessCode = entryAccessCode.Text;
		}
		public override void ControlsToObject (CustomNotification e)
		{
			if (!(e is GoogleEmailNotification)) {
				return;
			}
			GoogleEmailNotification ge = e as GoogleEmailNotification;

			ge.Email = entryUsername.Text;
			ge.Password = entryPassword.Text;
		}
		public override void ObjectToControls (CustomNotification e)
		{
			if (!(e is GoogleEmailNotification)) {
				return;
			}
			GoogleEmailNotification ge = e as GoogleEmailNotification;

			entryUsername.Text = ge.Email;
			entryPassword.Text = ge.Password;
		}
		public override void CopyProperties (CustomNotification source)
		{
			base.CopyProperties (source);

			if (source is ImapEmailNotification) {
				this.Email = (source as ImapEmailNotification).Email;
				this.Password = (source as ImapEmailNotification).Password;
				this.ServerAddress = (source as ImapEmailNotification).ServerAddress;
			}
		}
		public override void ControlsToObject (CustomNotification e)
		{
			if (!(e is ImapEmailNotification)) {
				return;
			}
			ImapEmailNotification ge = e as ImapEmailNotification;

			ge.Email = entryUsername.Text;
			ge.Password = entryPassword.Text;
			ge.ServerAddress = entryServerAddress.Text;
		}
		public override void ObjectToControls (CustomNotification e)
		{
			if (!(e is ImapEmailNotification)) {
				return;
			}
			ImapEmailNotification ge = e as ImapEmailNotification;

			entryUsername.Text = ge.Email;
			entryPassword.Text = ge.Password;
			entryServerAddress.Text = ge.ServerAddress;
		}
		public static CustomNotification ShowForm()
		{
			CustomNotification result = null;
			SelectNotificationTypeForm form = new SelectNotificationTypeForm ();
			int response = form.Run ();
		
			if ((ResponseType)response == ResponseType.Ok) {
				if (form.radiobuttonCustom.Active)
				{
					result = new CustomNotification();
				}
				else if (form.radiobuttonGmail.Active)
				{
					result = new GoogleEmailNotification();
				}
				else if (form.radiobuttonImap.Active)
				{
					result = new ImapEmailNotification();
				}
				else if (form.radiobuttonBlinkstickService.Active)
				{
					result = new BlinkstickService();
				}
				else if (form.radiobuttonCpuUsage.Active)
				{
					result = new CpuUsageNotification();
				}
				else if (form.radiobuttonAmbilight.Active)
				{
					result = new AmbiLightNotification();
				}
			}

			form.Destroy();

			return result;
		}
		public override void CopyProperties (CustomNotification source)
		{
			base.CopyProperties (source);

			if (source is BlinkstickService) {
				this.AccessCode = (source as BlinkstickService).AccessCode;
			}
		}
	        public NotificationUpdatedEventArgs(CustomNotification notification)
	        {
	            this.Notification = notification;
	        }
		public virtual void ControlsToObject (CustomNotification e)
		{
		}
		public virtual void ObjectToControls (CustomNotification e)
		{
		}
		public void RunTest ()
		{
			LedController controller = Manager.FindControllerBySerialNumber (SelectedDeviceSerial);
			if (controller != null) {
				CustomNotification tempEvent = new CustomNotification();
				ControlsToEvent(tempEvent);
				controller.ExecuteEvent(tempEvent);
			}
		}
		public static Boolean ShowForm(CustomNotification tevent, NotificationManager manager)
		{
			Boolean result = false;
			EditNotificationForm form = new EditNotificationForm ();
			form.EditObject = tevent;
			form.Manager = manager;
			form.SetupPages();
			form.ObjectToControls();
			int response = form.Run ();
		
			while (true) {
				if ((ResponseType)response == ResponseType.Ok) {
					if (form.ValidateForm())
					{
						form.ControlsToObject();
						result = true;
						break;
					}
				}
				else if ((ResponseType)response == ResponseType.Cancel) {
					break;
				}
				else if ((ResponseType)response == ResponseType.Apply) {
					form.RunTest();
				}
				else
				{
					break;
				}

				response = form.Run ();
			}

			form.Destroy();

			return result;
		}
		public void RemoveNotification (CustomNotification notification)
		{
			Notifications.Remove (notification);
			RemoveEvents (notification);
			foreach (LedController controller in Controllers) {
				if (controller.ActiveNotifications.Contains(notification))
				{
					controller.ActiveNotifications.Remove(notification);
					return;
				}
			}
		}
		protected void OnButtonPulseColorClicked (object sender, System.EventArgs e)
		{
            if (TestNotification == null)
            {
                TestNotification = new CustomNotification();
                TestNotification.NotificationType = NotificationTypeEnum.Pulse;
                TestNotification.BlinkCount = 1;
                TestNotification.BlinkSpeed = BlinkSpeedEnum.Normal;
            }

            TestNotification.Color = RgbColor.FromGdkColor(
                colorSelection.CurrentColor.Red, 
                colorSelection.CurrentColor.Green, 
                colorSelection.CurrentColor.Blue);

            SelectedController.ExecuteEvent(TestNotification);
		}
		public void AddNotification(CustomNotification notification)
		{
			Notifications.Add(notification);
			AssignEvents(notification);

			if (notification is BlinkstickService) {
				if (notification.Enabled) {
					client.Subscribe ("/devices/" + ((BlinkstickService)notification).AccessCode);
					if (!client.Working)
					{
						client.Connect ();
					}
				}
			}
		}
		public HistoryItem AddHistoryItemForNotification(CustomNotification notification, String text)
		{
			HistoryItem item = new HistoryItem(notification.Name, text);
			History.Add (item);
			return item;
		}
		public virtual CustomNotification Copy()
		{
			CustomNotification ev = new CustomNotification();
			ev.CopyProperties(this);
			return ev;
		}
예제 #22
0
 		public void ExecuteEvent (CustomNotification e)
		{
			if (Animating)
            {
                return;
            }

            if (e.NotificationType == NotificationTypeEnum.Pulse) {
				switch (e.BlinkSpeed) {
				case BlinkSpeedEnum.VerySlow:
					AnimationSpeed = 0.001;
					break;
				case BlinkSpeedEnum.Slow:
					AnimationSpeed = 0.005;
					break;
				case BlinkSpeedEnum.Normal:
					AnimationSpeed = 0.01;
					break;
				case BlinkSpeedEnum.Fast:
					AnimationSpeed = 0.05;
					break;
				case BlinkSpeedEnum.VeryFast:
					AnimationSpeed = 0.1;
					break;
				case BlinkSpeedEnum.VeryVeryFast:
					AnimationSpeed = 0.15;
					break;
				default:
					break;
				}

				PulsateSingleColor (e.BlinkCount, e.VisibleColor);
            } else if (e.NotificationType == NotificationTypeEnum.Blink) {
				switch (e.BlinkSpeed) {
				case BlinkSpeedEnum.VerySlow:
					AnimationSpeed = 5000;
					break;
				case BlinkSpeedEnum.Slow:
					AnimationSpeed = 2000;
					break;
				case BlinkSpeedEnum.Normal:
					AnimationSpeed = 500;
					break;
				case BlinkSpeedEnum.Fast:
					AnimationSpeed = 200;
					break;
				case BlinkSpeedEnum.VeryFast:
					AnimationSpeed = 100;
					break;
				case BlinkSpeedEnum.VeryVeryFast:
					AnimationSpeed = 50;
					break;
				default:
					break;
				} 

				BlinkColor(e.BlinkCount, e.VisibleColor);
			} else {
				MorphToColor(e.VisibleColor);
			}
		}
		private void RemoveEvents (CustomNotification notification)
		{
			notification.ActiveStatusChanged -= HandleActiveStatusChanged;
			notification.EnabledStatusChanged -= HandleEnabledStatusChanged;
			if (notification is BlinkstickService) {
				((BlinkstickService)notification).AccessCodeChanged -= HandleAccessCodeChanged;
			}
		}
		public override void CopyProperties (CustomNotification source)
		{
			base.CopyProperties (source);

			if (source is GoogleEmailNotification) {
				this.Email = (source as GoogleEmailNotification).Email;
				this.Password = (source as GoogleEmailNotification).Password;
			}
		}
		public virtual void CopyProperties (CustomNotification source)
		{
			this.Name = source.Name;
			this.Id = source.Id;
			this.BlinkSpeed = source.BlinkSpeed;
			this.Active = source.Active;
			this.Priority = source.Priority;
			this.Color = source.Color;
			this.NotificationType = source.NotificationType;
			this.BlinkCount = source.BlinkCount;
			this.Enabled = source.Enabled;
		}