//mxd
        private void flags_OnValueChanged(object sender, EventArgs e)
        {
            if (preventchanges)
            {
                return;
            }

            // Gather enabled flags
            HashSet <string> activeflags = new HashSet <string>();

            foreach (CheckBox cb in flags.Checkboxes)
            {
                if (cb.CheckState != CheckState.Unchecked)
                {
                    activeflags.Add(cb.Tag.ToString());
                }
            }

            // Check em
            List <string> warnings = ThingFlagsCompare.CheckFlags(activeflags);

            if (warnings.Count > 0)
            {
                //got missing flags
                tooltip.SetToolTip(missingflags, string.Join(Environment.NewLine, warnings.ToArray()));
                missingflags.Visible    = true;
                settingsgroup.ForeColor = Color.DarkRed;
                return;
            }

            //everything is OK
            missingflags.Visible    = false;
            settingsgroup.ForeColor = SystemColors.ControlText;
        }
        // This runs the check
        public override void Run()
        {
            int progress     = 0;
            int stepprogress = 0;

            // Go for all things
            foreach (Thing t in General.Map.Map.Things)
            {
                // Gather enabled flags
                HashSet <string> activeflags = new HashSet <string>();
                foreach (KeyValuePair <string, bool> group in t.GetFlags())
                {
                    if (group.Value)
                    {
                        activeflags.Add(group.Key);
                    }
                }

                // Check em
                List <string> warnings = ThingFlagsCompare.CheckFlags(activeflags);
                if (warnings.Count > 0)
                {
                    // Got missing flags
                    SubmitResult(new ResultUnusedThing(t, string.Join(" ", warnings.ToArray())));
                }

                // Handle thread interruption
                try { Thread.Sleep(0); } catch (ThreadInterruptedException) { return; }

                // We are making progress!
                if ((++progress / PROGRESS_STEP) > stepprogress)
                {
                    stepprogress = (progress / PROGRESS_STEP);
                    AddProgress(1);
                }
            }
        }
        private void flags_OnValueChanged(object sender, EventArgs e)
        {
            if (preventchanges)
            {
                return;
            }
            if (!preventmapchange)            //mxd
            {
                MakeUndo();
                int i = 0;

                // Apply flags
                foreach (Thing t in things)
                {
                    // Apply all flags
                    foreach (CheckBox c in flags.Checkboxes)
                    {
                        if (c.CheckState == CheckState.Checked)
                        {
                            t.SetFlag(c.Tag.ToString(), true);
                        }
                        else if (c.CheckState == CheckState.Unchecked)
                        {
                            t.SetFlag(c.Tag.ToString(), false);
                        }
                        else if (thingprops[i].Flags.ContainsKey(c.Tag.ToString()))
                        {
                            t.SetFlag(c.Tag.ToString(), thingprops[i].Flags[c.Tag.ToString()]);
                        }
                        else                         //things created in the editor have empty Flags by default
                        {
                            t.SetFlag(c.Tag.ToString(), false);
                        }
                    }

                    i++;
                }

                // Dispatch event
                General.Map.IsChanged = true;
                if (OnValuesChanged != null)
                {
                    OnValuesChanged(this, EventArgs.Empty);
                }
            }

            // Gather enabled flags
            HashSet <string> activeflags = new HashSet <string>();

            foreach (CheckBox cb in flags.Checkboxes)
            {
                if (cb.CheckState != CheckState.Unchecked)
                {
                    activeflags.Add(cb.Tag.ToString());
                }
            }

            // Check em
            List <string> warnings = ThingFlagsCompare.CheckFlags(activeflags);

            if (warnings.Count > 0)
            {
                // Got missing flags
                tooltip.SetToolTip(missingflags, string.Join(Environment.NewLine, warnings.ToArray()));
                missingflags.Visible    = true;
                settingsgroup.ForeColor = Color.DarkRed;
                return;
            }

            // Everything is OK
            missingflags.Visible    = false;
            settingsgroup.ForeColor = SystemColors.ControlText;
        }