예제 #1
0
        /// <summary>
        /// Adds a slice to the current control.
        /// </summary>
        /// <param name="slice">The slice.</param>
        private void OnAddSlice(PlSlice slice)
        {
            // Create a new tree node.
            TreeNode node = new TreeNode("Slice ({0})".FormatWith(slice.Name));
            node.ImageKey = "GlobeObject";
            node.SelectedImageKey = "GlobeObject";
            this.treeNode.Nodes.Add(node);
            this.treeNode.ExpandAll();

            // Create a new control.
            ControlSlice control = new ControlSlice();
            control.Initialize(this.crawler, slice, this.controls, node);
            this.controls.Add(control);

            // Set the node tag.
            node.Tag = control;

            // Create the list view item.
            ListViewItem item = new ListViewItem(new string[] {
                        slice.Id.HasValue ? slice.Id.Value.ToString() : string.Empty,
                        slice.Name,
                        slice.Created.ToString(),
                        slice.Expires.ToString(),
                        slice.NodeIds != null ? slice.NodeIds.Length.ToString() : "0",
                        slice.MaxNodes.ToString()
                    }, 0);
            item.Tag = new SliceInfo(slice, node, control);

            // Add the item to the list view.
            this.listViewSlices.Items.Add(item);

            // Add the slice changed event handler.
            slice.Changed += this.OnSliceChanged;
        }
예제 #2
0
 /// <summary>
 /// Creates a new slice information variable.
 /// </summary>
 /// <param name="slice">The PlanetLab slice.</param>
 /// <param name="node">The tree node.</param>
 /// <param name="control">The control.</param>
 public SliceInfo(PlSlice slice, TreeNode node, ControlSlice control)
     : this()
 {
     this.Slice = slice;
     this.Node = node;
     this.Control = control;
 }