Example #1
0
        public void GetRegistrySettings()
        {
            RegistryKey UserPrefs = Registry.CurrentUser.OpenSubKey("SOFTWARE\\INTEGRetroScreenSaver", true);
            String      TrollName;

            if (UserPrefs != null)
            {
                _nMoveInterval = Int32.Parse((string)UserPrefs.GetValue("nMoveInterval"));
                _nSteps        = Int32.Parse((string)UserPrefs.GetValue("nSteps"));
                _nTrolls       = Int32.Parse((string)UserPrefs.GetValue("nTrolls"));

                _trolls = new Troll[_nTrolls];
                for (int i = 0; i < _nTrolls; i++)
                {
                    // name, X, Y, direction, no. of colours, color options
                    TrollName = "Troll" + i.ToString();
                    Color first, second, third;

                    first  = Color.FromArgb(Int32.Parse((string)UserPrefs.GetValue(TrollName + "_color0")));
                    second = Color.FromArgb(Int32.Parse((string)UserPrefs.GetValue(TrollName + "_color1")));
                    third  = Color.FromArgb(Int32.Parse((string)UserPrefs.GetValue(TrollName + "_color2")));

                    _trolls[i] = new Troll(
                        (string)UserPrefs.GetValue(TrollName + "_name"),
                        Int32.Parse((string)UserPrefs.GetValue(TrollName + "_startX")),
                        Int32.Parse((string)UserPrefs.GetValue(TrollName + "_startY")),
                        (Troll.MoveDir)(Int32.Parse((string)UserPrefs.GetValue(TrollName + "_startdir"))),
                        _nSteps,
                        first, second, third
                        );
                }
            }
            else
            {
                RegistryKey newKey = Registry.CurrentUser.OpenSubKey("SOFTWARE", true);
                newKey.CreateSubKey("INTEGRetroScreenSaver");

                SetDefaults();
                SetRegistrySettings();
            }
        }
Example #2
0
        public void RemoveTroll(string HeWhoShallNotBeNamed)
        {
            Troll[] newtrolls = new Troll[_nTrolls - 1];
            int     HeWhoShallNotBeNamedsNumber = -1;
            int     j = 0;

            for (int i = 0; i < _nTrolls; i++)
            {
                if (_trolls[i].Name != HeWhoShallNotBeNamed)
                {
                    newtrolls[j] = _trolls[i];
                    j++;
                }
                else
                {
                    HeWhoShallNotBeNamedsNumber = i;
                }
            }

            if (HeWhoShallNotBeNamedsNumber == -1)
            {
                return;
            }

            RegistryKey UserPrefs = Registry.CurrentUser.OpenSubKey("SOFTWARE\\INTEGRetroScreenSaver", true);

            if (UserPrefs != null)
            {
                String TrollName = "Troll" + HeWhoShallNotBeNamedsNumber.ToString();

                ClearRegistrySettings();
                SetRegistrySettings();
            }

            _trolls = new Troll[_nTrolls - 1];
            _trolls = newtrolls;
            _nTrolls--;
        }