Esempio n. 1
0
        public override BaseEditor CreateObject(ref BaseEditor parent, Mogre.NameValuePairList parameters)
        {
            MaterialEditor obj = new MaterialEditor();

            Mogre.NameValuePairList.Iterator ni;
            if ((ni = parameters.Find("Init")) != parameters.End())
            {
                parameters["Name"] = "Material" + MogitorsRoot.Instance.CreateUniqueID("Material", "", 1);
            }

            obj.ProcessParameters(parameters);
            parent = MogitorsRoot.Instance.SceneManagerEditor;
            obj.Parent = parent;

            InstanceCount++;
            return obj;
        }
Esempio n. 2
0
        private void treeControl_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            TreeViewItem treeItem = e.NewValue as TreeViewItem;
            if (treeItem == null)
                return;

            if (treeItem.Parent == null)
            {
                if (MogitorsRoot.Instance.Selected != null)
                    MogitorsRoot.Instance.Selected.IsSelected = false;
                MogitorsRoot.Instance.RootEditor.IsSelected = true;
                return;
            }

            IconTextItem item = treeItem.Header as IconTextItem;
            if (item == null)
            {
                e.Handled = true;
                return;
            }

            int id = (treeItem.Tag != null) ? (int)treeItem.Tag : 0;

            int level = 0;
            while (treeItem.Tag != null)
            {
                treeItem = treeItem.Parent as TreeViewItem;
                item = treeItem.Header as IconTextItem;
                ++level;
            }

            string name = item.Name;

            MogitorsRoot mogRoot = MogitorsRoot.Instance;

            if (this.materialEditor == null || name != this.materialEditor.Name ||
                level != this.materialEditor.PropertyLevel ||
                id != this.materialEditor.PropertyId)
            {
                if (mogRoot.Selected != null)
                    mogRoot.Selected.IsSelected = false;

                if (this.materialEditor != null)
                    this.materialEditor.Destroy(false);

                BaseEditor parentEd = null;
                Mogre.NameValuePairList parameters = new Mogre.NameValuePairList();
                parameters["Name"] = name;

                this.materialEditor = MaterialEditor.Factory.CreateObject(ref parentEd, parameters) as MaterialEditor;
                if (this.materialEditor != null && this.materialEditor.Load())
                {
                    this.materialEditor.TreeItemHandle = treeItem;
                    this.materialEditor.SetPropertiesLevel(level, id);
                    this.materialEditor.IsSelected = true;
                }
            }
        }