Esempio n. 1
0
        // Called from the glow control when a program should be added or removed.
        public void ToggleProgram(GlowPrograms program, bool enable)
        {
            lock (m_programModifications)
            {
                // Add it to the list of pending changes, this will be updated on the next tick.
                m_programModifications.Add(new KeyValuePair <GlowPrograms, bool>(program, enable));
            }

            // Prevent programs from doing work if we need to change them.
            m_stopWorkAndLoop = true;
        }
Esempio n. 2
0
        /// <summary>
        /// Called by the main page when a program asks if it is enabled
        /// </summary>
        /// <param name="program"></param>
        /// <returns></returns>
        public bool IsProgramEnabled(GlowPrograms program)
        {
            if (m_settings == null)
            {
                return(false);
            }

            if (m_settings.ProgramStateList.ContainsKey(program) && m_settings.ProgramStateList[program] == GlowControlSettings.ProgramState.Eligible)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// Called by the main page when a program asks if it is enabled
        /// </summary>
        /// <param name="program"></param>
        /// <returns></returns>
        public bool IsProgramEnabled(GlowPrograms program)
        {
            if(m_settings == null)
            {
                return false;
            }

            if(m_settings.ProgramStateList.ContainsKey(program) && m_settings.ProgramStateList[program] == GlowControlSettings.ProgramState.Eligible)
            {
                return true;
            }
            return false;
        }
Esempio n. 4
0
        /// <summary>
        /// Called by the control when a program is toggled.
        /// </summary>
        /// <param name="program"></param>
        /// <param name="enabled"></param>
        public void ToggleProgram(GlowPrograms program, bool enabled)
        {
            if (m_settings == null)
            {
                // Since we can't do it, fire this so it will be toggled back.
                m_listener.OnEnabledProgramsChanged();
                return;
            }

            // Update the program
            m_settings.ProgramStateList[program] = enabled ? GlowControlSettings.ProgramState.Eligible : GlowControlSettings.ProgramState.Disabled;

            // Send updated settings
            SendUpdatedSettings();
        }
Esempio n. 5
0
        /// <summary>
        /// Called by the control when a program is toggled.
        /// </summary>
        /// <param name="program"></param>
        /// <param name="enabled"></param>
        public void ToggleProgram(GlowPrograms program, bool enabled)
        {
            if(m_settings == null)
            {
                // Since we can't do it, fire this so it will be toggled back.
                m_listener.OnEnabledProgramsChanged();
                return;
            }

            // Update the program
            m_settings.ProgramStateList[program] = enabled ? GlowControlSettings.ProgramState.Eligible : GlowControlSettings.ProgramState.Disabled;

            // Send updated settings
            SendUpdatedSettings();
        }
Esempio n. 6
0
        private void AnimContentGrid_Completed(object sender, object e)
        {
            if (m_programToSwtich != GlowPrograms.None)
            {
                // Switch and fade in
                ui_contentGrid.Children.Clear();
                ui_contentGrid.Children.Add((UIElement)m_paneControls[m_programToSwtich]);
                m_programToSwtich = GlowPrograms.None;

                ui_animContentGrid.From = 0;
                ui_animContentGrid.To   = 1;
                ui_storyContentGrid.Begin();

                // Side the side bar color
                UpdateProgramNavUI();
            }
        }
Esempio n. 7
0
        private void SetPane(GlowPrograms program)
        {
            if (!m_paneControls.ContainsKey(program))
            {
                throw new Exception("That program doesn't have a user control!");
            }

            // If we are already going get out of here.
            if (m_programToSwtich != GlowPrograms.None)
            {
                return;
            }

            // Cache the program
            m_programToSwtich = program;
            App.GlowBack.AppSetting.LastShownProgram = m_programToSwtich;

            // Fade out
            ui_animContentGrid.From = 1;
            ui_animContentGrid.To   = 0;
            ui_storyContentGrid.Begin();
            ui_spitView.IsPaneOpen = false;
        }
Esempio n. 8
0
 public Command(GlowPrograms program, uint messageId, string message)
 {
     Program = program;
     MessageId = messageId;
     Message = message;
 }
Esempio n. 9
0
 public bool IsProgramEnabled(GlowPrograms program)
 {
     return(m_activePrograms.ContainsKey(program));
 }
Esempio n. 10
0
        private void AnimContentGrid_Completed(object sender, object e)
        {
            if(m_programToSwtich != GlowPrograms.None)
            {
                // Switch and fade in
                ui_contentGrid.Children.Clear();
                ui_contentGrid.Children.Add((UIElement)m_paneControls[m_programToSwtich]);
                m_programToSwtich = GlowPrograms.None;

                ui_animContentGrid.From = 0;
                ui_animContentGrid.To = 1;
                ui_storyContentGrid.Begin();

                // Side the side bar color
                UpdateProgramNavUI();
            }
        }
Esempio n. 11
0
 /// <summary>
 /// Called by the programs to get their current state.
 /// </summary>
 /// <param name="program"></param>
 /// <returns></returns>
 public bool GetProgramState(GlowPrograms program)
 {
     return ((GlowControlPane)m_paneControls[GlowPrograms.GlowControl]).IsProgramEnabled(program);
 }
Esempio n. 12
0
 /// <summary>
 /// Called by a program when they want to toggle their state.
 /// </summary>
 /// <param name="program"></param>
 /// <param name="enable"></param>
 public void ToggleProgram(GlowPrograms program, bool enable)
 {
     ((GlowControlPane)m_paneControls[GlowPrograms.GlowControl]).ToggleProgram(program, enable);
     UpdateProgramNavUI();
 }
Esempio n. 13
0
 /// <summary>
 /// Called by a program when they want to toggle their state.
 /// </summary>
 /// <param name="program"></param>
 /// <param name="enable"></param>
 public void ToggleProgram(GlowPrograms program, bool enable)
 {
     ((GlowControlPane)m_paneControls[GlowPrograms.GlowControl]).ToggleProgram(program, enable);
     UpdateProgramNavUI();
 }
Esempio n. 14
0
        private void SetPane(GlowPrograms program)
        {
            if (!m_paneControls.ContainsKey(program))
            {
                throw new Exception("That program doesn't have a user control!");
            }

            // If we are already going get out of here.
            if (m_programToSwtich != GlowPrograms.None)
            {
                return;
            }

            // Cache the program
            m_programToSwtich = program;
            App.GlowBack.AppSetting.LastShownProgram = m_programToSwtich;

            // Fade out
            ui_animContentGrid.From = 1;
            ui_animContentGrid.To = 0;            
            ui_storyContentGrid.Begin();
            ui_spitView.IsPaneOpen = false;
        }
Esempio n. 15
0
        // Called from the glow control when a program should be added or removed.
        public void ToggleProgram(GlowPrograms program, bool enable)
        {
            lock(m_programModifications)
            {
                // Add it to the list of pending changes, this will be updated on the next tick.
                m_programModifications.Add(new KeyValuePair<GlowPrograms, bool>(program, enable));
            }

            // Prevent programs from doing work if we need to change them.
            m_stopWorkAndLoop = true;
        }
Esempio n. 16
0
 public Command(GlowPrograms program, uint messageId, string message)
 {
     Program   = program;
     MessageId = messageId;
     Message   = message;
 }
Esempio n. 17
0
        public void DoWork(uint timeElaspedMs)
        {
            // Subtract time remaining
            m_nextCycleTimeMs -= (int)timeElaspedMs;

            if (m_nextCycleTimeMs < 0)
            {
                // Set the intensity
                double   desiredIntensity = -1;
                TimeSpan now = DateTime.Now.TimeOfDay;
                // If the end time is greater than the start time, do the normal compare (start > currentTime > end)
                // If the end time is less than the start time, then if the current time is greater than the start time we are good, or if the current time is less than than end time we are good.
                if ((m_settings.SleepyTimeEnd.CompareTo(m_settings.SleepyTimeStart) > 0 && now.CompareTo(m_settings.SleepyTimeStart) > 0 && now.CompareTo(m_settings.SleepyTimeEnd) < 0) ||
                    (m_settings.SleepyTimeEnd.CompareTo(m_settings.SleepyTimeStart) < 0 && (now.CompareTo(m_settings.SleepyTimeStart) > 0 || now.CompareTo(m_settings.SleepyTimeEnd) < 0)))
                {
                    desiredIntensity = m_settings.SleepyTimeIntensity;
                }
                else
                {
                    desiredIntensity = m_settings.MasterIntensity;
                }

                // Clamp the intensity
                desiredIntensity = Math.Min(1.0, Math.Max(0, desiredIntensity));

                // Check to see if we need to update the intensity. Note we always want to do it now
                // if this was from a user action, but if not we don't want to do it if we are already
                // running the animation.
                if (desiredIntensity != m_controller.GetMasterIntensity() &&
                    (m_userActionCycle || !m_controller.IsMasterIntensityAnimating()))
                {
                    m_controller.AnimateMasterIntensity(desiredIntensity, m_userActionCycle ? new TimeSpan(0, 0, 0, 0, 200) : new TimeSpan(0, 0, 10));
                }

                GlowPrograms runningProgram = GlowPrograms.None;
                GlowPrograms nextProgram    = GlowPrograms.None;
                foreach (KeyValuePair <GlowPrograms, GlowControlSettings.ProgramState> programState in m_settings.ProgramStateList)
                {
                    // Forget about anything that is running in the background.
                    if (programState.Value != GlowControlSettings.ProgramState.Background)
                    {
                        // If we found a program, look for the next possible program to run.
                        if (runningProgram != GlowPrograms.None && programState.Value == GlowControlSettings.ProgramState.Eligible)
                        {
                            nextProgram = programState.Key;
                            break;
                        }

                        if (m_controller.IsProgramEnabled(programState.Key))
                        {
                            // We found the running program
                            runningProgram = programState.Key;
                        }
                    }
                }

                if (runningProgram != GlowPrograms.None)
                {
                    // We found the running, lets see if we have a next
                    if (nextProgram == GlowPrograms.None)
                    {
                        // We need to loop back through the first part of the loop to find the
                        // next program.
                        foreach (KeyValuePair <GlowPrograms, GlowControlSettings.ProgramState> programState in m_settings.ProgramStateList)
                        {
                            if (programState.Key == runningProgram)
                            {
                                // We looped all the way through and didn't find anything.
                                break;
                            }

                            if (programState.Value == GlowControlSettings.ProgramState.Eligible)
                            {
                                // We found a new program
                                nextProgram = programState.Key;
                                break;
                            }
                        }
                    }

                    if (nextProgram != GlowPrograms.None)
                    {
                        // We found the running and the next, switch it out!
                        m_controller.ToggleProgram(runningProgram, false);
                        m_controller.ToggleProgram(nextProgram, true);
                    }
                    else
                    {
                        // Check if this program should be running.
                        if (m_settings.ProgramStateList[runningProgram] != GlowControlSettings.ProgramState.Eligible)
                        {
                            // We need to stop this program and put the system to sleep.
                            m_controller.ToggleProgram(runningProgram, false);
                            GoToSleepState();
                        }
                    }
                }
                else
                {
                    // We didn't find anything running nor anything to be next. Loop through to see if we can find
                    // a program that we can run.
                    bool programFound = false;
                    foreach (KeyValuePair <GlowPrograms, GlowControlSettings.ProgramState> programState in m_settings.ProgramStateList)
                    {
                        if (programState.Value == GlowControlSettings.ProgramState.Eligible)
                        {
                            m_controller.ToggleProgram(programState.Key, true);
                            programFound = true;
                            break;
                        }
                    }

                    // If we didn't find anything we are off.
                    if (!programFound)
                    {
                        GoToSleepState();
                    }
                }

                // Reset the timers
                m_nextCycleTimeMs = (int)m_settings.ProgramCycleTimeMs;
                m_userActionCycle = false;
            }
        }
Esempio n. 18
0
 public bool IsProgramEnabled(GlowPrograms program)
 {
     return m_activePrograms.ContainsKey(program);
 }
Esempio n. 19
0
 /// <summary>
 /// Called by the programs to get their current state.
 /// </summary>
 /// <param name="program"></param>
 /// <returns></returns>
 public bool GetProgramState(GlowPrograms program)
 {
     return(((GlowControlPane)m_paneControls[GlowPrograms.GlowControl]).IsProgramEnabled(program));
 }