コード例 #1
0
ファイル: LocationsTabView.cs プロジェクト: windygu/AW-master
        /// <summary>
        /// Delete a location from the tree
        /// </summary>
        protected void DeleteTreeLocation()
        {
            // Get the parent - as we don;t allow selection across levels we can be sure that the parent for all
            // selected items is the same
            UltraTreeNode parentNode = locationsTree.SelectedNodes[0].Parent;

            // first check that the user isn't trying to delete the root location
            if (parentNode == null)
            {
                MessageBox.Show("Unable to delete " + locationsTree.SelectedNodes[0].Text + " - the top-level location cannot be deleted", "AuditWizard", MessageBoxButtons.OK);
                return;
            }

            // Confirm the deletion as this is a pretty serious function
            if (MessageBox.Show("Are you sure that you want to delete the selected location(s)?  All child locations will also be deleted and any child assets moved to the parent location.", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
            {
                return;
            }

            // Delete these locations
            foreach (UltraTreeNode node in locationsTree.SelectedNodes)
            {
                // get the location and delete from the database
                AssetGroup location = node.Tag as AssetGroup;
                location.Delete();

                // ...and remove it from the tree
                parentNode.Nodes.Remove(node);
            }

            // Select the parent node as this will cause the list to be refreshed
            parentNode.BringIntoView();
            parentNode.Selected = true;
        }
コード例 #2
0
ファイル: LocationsTabView.cs プロジェクト: windygu/AW-master
        /// <summary>
        /// Adds a new location as a child of the location currently selected in the TreeView
        /// </summary>
        public void AddLocation()
        {
            if (locationsTree.SelectedNodes.Count == 0)
            {
                return;
            }
            //
            UltraTreeNode selectedNode = locationsTree.SelectedNodes[0];

            AssetGroup parentGroup = selectedNode.Tag as AssetGroup;
            AssetGroup newGroup    = new AssetGroup();

            newGroup.GroupType = AssetGroup.GROUPTYPE.userlocation;
            newGroup.ParentID  = parentGroup.GroupID;
            //
            FormUserLocation form = new FormUserLocation(parentGroup, newGroup);

            if (form.ShowDialog() == DialogResult.OK)
            {
                UltraTreeNode newNode = selectedNode.Nodes.Add(newGroup.FullName, newGroup.Name);

                newNode.Override.NodeAppearance.Image         = Properties.Resources.location_16;
                newNode.Override.ExpandedNodeAppearance.Image = Properties.Resources.location_16;
                newNode.Tag = newGroup;
                newNode.BringIntoView();

                // Add the new location to the list view also
                PopulateListView(selectedNode);
            }
        }
コード例 #3
0
        /// <summary>
        /// Called as we double click a row in the list - this effectively causes this item to be expanded
        /// in the tree view and hence here
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void auditGridView_DoubleClickRow(object sender, DoubleClickRowEventArgs e)
        {
            // Get the DataObject from the grid as this helps identify the item being double clicked.
            object dataObject = e.Row.Cells["DataObject"].Value;

            // OK - what is it?
            // In general the dataObject may be one of:
            //	UltraTreeNode - most items - this simply holds the parent item from the tree.
            //	Asset - used only in All Assets view
            //	FileSystemFile - terminus of a File System branch identifies a specific file
            //
            //  If we double click an UltraTreeNode this causes it to be expanded
            if (dataObject is UltraTreeNode)
            {
                UltraTreeNode treeNode = dataObject as UltraTreeNode;

                // ...and cause it to be expanded
                treeNode.Expanded = true;

                // ...and select it also
                UltraTree treeControl = treeNode.Control as UltraTree;
                treeNode.BringIntoView(true);
                _displayedNode.Selected = false;
                treeNode.Selected       = true;
            }

            // Double-click on a FileSystemFile displays it's properties
            else if (dataObject is FileSystemFile)
            {
                propertiesToolStripMenuItem_Click(sender, null);
            }
        }
コード例 #4
0
ファイル: LocationsTabView.cs プロジェクト: windygu/AW-master
 /// <summary>
 /// Restore the selection state of any nodes contained within the supplied list
 /// </summary>
 /// <param name="selectedNodes"></param>
 protected void RestoreSelectedNodes(SelectedNodesCollection selectedNodes)
 {
     foreach (UltraTreeNode node in selectedNodes)
     {
         UltraTreeNode selectedNode = locationsTree.GetNodeByKey(node.Key);
         if (selectedNode != null)
         {
             selectedNode.BringIntoView();
             if (selectedNode.Selected == false)
             {
                 selectedNode.Selected = true;
             }
         }
     }
 }
コード例 #5
0
        private void GotoSelectedAsset()
        {
            if (lvResults.SelectedItems.Count == 0)
            {
                return;
            }

            UltraListViewItem lvi = lvResults.SelectedItems[0];

            if (lvi == null)
            {
                return;
            }

            // display the node
            UltraTreeNode rootNode = _explorerTree.Nodes[0];
            UltraTreeNode node     = AddMatches(rootNode, lvi.Value.ToString());

            node.BringIntoView();
            _explorerTree.SelectedNodes.Clear();
            node.Selected = true;
            node.Expanded = true;
        }
コード例 #6
0
        private void applicationsGridView_DoubleClickRow(object sender, DoubleClickRowEventArgs e)
        {
            // Do not allow double -click on the group by row
            if (e.Row is UltraGridGroupByRow)
            {
                return;
            }

            // Get the DataObject from the grid as this helps identify the item being double clicked.
            object dataObject = e.Row.Cells["ApplicationObject"].Value;

            //  If we double click an UltraTreeNode this causes it to be expanded
            if (dataObject is UltraTreeNode)
            {
                UltraTreeNode treeNode = dataObject as UltraTreeNode;

                // ...and cause it to be expanded
                treeNode.Expanded = true;

                // ...and select it also
                UltraTree treeControl = treeNode.Control as UltraTree;
                treeNode.BringIntoView(true);
                _displayedNode.Selected = false;
                treeNode.Selected       = true;
            }

            else
            {
                // If not an UltraTreeNode then try and display the items properties
                applicationsGridView.Selected.Rows.Clear();
                applicationsGridView.Selected.Rows.Add(e.Row);

                // ...and get it's properties
                ShowProperties();
            }
        }