Example #1
0
        private static void GlobalUpdateSelection(object sender, SelectionChangedEventArgs e)
        {
            ObjectInspector target = null;

            foreach (ObjectSelection.Category cat in ObjectSelection.EnumerateCategories(e.AffectedCategories))
            {
                var objViews =
                    from v in EditorBasePlugin.Instance.ObjViews
                    where v.AcceptsSelection(e.Current)
                    select new {
                    View            = v,
                    Empty           = v.EmptySelection,
                    PerfectFit      = v.EmptySelection || (cat & v.DisplayedCategory) != ObjectSelection.Category.None,
                    TypeShare       = ObjectSelection.GetTypeShareLevel(e.Current.Exclusive(cat), v.DisplayedSelection),
                    NumSameCatViews = EditorBasePlugin.Instance.ObjViews.Count(o => o.AcceptsSelection(e.Current) && o.DisplayedCategory == v.DisplayedCategory)
                };
                var sortedQuery =
                    from o in objViews
                    orderby o.PerfectFit descending, o.Empty ascending, o.NumSameCatViews descending, o.TypeShare ascending
                select o;
                var targetItem = sortedQuery.FirstOrDefault();
                if (targetItem == null)
                {
                    return;
                }
                target = targetItem.View;

                // If a mouse button is pressed, reschedule the selection for later - there might be a drag in progress
                if (Control.MouseButtons != System.Windows.Forms.MouseButtons.None)
                {
                    target.selSchedMouse            = e.Current;
                    target.selSchedMouseCat         = cat;
                    target.timerSelectSched.Enabled = true;
                }
                else
                {
                    target.UpdateSelection(e.Current, cat);
                }
            }

            //  Make sure disposed objects are deselected in non-target views (locked, etc.)
            foreach (ObjectInspector v in EditorBasePlugin.Instance.ObjViews)
            {
                if (v.EmptySelection)
                {
                    continue;
                }
                if (v == target)
                {
                    continue;
                }

                var disposedObj = e.Removed.OfType <IManageableObject>().Where(o => o.Disposed);
                if (disposedObj.Any())
                {
                    ObjectSelection disposedSel = new ObjectSelection(disposedObj);
                    v.UpdateSelection(v.DisplayedSelection - disposedSel, v.DisplayedCategory);
                }
            }
        }
Example #2
0
        public void CopyTo(ObjectInspector other)
        {
            this.gridExpandState.UpdateFrom(this.propertyGrid.MainEditor);

            other.buttonAutoRefresh.Checked = this.buttonAutoRefresh.Checked;
            other.buttonLock.Checked = this.buttonLock.Checked;

            this.gridExpandState.CopyTo(other.gridExpandState);
        }
Example #3
0
        public void CopyTo(ObjectInspector other)
        {
            this.gridExpandState.UpdateFrom(this.propertyGrid.MainEditor);

            other.buttonAutoRefresh.Checked = this.buttonAutoRefresh.Checked;
            other.buttonLock.Checked        = this.buttonLock.Checked;

            this.gridExpandState.CopyTo(other.gridExpandState);
        }
Example #4
0
        public ObjectInspector RequestObjView(bool dontShow = false)
        {
            ObjectInspector objView = new ObjectInspector(this.objViews.Count);

            this.objViews.Add(objView);
            objView.FormClosed += delegate(object sender, FormClosedEventArgs e) { this.objViews.Remove(sender as ObjectInspector); };

            if (!this.isLoading && !dontShow)
            {
                objView.Show(DualityEditorApp.MainForm.MainDockPanel);
                if (objView.Pane != null)
                {
                    objView.Pane.Activate();
                    objView.Focus();
                }
            }
            return(objView);
        }
Example #5
0
        private void buttonClone_Click(object sender, EventArgs e)
        {
            ObjectInspector objView = EditorBasePlugin.Instance.RequestObjView(true);

            this.CopyTo(objView);
            objView.buttonLock.Checked = true;

            DockPanel mainDoc = DualityEditorApp.MainForm.MainDockPanel;

            if (this.DockHandler.DockState.IsAutoHide())
            {
                objView.Show(this.DockPanel, this.DockHandler.DockState);
            }
            else
            {
                objView.Show(this.DockHandler.Pane, DockAlignment.Bottom, 0.5d);
            }

            // Need it before showing because of instant-selection
            objView.propertyGrid.SelectObjects(this.propertyGrid.Selection);
            objView.gridExpandState.ApplyTo(objView.propertyGrid.MainEditor);
        }
Example #6
0
 private void menuItemObjView_Click(object sender, EventArgs e)
 {
     ObjectInspector objView = this.RequestObjView();
 }
Example #7
0
        public ObjectInspector RequestObjView(bool dontShow = false)
        {
            ObjectInspector objView = new ObjectInspector(this.objViews.Count);
            this.objViews.Add(objView);
            objView.FormClosed += delegate(object sender, FormClosedEventArgs e) { this.objViews.Remove(sender as ObjectInspector); };

            if (!this.isLoading && !dontShow)
            {
                objView.Show(DualityEditorApp.MainForm.MainDockPanel);
                if (objView.Pane != null)
                {
                    objView.Pane.Activate();
                    objView.Focus();
                }
            }
            return objView;
        }