Ejemplo n.º 1
0
        private void checkBox_Unchecked(object sender, RoutedEventArgs e)
        {
            CheckBox   checkbox = sender as CheckBox;
            StackPanel sp       = checkbox.Parent as StackPanel;
            ActorData  ac       = sp.DataContext as ActorData;

            if (ac != null && ac.Actor != null)
            {
                ac.Actor.Visible = false;
            }
        }
Ejemplo n.º 2
0
        private void SelectionChanged()
        {
            if (TreeViewActors.SelectedItem == null)
            {
                return;
            }

            SelectActors.Clear();

            if (TreeViewActors.TreeListItemsSource.Count <= 0)
            {
                return;
            }

            if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift))
            {
                for (int i = 0; i < TreeViewActors.Items.Count; i++)
                {
                    var item = TreeViewActors.ItemContainerGenerator.ContainerFromItem(TreeViewActors.Items[i]) as TreeListView.TreeListItem;

                    if (item != null && item.IsSelected)
                    {
                        ActorData ad = item.Content as ActorData;
                        if (ad != null)
                        {
                            SelectActors.Add(i, new EditorCommon.ViewPort.ViewPortControl.SelectActorData()
                            {
                                Actor            = ad.Actor,
                                StartTransMatrix = ad.Actor.Placement.WorldMatrix,
                            });
                        }
                    }
                }

                vp.SelectActors(SelectActors.Values.ToArray());
            }
            else
            {
                var item = TreeViewActors.ItemContainerGenerator.ContainerFromItem(TreeViewActors.Items[TreeViewActors.SelectedIndex]) as TreeListView.TreeListItem;
                if (item != null)
                {
                    ActorData ad = item.Content as ActorData;
                    if (ad != null)
                    {
                        SelectActors.Add(TreeViewActors.SelectedIndex, new EditorCommon.ViewPort.ViewPortControl.SelectActorData()
                        {
                            Actor            = ad.Actor,
                            StartTransMatrix = ad.Actor.Placement.WorldMatrix,
                        });
                        vp.SelectActor(ad.Actor);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void AddActorToItem(TreeListView.ObservableCollectionAdv <TreeListView.ITreeModel> listads, EngineNS.GamePlay.Actor.GActor actor)
        {
            //过滤掉辅助的actor(物理碰撞盒子)
            if (actor.SpecialName != null && actor.SpecialName.Equals(EngineNS.Bricks.HollowMaker.GeomScene.ActorName))
            {
                return;
            }

            bool filter = true;

            if (!string.IsNullOrEmpty(mFilterString))
            {
                filter = CheckFilter(actor);
            }

            if (filter == false)
            {
                return;
            }

            String typeall = actor.GetType().ToString();

            String[] type      = typeall.Split('.');
            var      actorData = new ActorData()
            {
                Actor = actor
            };

            BindingOperations.SetBinding(actorData, ActorData.NameProperty, new Binding("SpecialName")
            {
                Source = actor
            });
            BindingOperations.SetBinding(actorData, ActorData.HighLightStringProperty, new Binding("FilterString")
            {
                Source = this
            });
            BindingOperations.SetBinding(actorData, ActorData.VisibleProperty, new Binding("Visible")
            {
                Source = actor
            });
            listads.Add(actorData);//actor.SpecialName

            if (actor.GetChildrenUnsafe().Count > 0)
            {
                addActorsToItems(actorData.Children, actor.GetChildrenUnsafe());
            }
        }
Ejemplo n.º 4
0
        //int prefocusindex = 0;
        //Focus actor ui form viewport.
        //public void FocusActorItem(EngineNS.GamePlay.Actor.GActor actor)
        //{
        //    if (prefocusindex < TreeViewActors.TreeListItemsSource.Count)
        //    {
        //        ActorData preitemactor = TreeViewActors.TreeListItemsSource[prefocusindex] as ActorData;
        //        if (preitemactor != null)
        //        {
        //            if (preitemactor.Actor == actor)
        //                return;

        //            var item = TreeViewActors.ItemContainerGenerator.ContainerFromItem(TreeViewActors.Items[prefocusindex]) as TreeListView.TreeListItem;
        //            if (item != null)
        //                item.IsSelected = false;
        //        }
        //    }

        //    SelectActors.Clear( );
        //    for (int i = 0; i < TreeViewActors.TreeListItemsSource.Count; i ++)
        //    {
        //        ActorData itemactor = TreeViewActors.TreeListItemsSource[i] as ActorData;
        //        if (itemactor != null && itemactor.Actor == actor)
        //        {

        //            SelectActors.Add(i, new EditorCommon.ViewPort.ViewPortControl.SelectActorData()
        //            {
        //                Actor = actor,
        //                StartTransMatrix = actor.Placement.WorldMatrix,
        //            });
        //            //TODO..
        //            TreeViewActors.Focus();

        //            var item = TreeViewActors.ItemContainerGenerator.ContainerFromItem(TreeViewActors.Items[i]) as TreeListView.TreeListItem;
        //            if (item != null)
        //            {
        //                item.IsEnabled = true;
        //                item.IsSelected = true;
        //                TreeViewActors.Items.MoveCurrentTo(item);
        //            }
        //            prefocusindex = i;
        //            break;
        //        }
        //    }
        //}

        //TODO..
        public void FocusActorItems(List <EngineNS.GamePlay.Actor.GActor> selectActors)//, EngineNS.GamePlay.Actor.GActor actor)
        {
            if (SelectActors.Count > 0)
            {
                int[] skeys = SelectActors.Keys.ToArray();
                for (int i = 0; i < skeys.Length; i++)
                {
                    var item = TreeViewActors.ItemContainerGenerator.ContainerFromItem(TreeViewActors.Items[skeys[i]]) as TreeListView.TreeListItem;
                    if (item != null)
                    {
                        item.IsSelected = false;
                    }
                }
            }

            SelectActors.Clear();

            if (TreeViewActors.TreeListItemsSource.Count <= 0)
            {
                return;
            }

            var lsad = new List <EngineNS.GamePlay.Actor.GActor>(selectActors);

            for (int i = 0; i < TreeViewActors.Items.Count; i++)
            {
                if (lsad.Count == 0)
                {
                    break;
                }

                //TODO.. 有時候拿不到对象
                var item = TreeViewActors.ItemContainerGenerator.ContainerFromItem(TreeViewActors.Items[i]) as TreeListView.TreeListItem;
                if (item != null)
                {
                    ActorData ad = item.Content as ActorData;
                    item.IsSelected = false;
                    for (int j = 0; j < lsad.Count; j++)
                    {
                        if (lsad[j] == ad.Actor)
                        {
                            //if (ad.Actor == actor)
                            //{
                            //    //TreeViewActors.Items.MoveCurrentTo(TreeViewActors.Items[i]);
                            //    //TreeViewActors.Items.MoveCurrentToPosition(i);
                            //    //TreeViewActors.SelectedItem = TreeViewActors.Items[i];
                            //    //TreeViewActors.SelectedIndex = i;
                            //    //TreeViewActors.Items.Refresh();
                            //}


                            EditorCommon.ViewPort.ViewPortControl.SelectActorData outdata;
                            if (SelectActors.TryGetValue(i, out outdata) == false)
                            {
                                SelectActors.Add(i, new EditorCommon.ViewPort.ViewPortControl.SelectActorData()
                                {
                                    Actor            = lsad[j],
                                    StartTransMatrix = lsad[j].Placement.WorldMatrix,
                                });
                            }

                            lsad.RemoveAt(j);
                            item.IsSelected = true;
                            break;
                        }
                    }
                }
                else
                {
                    //TODO..
                }
            }
        }