Exemplo n.º 1
0
        public static void CloseAllRtcForms() //This allows every form to get closed to prevent RTC from hanging
        {
            if (isClosing)
            {
                return;
            }

            isClosing = true;

            foreach (Form frm in UICore.AllColorizedSingletons())
            {
                if (frm != null)
                {
                    frm.Close();
                }
            }

            if (S.GET <RTC_Standalone_Form>() != null)
            {
                S.GET <RTC_Standalone_Form>().Close();
            }

            //Clean out the working folders
            if (!CorruptCore.RtcCore.DontCleanSavestatesOnQuit)
            {
                Stockpile.EmptyFolder("WORKING");
            }

            Environment.Exit(0);
        }
Exemplo n.º 2
0
        public static void SetRTCColor(Color color, Control ctr = null)
        {
            HashSet <Control> allControls = new HashSet <Control>();

            if (ctr == null)
            {
                foreach (Form targetForm in UICore.AllColorizedSingletons())
                {
                    if (targetForm != null)
                    {
                        foreach (var c in targetForm.Controls.getControlsWithTag())
                        {
                            allControls.Add(c);
                        }
                        allControls.Add(targetForm);
                    }
                }

                //Get the extraforms
                foreach (UI_CanvasForm targetForm in UI_CanvasForm.extraForms)
                {
                    foreach (var c in targetForm.Controls.getControlsWithTag())
                    {
                        allControls.Add(c);
                    }
                    allControls.Add(targetForm);
                }

                //We have to manually add the etform because it's not singleton, not an extraForm, and not owned by any specific form
                //Todo - Refactor this so we don't need to add it separately
                if (mtForm != null)
                {
                    foreach (var c in mtForm.Controls.getControlsWithTag())
                    {
                        allControls.Add(c);
                    }
                    allControls.Add(mtForm);
                }
            }
            else if (ctr is Form || ctr is UserControl)
            {
                foreach (var c in ctr.Controls.getControlsWithTag())
                {
                    allControls.Add(c);
                }
                allControls.Add(ctr);
            }
            else if (ctr is Form)
            {
                allControls.Add(ctr);
            }

            float generalDarken = -0.50f;
            float light1        = 0.10f;
            float light2        = 0.45f;
            float dark1         = -0.20f;
            float dark2         = -0.35f;
            float dark3         = -0.50f;
            float dark4         = -0.85f;

            color = color.ChangeColorBrightness(generalDarken);

            Light1Color = color.ChangeColorBrightness(light1);
            Light2Color = color.ChangeColorBrightness(light2);
            NormalColor = color;
            Dark1Color  = color.ChangeColorBrightness(dark1);
            Dark2Color  = color.ChangeColorBrightness(dark2);
            Dark3Color  = color.ChangeColorBrightness(dark3);
            Dark4Color  = color.ChangeColorBrightness(dark4);

            var tag2ColorDico = new Dictionary <string, Color>
            {
                { "color:light2", Light2Color },
                { "color:light1", Light1Color },
                { "color:normal", NormalColor },
                { "color:dark1", Dark1Color },
                { "color:dark2", Dark2Color },
                { "color:dark3", Dark3Color },
                { "color:dark4", Dark4Color }
            };

            foreach (var c in allControls)
            {
                var tag = c.Tag?.ToString().Split(' ');

                if (tag == null || tag.Length == 0)
                {
                    continue;
                }

                //Snag the tag and look for the color.
                var ctag = tag.FirstOrDefault(x => x.Contains("color:"));

                //We didn't find a valid color
                if (ctag == null || !tag2ColorDico.TryGetValue(ctag, out Color _color))
                {
                    continue;
                }

                if (c is Label l && l.BackColor != Color.FromArgb(30, 31, 32))
                {
                    c.ForeColor = _color;
                }