Exemple #1
0
        public void TimerSetIcon(TimerTile timerTile, Appliance appl)
        {
            try
            {
                Storyboard sb = new Storyboard();

                DoubleAnimation FadeOut = new DoubleAnimation();
                FadeOut.Duration = new Duration(TimeSpan.FromMilliseconds(400));
                FadeOut.From = timerTile.ApplianceIcon.Opacity; ;
                FadeOut.To = 0.0;

                Storyboard.SetTarget(FadeOut, timerTile.ApplianceIcon);
                Storyboard.SetTargetProperty(FadeOut, "(Image.Opacity)");
                sb.Children.Add(FadeOut);
                sb.Completed += (sendr, e) =>
                {
                   
                    Storyboard sbFadeIn = new Storyboard();
                    DoubleAnimation FadeIn = new DoubleAnimation();
                    FadeIn.Duration = new Duration(TimeSpan.FromMilliseconds(400));
                    FadeIn.From = 0.0;
                    FadeIn.To = 1.0;
                    timerTile.ApplianceIcon.Source = ApplianceIconFromType(appl.Type).Source;

                    Storyboard.SetTarget(FadeIn, timerTile.ApplianceIcon);
                    Storyboard.SetTargetProperty(FadeIn, "(Image.Opacity)");
                    sbFadeIn.Children.Add(FadeIn);
                    sbFadeIn.Begin();
                };
                sb.Begin();
            }
            catch (Exception ex)
            {
                logException(ex);
            }
        }
Exemple #2
0
        private async void ApplyTime(Appliance appl)
        {
            try
            {
                await mMainPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
                {
                    TimerTile timerTile = (TimerTile)mMainPage.FindName(appl.Name);

                    if (appl.Time.TotalSeconds == 0)
                    {
                        appl.IsRunning = false;
                        SentToast(appl.FullName, appl.Phrase);
                        appl = ApplianceDefaults(appl.Type);
                        TimerSetTime(timerTile, appl.Time);
                    }
                    else
                    {
                        TimerSetTime(timerTile, appl.Time);
                    }

                    timerTile = null;
                });
            }
            catch (Exception ex)
            {
                logException(ex);
            }
        }
Exemple #3
0
        public void TimerAdd(Appliance.ApplianceType Type)
        {
            try
            {
                double dTop = 0;
                Appliance newAppliance = ApplianceByType(Type);
                TimerTile timerTile = new TimerTile(this.TileColor, this.ApplianceIconFromType(Type), mMainPage);
                timerTile.Width = this.mMainPage.ActualWidth;
                timerTile.Height = this.mdTileSize;
                timerTile.Name = newAppliance.Name;

                TimerSetTime(timerTile, newAppliance.Time);

                Appliances.Add(newAppliance);

                if (Appliances.Count > 1)
                {
                    dTop = ((Appliances.Count - 1) * this.mdTileSize);
                    TimerTile tile = (TimerTile)this.mMainPage.Timers.Children[(this.mMainPage.Timers.Children.Count - 1)];
                    GeneralTransform transform = tile.TransformToVisual(mMainPage.Timers);
                    Point controlPosition = transform.TransformPoint(new Point(0, 0));

                    dTop = (controlPosition.Y + this.mdTileSize);
                }

                this.mMainPage.Timers.Children.Add(timerTile); //Must be after the check of top, just above here

                TimerMove(timerTile, this.mMainPage.ActualHeight, dTop);

                //Cleanup
                newAppliance = null;
                timerTile = null;
            }
            catch (Exception ex)
            {
                logException(ex);
            }
        }
Exemple #4
0
        private Appliance ApplianceDefaults(Appliance.ApplianceType Type)
        {
            Appliance appliance = new Appliance();
            appliance.Type = Type;

            try
            {
                switch (Type)
                {
                    case Appliance.ApplianceType.ClothesDryer:
                        appliance.FullName = "Clothes Dryer";
                        appliance.Phrase = "The clothes are dry";
                        appliance.Time = new TimeSpan(1, 0, 0);
                        break;

                    case Appliance.ApplianceType.EggTimer:
                        appliance.FullName = "Egg Timer";
                        appliance.Phrase = "Timer dinged";
                        appliance.Time = new TimeSpan(0, 5, 0);
                        break;

                    case Appliance.ApplianceType.Fridge:
                        appliance.FullName = "Refrigerator";
                        appliance.Phrase = "Somethings chilling";
                        appliance.Time = new TimeSpan(0, 120, 0);
                        break;

                    case Appliance.ApplianceType.Microwave:
                        appliance.FullName = "Microwave";
                        appliance.Phrase = "Atomic Beep Beep";
                        appliance.Time = new TimeSpan(0, 10, 0);
                        break;

                    case Appliance.ApplianceType.Oven:
                        appliance.FullName = "Oven";
                        appliance.Phrase = "Oven is hot";
                        appliance.Time = new TimeSpan(0, 25, 0);
                        break;

                    case Appliance.ApplianceType.Stove:
                        appliance.FullName = "Stove";
                        appliance.Phrase = "Stove needs attention";
                        appliance.Time = new TimeSpan(0, 15, 0);
                        break;

                    case Appliance.ApplianceType.TV:
                        appliance.FullName = "TV / Computer";
                        appliance.Phrase = "Pay attention to this device";
                        appliance.Time = new TimeSpan(1, 0, 0);
                        break;

                    case Appliance.ApplianceType.WashingMachine:
                        appliance.FullName = "Washing Machine";
                        appliance.Phrase = "The wash is done";
                        appliance.Time = new TimeSpan(0, 38, 0);
                        break;
                }
            }
            catch (Exception ex)
            {
                logException(ex);
            }

            return appliance;
        }
Exemple #5
0
        private Appliance ApplianceFromCSV(string Input)
        {
            Appliance appliance = new Appliance();

            try
            {
                string[] Values = Input.Split(',');

                appliance.Type = this.ApplianceTypeFromType(Values[0]);
                appliance.Time = new TimeSpan(0, Convert.ToInt16(Values[1]), 0);
                appliance.FullName = Values[2];
                appliance.Phrase = Values[3];

            }
            catch (Exception ex)
            {
                logException(ex);
            }

            return appliance;
        }
Exemple #6
0
        public Image ApplianceIconFromType(Appliance.ApplianceType Type)
        {
            Image Return = new Image();
            string sIcon = "Egg_Timer";

            try
            {
                switch (Type)
                {
                    case Appliance.ApplianceType.ClothesDryer:
                        sIcon = "Clothes-Dryer";
                        break;

                    case Appliance.ApplianceType.EggTimer:
                        sIcon = "Egg_Timer";
                        break;

                    case Appliance.ApplianceType.Fridge:
                        sIcon = "Fridge";
                        break;

                    case Appliance.ApplianceType.Microwave:
                        sIcon = "Microwave";
                        break;

                    case Appliance.ApplianceType.Oven:
                        sIcon = "Oven";
                        break;

                    case Appliance.ApplianceType.Stove:
                        sIcon = "Stove";
                        break;

                    case Appliance.ApplianceType.TV:
                        sIcon = "TV";
                        break;

                    case Appliance.ApplianceType.WashingMachine:
                        sIcon = "Washing_Machine";
                        break;
                }

                Return.Source = new BitmapImage(new Uri("ms-appx:///Assets/" + sIcon + ".png", UriKind.Absolute));
            }
            catch (Exception ex)
            {
                logException(ex);
            }

            return Return;
        }
Exemple #7
0
        public Appliance ApplianceByType(Appliance.ApplianceType Type)
        {
            Appliance appliance = new Appliance();

            try
            {
                bool bFound = false;
                List<string> ApplianceValues = new List<string>();
                var tempValues = ((string[])ApplicationData.Current.LocalSettings.Values["ApplianceValues"]);

                if (tempValues != null)
                {
                    ApplianceValues = tempValues.ToList();

                    if (ApplianceValues.Count > 0)
                    {
                        string sValue = ApplianceValues.Find(e => (e.IndexOf(Type.ToString()) > -1));

                        if (sValue != null)
                        {
                            appliance = ApplianceFromCSV(sValue);
                            bFound = true;
                        }
                    }
                }


                if (bFound == false)
                {
                    appliance = ApplianceDefaults(Type);
                    ApplianceValues.Add(appliance.Type.ToString() + "," + appliance.Time.TotalMinutes.ToString() + "," + appliance.FullName + "," + appliance.Phrase);
                    ApplicationData.Current.LocalSettings.Values["ApplianceValues"] = ApplianceValues.ToArray();
                }
            }
            catch (Exception ex)
            {
                logException(ex);
            }

            return appliance;
        }