示例#1
0
        public T GetViewControl <T>(string vcKey = "") where T : UserControl, new()
        {
            T rst = null;

            if (ViewControls != null)
            {
                string typekey = GetViewControlKey(typeof(T), vcKey);
                if (ViewControls.ContainsKey(typekey) && ViewControls[typekey] != null)
                {
                    rst = ViewControls[typekey] as T;
                }
            }
            return(rst);
        }
示例#2
0
        private void UnRegisterRelationUserControl(ref UserControl uc, string vcKey, bool isUnRegisterVM)
        {
            if (uc == null)
            {
                return;
            }
            string uctypekey = GetViewControlKey(uc.GetType(), vcKey);
            var    ucchilds  = uc.Descendents();

            foreach (UserControl t in ucchilds.OfType <UserControl>())
            {
                UserControl t2    = t;
                string      t2key = GetViewControlKey(t2.GetType(), vcKey);
                UnRegisterRelationUserControl(ref t2, vcKey, isUnRegisterVM);
                if (t2 != null)
                {
                    if (t2.DataContext != null)
                    {
                        if (isUnRegisterVM)
                        {
                            if (t2.DataContext is ViewModelBase)
                            {
                                ViewModelLocator.Instance.UnRegisterViewModel(t2.DataContext.GetType(), vcKey);
                            }
                        }
                        t2.DataContext = null;
                    }
                    if (t2.Content != null)
                    {
                        GC.SuppressFinalize(t2.Content);
                        t2.Content = null;
                    }
                }
                if (ViewControls.ContainsKey(t2key))
                {
                    ViewControls.Remove(t2key);
                }
                if (t2 != null)
                {
                    GC.SuppressFinalize(t2);
                }
            }
        }
示例#3
0
        private void InnerUnRegisterUI(Type type, string vcKey, bool isUnRegisterVM)
        {
            string vcTypeKey = GetViewControlKey(type, vcKey);

            if (ViewControls.ContainsKey(vcTypeKey))
            {
                object t = ViewControls[vcTypeKey];
                if (t != null)
                {
                    if (t is UserControl)
                    {
                        #region  usercontrol
                        UserControl uc = t as UserControl;
                        UnRegisterRelationUserControl(ref uc, vcKey, isUnRegisterVM);
                        if (uc.Content != null)
                        {
                            GC.SuppressFinalize(uc.Content);
                            uc.Content = null;
                        }
                        if (uc.DataContext != null)
                        {
                            if (isUnRegisterVM)
                            {
                                if (uc.DataContext is ViewModelBase)
                                {
                                    ViewModelLocator.Instance.UnRegisterViewModel(uc.DataContext.GetType(), vcKey);
                                }
                            }
                            uc.DataContext = null;
                        }
                        #endregion
                    }
                }
                ViewControls.Remove(vcTypeKey);
                if (t != null)
                {
                    GC.SuppressFinalize(t);
                }
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
示例#4
0
        public Settings(InputManager iM, int playerOneIndex, int playerTwoIndex)
        {
            p1Up     = SettingsManager.p1MoveUp;
            p1Down   = SettingsManager.p1MoveDown;
            p1Select = SettingsManager.p1PowerUp;
            p1Start  = SettingsManager.p1Start;

            p2Up     = SettingsManager.p2MoveUp;
            p2Down   = SettingsManager.p2MoveDown;
            p2Select = SettingsManager.p2PowerUp;
            p2Start  = SettingsManager.p2Start;

            settingsChoiceSwitcher = SettingsChoice.settings;

            CurrentSettingsChoice = 0;
            marginFromMenuObj     = SettingsManager.arrowsInMenuMaxX;
            arrowOneLeft          = new GameObject(Vector2.Zero, TextureManager.menuArrowLeft);
            arrowTwoLeft          = new GameObject(Vector2.Zero, TextureManager.menuArrowLeft);

            arrowOneRight = new GameObject(Vector2.Zero, TextureManager.menuArrowRight);
            arrowTwoRight = new GameObject(Vector2.Zero, TextureManager.menuArrowRight);

            configureGamePad = new GameObject(Vector2.Zero, TextureManager.settingsConfigureGamePad);
            viewControls     = new GameObject(Vector2.Zero, TextureManager.settingsViewControls);
            resetPreConfig   = new GameObject(Vector2.Zero, TextureManager.settingsShowPreConfig);

            if (SettingsManager.gamePadVersion)
            {
                menuObjs.Add(configureGamePad);
            }
            menuObjs.Add(viewControls);
            menuObjs.Add(resetPreConfig);

            AssignPos();

            showControls      = new ViewControls();
            configureGamePads = new ConfigureGamePads(iM, playerOneIndex, playerTwoIndex);
        }
示例#5
0
        private T innerRegisterUI <T>(string vcKey) where T : new()
        {
            T      rst;
            string typekey = GetViewControlKey(typeof(T), vcKey);

            if (ViewControls.ContainsKey(typekey))
            {
                if (ViewControls[typekey] != null)
                {
                    rst = (T)ViewControls[typekey];
                }
                else
                {
                    rst = CreateUserControl <T>();
                    ViewControls[typekey] = rst;
                }
            }
            else
            {
                rst = CreateUserControl <T>();
                ViewControls.Add(typekey, rst);
            }
            return(rst);
        }