Example #1
0
        protected void Initialize()
        {
            /*  _threadSafety = new ThreadSafetyEnforcer("Main Window Class");
             * _invoker = new Invoker(_threadSafety); */

            if (AvailableScreens == null)
            {
                throw new Exception("AvailableScreens not set!");
            }

            foreach (var screen in AvailableScreens)
            {
                screen.Value.Initialize();
            }

            if (!AvailableScreens.ContainsKey("MainMenu"))
            {
                throw new Exception("MainMenu not set!");
            }

            this.FormClosing += MainForm_FormClosing;

            CurrentScreen = AvailableScreens["MainMenu"];
            CurrentScreen.Load();
            ScreenChanged?.Invoke(this, EventArgs.Empty);

            this.Show();
        }
Example #2
0
        private void SelectCurrentTheme()
        {
            var curr = AvailableScreens.FirstOrDefault(ls => ls.Filename.Contains(Configuration.CurrentSelectedTheme));

            if (curr != null)
            {
                SelectedTheme = curr;
                OnPropertyChanged(x => x.SelectedTheme);
            }
        }
Example #3
0
        /// <summary>
        /// Change to the screen name listed. The screenName should be an item in the AvailableScreens.
        /// </summary>
        public void ChangeToScreen(string screenName)
        {
            //The InvokeMethod will run it right away if this is the correct thread.

            InvokeMethod((object nothing) =>
            {
                if (!AvailableScreens.ContainsKey(screenName))
                {
                    throw new Exception(string.Format("{0} does not exist!", screenName));
                }
                CurrentScreen.Unload();
                CurrentScreen = AvailableScreens[screenName];

                CurrentScreen.Load();
                ScreenChanged?.Invoke(this, EventArgs.Empty);
            }, null);
        }
Example #4
0
        public MainViewModel()
        {
            AvailableScreens = Screen.AllScreens;

            BackgroundColor = Properties.Settings.Default.Background;
            ForegroundColor = Properties.Settings.Default.Foregound;
            SelectedFont    = Properties.Settings.Default.Font;

            SelectedScreen = AvailableScreens.FirstOrDefault(x => x.DeviceName == Properties.Settings.Default.Display);
            if (SelectedScreen == null)
            {
                SelectedScreen = AvailableScreens.First();
            }

            CountdownTime         = new DateTime(2000, 1, 1, 0, 5, 0);
            StartPauseTimer       = true;
            SelectedDisplayFormat = "hh:mm";
            Mode = false;
        }
        /// <summary>
        /// Enters a new media navigation context by modifying the list of available screens. This is used for
        /// presenting the result of a filter, where the menu must be changed.
        /// </summary>
        /// <param name="subViewSpecification">Specification for the sub view to be shown in the new navigation context.</param>
        /// <param name="currentMenuItemLabel">Current menu item label needed for distinction of available screens.</param>
        /// <param name="navbarDisplayLabel">Display label to be shown in the navigation bar for the new navigation context.</param>
        /// <returns>Newly created navigation data.</returns>
        public NavigationData StackAutonomousNavigationContext(ViewSpecification subViewSpecification, string currentMenuItemLabel, string navbarDisplayLabel)
        {
            AbstractScreenData currentScreen = AvailableScreens.FirstOrDefault(screen => screen.MenuItemLabel == currentMenuItemLabel);
            ICollection <AbstractScreenData> remainingScreens = new List <AbstractScreenData>(AvailableScreens.Where(screen => screen != currentScreen));

            WorkflowState newState = WorkflowState.CreateTransientState(
                "View: " + subViewSpecification.ViewDisplayName, subViewSpecification.ViewDisplayName,
                false, null, false, WorkflowType.Workflow, null);

            string             nextScreenName;
            AbstractScreenData nextScreen = null;

            // Try to load the prefered next screen from settings.
            if (LoadScreenHierarchy(CurrentScreenData.GetType().ToString(), out nextScreenName))
            {
                nextScreen = remainingScreens.FirstOrDefault(s => s.GetType().ToString() == nextScreenName);
            }

            // Default way: always take the first of the available screens.
            if (nextScreen == null)
            {
                nextScreen = remainingScreens.First(s => s != currentScreen);
            }

            ScreenConfig nextScreenConfig;

            LoadLayoutSettings(nextScreen.GetType().ToString(), out nextScreenConfig);

            Sorting.Sorting nextSortingMode = AvailableSortings.FirstOrDefault(
                sorting => sorting.GetType().ToString() == nextScreenConfig.Sorting && sorting.IsAvailable(nextScreen)) ?? _currentSorting;
            Sorting.Sorting nextGroupingMode = String.IsNullOrEmpty(nextScreenConfig.Grouping) ? null : AvailableGroupings.FirstOrDefault(
                grouping => grouping.GetType().ToString() == nextScreenConfig.Grouping && grouping.IsAvailable(nextScreen)) ?? _currentGrouping;

            NavigationData newNavigationData = new NavigationData(this, subViewSpecification.ViewDisplayName,
                                                                  newState.StateId, newState.StateId, subViewSpecification, nextScreen, remainingScreens,
                                                                  nextSortingMode, nextGroupingMode)
            {
                LayoutType = nextScreenConfig.LayoutType, LayoutSize = nextScreenConfig.LayoutSize
            };

            PushNewNavigationWorkflowState(newState, navbarDisplayLabel, newNavigationData);
            return(newNavigationData);
        }
Example #6
0
 /// <summary>
 /// Change to the screen name listed. The screenName should be an item in the AvailableScreens.
 /// </summary>
 public void ChangeToScreen(string screenName)
 {
     //The lambda expression keeps the name in scope
     //so no worried there, i hope...
     //The InvokeMethod will run it right away if this is the correct thread.
     System.Action <object> id = (object nothing) =>
     {
         if (!AvailableScreens.ContainsKey(screenName))
         {
             throw new Exception(string.Format("{0} does not exist!", screenName));
         }
         if (ScreenLoaded())
         {
             CurrentScreen.Unload();
         }
         CurrentScreen = AvailableScreens[screenName];
         CurrentScreen.Load();
         ScreenChanged?.Invoke(this, EventArgs.Empty);
     };
     InvokeMethod(id, null);
 }
Example #7
0
 public void LoadScreen(AvailableScreens pScreen)
 {
     if (m_bAllLoaded)
     {
         m_bAllLoaded = false;
         switch (pScreen)
         {
             case AvailableScreens.TITLE:
                 m_pScreenToLoad = new TitleScreen(this);
                 break;
             case AvailableScreens.HIGHSCORE:
                 m_pScreenToLoad = new HighScoreScreen(this);
                 break;
             case AvailableScreens.GAMEOVER:
                 m_pScreenToLoad = new GameOverScreen(this);
                 break;
             case AvailableScreens.GAMEPLAY:
                 m_pScreenToLoad = new GameplayScreen(this);
                 break;
             case AvailableScreens.MAINMENU:
                 m_pScreenToLoad = new MainMenuScreen(this);
                 break;
             case AvailableScreens.OPTIONS:
                 m_pScreenToLoad = new OptionsScreen(this);
                 break;
         }
         ThreadPool.QueueUserWorkItem(new WaitCallback(LoadScreenContent));
     }
     else
     {
         Console.WriteLine("SCREENS IS ALREADY LOADING! PLEASE WAIT");
     }
 }