Esempio n. 1
0
        /// <summary>
        /// Called when a mouse button was pressed.
        /// </summary>
        public void OnButtonPress(ButtonPressEventArgs args)
        {
            Vector2 mousePos = new Vector2((float)args.Event.X, (float)args.Event.Y);

            ModifierType modifierMask = Accelerator.DefaultModMask;
            bool         shift        = (args.Event.State & modifierMask) == ModifierType.ShiftMask;

            if (args.Event.Button == 1) // left click
            {
                MeshInfo underCursor = GetMeshAtScreenPos(mousePos);

                ModifyMeshInfosOperation op = new ModifyMeshInfosOperation();

                // clear current selection unless shift is pressed
                if (!shift)
                {
                    MeshManager.Instance.SelectedMeshes.ForEach(m => m.IsSelected = false);
                }
                if (underCursor != null)
                {
                    underCursor.IsActive = true;
                }

                op.Complete();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Removes all selected meshes. The operation is added to the undo stack.
        /// </summary>
        public void DeleteSelected()
        {
            ModifyMeshInfosOperation op = new ModifyMeshInfosOperation();

            RemoveMeshes(SelectedMeshes);

            op.Complete();
        }
Esempio n. 3
0
        /// <summary>
        /// Called when a visibility checkbox has changed.
        /// </summary>
        private void OnVisibleToggled(object o, ToggledArgs args)
        {
            TreePath path = new TreePath(args.Path);
            TreeIter iter;

            if (m_listStore.GetIter(out iter, path))
            {
                ModifyMeshInfosOperation op = new ModifyMeshInfosOperation();
                m_ignoreListSelection = true;
                m_indexToMesh[path.Indices[0]].IsVisible = !(bool)m_listStore.GetValue(iter, 0);
                op.Complete();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Makes every mesh visible. The operation is added to the undo stack.
        /// </summary>
        public void ShowAll()
        {
            ModifyMeshInfosOperation op = new ModifyMeshInfosOperation();

            m_meshes.ForEach(m => m.IsSelected = false);
            foreach (MeshInfo mesh in m_meshes.Where(m => !m.IsVisible))
            {
                mesh.IsVisible  = true;
                mesh.IsSelected = true;
            }

            op.Complete();
        }
Esempio n. 5
0
        /// <summary>
        /// Makes every mesh visible. The operation is added to the undo stack.
        /// </summary>
        public void HideSelected()
        {
            ModifyMeshInfosOperation op = new ModifyMeshInfosOperation();

            foreach (MeshInfo mesh in m_meshes)
            {
                if (mesh.IsSelected)
                {
                    mesh.IsVisible = false;
                }
            }

            op.Complete();
        }
Esempio n. 6
0
        /// <summary>
        /// Delects all meshes if any are selected and selects all meshes is none are selected.
        /// The operation is added to the undo stack.
        /// </summary>
        public void ToggleSelected()
        {
            ModifyMeshInfosOperation op = new ModifyMeshInfosOperation();

            if (m_meshes.Any(m => m.IsSelected))
            {
                m_meshes.ForEach(m => m.IsSelected = false);
            }
            else
            {
                m_meshes.ForEach(m => m.IsSelected = m.IsVisible);
            }

            op.Complete();
        }
Esempio n. 7
0
        /// <summary>
        /// Adds meshes to the loaded mesh list. The operation is added to the undo stack.
        /// </summary>
        /// <param name="meshes">The meshes to add.</param
        /// <returns>The mesh infos for the added meshes.</returns>
        public List <MeshInfo> AddMeshes(IEnumerable <Mesh> meshes)
        {
            ModifyMeshInfosOperation op = new ModifyMeshInfosOperation();

            List <MeshInfo> meshInfos = new List <MeshInfo>();

            foreach (Mesh mesh in meshes)
            {
                meshInfos.Add(new MeshInfo(mesh));
            }
            AddMeshes(meshInfos);

            op.Complete();

            return(meshInfos);
        }
Esempio n. 8
0
        /// <summary>
        /// Called when the selected elements of the list view has changed.
        /// </summary>
        private void OnListSelectionChanged(object sender, System.EventArgs e)
        {
            if (!m_ignoreListSelection)
            {
                ModifyMeshInfosOperation op = new ModifyMeshInfosOperation();

                // deselect old selection
                List <MeshInfo> oldSelection = MeshManager.Instance.SelectedMeshes;
                oldSelection.ForEach(m => m.IsSelected = false);

                List <MeshInfo> newSelected = GetSelectedMeshes().Where(m => !oldSelection.Contains(m)).ToList();
                newSelected.ForEach(m => m.IsSelected = true);

                if (newSelected.Count > 0)
                {
                    if (oldSelection.Count > 0 && m_meshToIndex[oldSelection.First()] < m_meshToIndex[newSelected.First()])
                    {
                        newSelected.Last().IsActive = true;
                    }
                    else
                    {
                        newSelected.First().IsActive = true;
                    }
                }

                op.Complete();
            }
            else
            {
                m_treeView.Selection.Changed -= OnListSelectionChanged;

                m_treeView.Selection.UnselectAll();
                foreach (KeyValuePair <MeshInfo, int> meshPath in m_meshToIndex)
                {
                    if (meshPath.Key.IsSelected)
                    {
                        TreePath path = new TreePath(meshPath.Value.ToString());
                        m_treeView.Selection.SelectPath(path);
                    }
                }
                m_ignoreListSelection = false;

                m_treeView.Selection.Changed += OnListSelectionChanged;
            }
        }