예제 #1
0
        //mxd
        private void buttonselectioneffects_Click(object sender, EventArgs e)
        {
            BuilderPlug.Me.ViewSelectionEffects = buttonselectioneffects.Checked;

            // Notify current mode
            BaseClassicMode mode = General.Editing.Mode as BaseClassicMode;

            if (mode != null)
            {
                mode.OnViewSelectionEffectsChanged(BuilderPlug.Me.ViewSelectionEffects);
            }

            General.Interface.RedrawDisplay();
            General.Interface.DisplayStatus(StatusType.Info, (buttonselectioneffects.Checked ?
                                                              "Show sector tags and effects" :
                                                              "Don't show sector tags and effects"));
        }
        public bool Setup(BaseClassicMode mode)
        {
            this.mode = mode;

            //which tabs should we display?
            TabPage[] activetabs = null;
            if (General.Editing.Mode is ThingsMode)
            {
                if (General.Map.Map.GetSelectedThings(true).Count == 0)
                {
                    return(SetupFailed("This action requires selection..."));
                }
                activetabs = new[] { things };
            }
            else if (General.Editing.Mode is VerticesMode && General.Map.UDMF)
            {
                if (General.Map.Map.GetSelectedVertices(true).Count == 0)
                {
                    return(SetupFailed("This action requires selection..."));
                }
                activetabs = new[] { vertices };
            }
            else if (General.Editing.Mode is LinedefsMode)
            {
                if (General.Map.Map.GetSelectedLinedefs(true).Count == 0)
                {
                    return(SetupFailed("This action requires selection..."));
                }
                activetabs = new[] { linedefs, sidedefs };
            }
            else if (mode is SectorsMode)
            {
                if (General.Map.Map.GetSelectedSectors(true).Count == 0)
                {
                    return(SetupFailed("This action requires selection..."));
                }
                activetabs = new[] { sectors };
            }

            if (activetabs == null)
            {
                return(SetupFailed("This action doesn't support current editing mode..."));
            }

            //fill flags
            showntabs = new List <TabPage>();
            int maxheight = int.MinValue;

            foreach (TabPage page in activetabs)
            {
                CheckboxArrayControl curControl = page.Controls[0] as CheckboxArrayControl;
                if (curControl == null)
                {
                    continue;                                    //just a piece of boilerplate...
                }
                FieldInfo[] props = typecontrols[curControl].GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
                foreach (var prop in props)
                {
                    foreach (Attribute attr in Attribute.GetCustomAttributes(prop))
                    {
                        if (attr.GetType() == typeof(FieldDescription))
                        {
                            FieldDescription fd = (FieldDescription)attr;
                            if (fd.SupportsCurrentMapFormat)
                            {
                                curControl.Add(fd.Description, prop.Name).Checked = (bool)prop.GetValue(typecontrols[curControl]);
                            }
                        }
                    }
                }

                if (curControl.Checkboxes.Count > 0)
                {
                    curControl.PositionCheckboxes();
                    showntabs.Add(page);

                    // Store height
                    maxheight = Math.Max(maxheight, curControl.GetHeight());
                }
            }

            // Apply height
            if (maxheight != int.MinValue)
            {
                this.Height += maxheight - activetabs[0].Controls[0].Height;
            }

            // Got anything to show?
            if (showntabs.Count == 0)
            {
                return(SetupFailed("This action doesn't support current editing mode..."));
            }

            // Hide unused tab pages
            tabControl.TabPages.Clear();
            tabControl.TabPages.AddRange(showntabs.ToArray());
            tabControl.SelectTab(showntabs[0]);

            return(true);
        }