示例#1
0
        void IInitializable.Initialize()
        {
            m_controls = new XLEManipCtrls();

                // We could use another MEF container system to initialise the
                // tab pages for this control... But for now, this is a simple
                // way to get the behaviour we want.
            var manipulators = Globals.MEFContainer.GetExportedValues<IManipulator>();
            foreach (var m in manipulators) {
                var t = m as Terrain.TerrainManipulator;
                if (t!=null) {
                    var terrainCtrls = new XLENativeManipControls();
                    terrainCtrls.Dock = DockStyle.Fill;
                    terrainCtrls.SetActiveContext(t.ManipulatorContext);

                    var terrainPage = new TabPage("Terrain");
                    terrainPage.Tag = m;
                    terrainPage.Controls.Add(terrainCtrls);
                    m_controls.m_tabControl.TabPages.Add(terrainPage);
                }

                var s = m as Placements.ScatterPlaceManipulator;
                if (s != null) {
                    var properties = new XLEScatterPlaceControls();
                    properties.Dock = DockStyle.Fill;
                    properties.Object = s.ManipulatorContext;

                    properties.SaveEvent = delegate(object o, string fn)
                        {
                            try
                            {
                                var settings = o as Placements.ScatterPlaceManipulator.ManipulatorSettings;
                                if (settings != null)
                                    settings.SaveModelList(fn);
                            }
                            catch { MessageBox.Show("Error while saving model list"); }
                        };

                    properties.LoadEvent = delegate(object o, string fn)
                        {
                            try
                            {
                                var settings = o as Placements.ScatterPlaceManipulator.ManipulatorSettings;
                                if (settings != null)
                                    settings.LoadModelList(fn);

                                    // Hack! Problem when refreshing properties after a change
                                    // So we need to change the object to something else, and then
                                    // change it back.
                                    // Note that this creates a hidden cyclic dependency
                                    //      -- because we're keeping a reference on the "properties"
                                    //          variable here
                                properties.Object = new Placements.ScatterPlaceManipulator.ManipulatorSettings();
                                properties.Object = settings;
                            }
                            catch { MessageBox.Show("Error while loading model list"); }
                        };

                    var page = new TabPage("Scatter Placer");
                    page.Tag = m;
                    page.Controls.Add(properties);
                    m_controls.m_tabControl.TabPages.Add(page);
                }
            }

            m_controlHostService.RegisterControl(
                m_controls,
                new ControlInfo("Manipulator Controls", "Properties for the active manipulator", StandardControlGroup.Right),
                null);
        }
示例#2
0
        void IInitializable.Initialize()
        {
            m_controls = new XLEManipCtrls();

            // We could use another MEF container system to initialise the
            // tab pages for this control... But for now, this is a simple
            // way to get the behaviour we want.
            var manipulators = Globals.MEFContainer.GetExportedValues <IManipulator>();

            foreach (var m in manipulators)
            {
                var t = m as Terrain.TerrainManipulator;
                if (t != null)
                {
                    var terrainCtrls = new XLENativeManipControls();
                    terrainCtrls.Dock = DockStyle.Fill;
                    terrainCtrls.SetActiveContext(t.ManipulatorContext);

                    var terrainPage = new TabPage("Terrain");
                    terrainPage.Tag = m;
                    terrainPage.Controls.Add(terrainCtrls);
                    m_controls.m_tabControl.TabPages.Add(terrainPage);
                }

                var s = m as Placements.ScatterPlaceManipulator;
                if (s != null)
                {
                    var properties = new XLEScatterPlaceControls();
                    properties.Dock   = DockStyle.Fill;
                    properties.Object = s.ManipulatorContext;

                    properties.SaveEvent = delegate(object o, string fn)
                    {
                        try
                        {
                            var settings = o as Placements.ScatterPlaceManipulator.ManipulatorSettings;
                            if (settings != null)
                            {
                                settings.SaveModelList(fn);
                            }
                        }
                        catch { MessageBox.Show("Error while saving model list"); }
                    };

                    properties.LoadEvent = delegate(object o, string fn)
                    {
                        try
                        {
                            var settings = o as Placements.ScatterPlaceManipulator.ManipulatorSettings;
                            if (settings != null)
                            {
                                settings.LoadModelList(fn);
                            }

                            // Hack! Problem when refreshing properties after a change
                            // So we need to change the object to something else, and then
                            // change it back.
                            // Note that this creates a hidden cyclic dependency
                            //      -- because we're keeping a reference on the "properties"
                            //          variable here
                            properties.Object = new Placements.ScatterPlaceManipulator.ManipulatorSettings();
                            properties.Object = settings;
                        }
                        catch { MessageBox.Show("Error while loading model list"); }
                    };

                    var page = new TabPage("Scatter Placer");
                    page.Tag = m;
                    page.Controls.Add(properties);
                    m_controls.m_tabControl.TabPages.Add(page);
                }
            }

            m_controlHostService.RegisterControl(
                m_controls,
                new ControlInfo("Manipulator Controls", "Properties for the active manipulator", StandardControlGroup.Right),
                null);
        }