Exemplo n.º 1
0
 /// <summary>
 /// An event handler called when a site has been removed.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnSitesRemoved(object sender, PlObjectEventArgs<PlSite> e)
 {
     // Get the list view item containing the site.
     ListViewItem item = this.listViewSites.Items.FirstOrDefault((ListViewItem it) =>
         {
             // Get the item tag.
             Pair<PlSite, MapMarker> tag = (Pair<PlSite, MapMarker>)it.Tag;
             // Return true if the tag slice matches the current slice.
             return object.ReferenceEquals(tag.First, e.Object);
         });
     // If the item is not null.
     if (null != item)
     {
         // Get the item tag.
         Pair<PlSite, MapMarker> tag = (Pair<PlSite, MapMarker>)item.Tag;
         // Remove the slice changed event handler.
         tag.First.Changed -= this.OnSiteChanged;
         // Remove the map marker.
         this.mapControl.Markers.Remove(tag.Second);
         // Dispose the map marker.
         tag.Second.Dispose();
         // Remove the item.
         this.listViewSites.Items.Remove(item);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// An event handler called when a slice is added.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnSlicesAdded(object sender, PlObjectEventArgs<PlSlice> e)
 {
     // If the slice has a valid identifier.
     if (e.Object.Id.HasValue)
     {
         // Create a new slice configuration.
         PlConfigSlice configSlice = new PlConfigSlice(e.Object, this.keySlices);
         // Add the configuration to the dictionary.
         this.configSlices.Add(e.Object.Id.Value, configSlice);
     }
 }
Exemplo n.º 3
0
 // Private methods.
 /// <summary>
 /// An event handler called when the site has changed.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnSiteChanged(object sender, PlObjectEventArgs e)
 {
     // Get the site.
     PlSite site = e.Object as PlSite;
     // Find the list view item corresponding to the slice.
     ListViewItem item = this.listViewSites.Items.FirstOrDefault((ListViewItem it) =>
     {
         // Get the slice info.
         Pair<PlSite, MapMarker> tag = (Pair<PlSite, MapMarker>)it.Tag;
         // Return true if the item corresponds to the same slice.
         return object.ReferenceEquals(site, tag.First);
     });
     // If the item is not null.
     if (null != item)
     {
         // Update the item.
         item.SubItems[0].Text = site.SiteId.ToString();
         item.SubItems[1].Text = site.Name;
         item.SubItems[2].Text = site.Url;
         item.SubItems[3].Text = site.NodeIds.Length.ToString();
         item.SubItems[4].Text = site.DateCreated.ToString();
         item.SubItems[5].Text = site.LastUpdated.ToString();
         item.SubItems[6].Text = site.Latitude.HasValue ? site.Latitude.Value.LatitudeToString() : string.Empty;
         item.SubItems[7].Text = site.Longitude.HasValue ? site.Longitude.Value.LongitudeToString() : string.Empty;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// An event handler called when a new site has been added.
        /// </summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnSitesAdded(object sender, PlObjectEventArgs<PlSite> e)
        {
            // The filter flag.
            bool filterFlag = false;

            // If the filter is not null or empty.
            if (!string.IsNullOrEmpty(this.filter))
            {
                // If the site name does not match the filter, return.
                if (!string.IsNullOrEmpty(e.Object.Name))
                {
                    filterFlag = !e.Object.Name.ToLower().Contains(this.filter.ToLower());
                }
            }

            // If the site is not filtered.
            if (!filterFlag)
            {
                // Add the site.
                this.OnAddSite(e.Object);
            }

            // Update the label.
            this.status.Send(ApplicationStatus.StatusType.Normal,
                "Showing {0} of {1} PlanetLab site{2}.".FormatWith(
                this.listViewSites.Items.Count,
                this.crawler.PlanetLab.Sites.Count,
                this.crawler.PlanetLab.Sites.Count.PluralSuffix()), Resources.GlobeLab_16);
        }
Exemplo n.º 5
0
 /// <summary>
 /// An event handler called when a node has been removed.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnNodesRemoved(object sender, PlObjectEventArgs<PlNode> e)
 {
     // Get the list view item containing the node.
     ListViewItem item = this.listViewNodes.Items.FirstOrDefault((ListViewItem it) =>
         {
             // Get the item tag.
             Pair<PlNode, MapMarker> tag = (Pair<PlNode, MapMarker>)it.Tag;
             // Return true if the tag node matches the current node.
             return object.ReferenceEquals(tag.First, e.Object);
         });
     // If the item is not null.
     if (null != item)
     {
         // Get the node.
         PlNode node = item.Tag as PlNode;
         // Remove the node changed event handler.
         node.Changed -= this.OnNodeChanged;
         // Remove the item.
         this.listViewNodes.Items.Remove(item);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// An event handler called when a slice has been removed from the local slices list.
        /// </summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnSlicesRemoved(object sender, PlObjectEventArgs<PlSlice> e)
        {
            // Search the list view item for the current slice.
            ListViewItem item = this.listViewSlices.Items.FirstOrDefault((ListViewItem it) =>
                {
                    // Get the slice info.
                    SliceInfo info = (SliceInfo)it.Tag;
                    // Compare the item slice with the current slice.
                    return object.ReferenceEquals(e.Object, info.Slice);
                });

            // If the item is not null.
            if (null != item)
            {
                // Get the slice info.
                SliceInfo info = (SliceInfo)item.Tag;
                // Remove the slice changed event handler.
                info.Slice.Changed -= this.OnSliceChanged;
                // Remove the list view item.
                this.listViewSlices.Items.Remove(item);
                // Remove the tree node.
                this.treeNode.Nodes.Remove(info.Node);
                // Remove the control.
                this.controls.Remove(info.Control);
                // Dispose the control.
                info.Control.Dispose();
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// An event handler called when a PlanetLab node has changed.
        /// </summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnNodeChanged(object sender, PlObjectEventArgs e)
        {
            this.Invoke(() =>
                {
                    // Get the node.
                    PlNode node = e.Object as PlNode;
                    // Get the list item corresponding to the selected node.
                    ListViewItem item = this.listViewNodes.Items.FirstOrDefault((ListViewItem it) =>
                        {
                            // Get the node info.
                            NodeInfo info = it.Tag as NodeInfo;
                            // Check the tag node equals the current node.
                            return info.NodeId == node.Id;
                        });
                    // Update the item information.
                    if (null != item)
                    {
                        // Get the node information.
                        NodeInfo info = item.Tag as NodeInfo;

                        // Set the item information.
                        item.SubItems[0].Text = node.Id.Value.ToString();
                        item.SubItems[1].Text = node.Hostname;
                        item.ImageKey = ControlSlice.nodeImageKeys[(int)node.GetBootState()];
                    }
                });
        }
Exemplo n.º 8
0
 /// <summary>
 /// An event handler called when the user renewes a PlanetLab slice.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnRenewed(object sender, PlObjectEventArgs<PlSlice> e)
 {
     // Set the result.
     this.Result = e.Object;
     // Set the dialog result.
     this.DialogResult = DialogResult.OK;
 }
Exemplo n.º 9
0
        /// <summary>
        /// An event handler called when the console is disconnecting.
        /// </summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnConsoleDisconnecting(object sender, PlObjectEventArgs<PlNode> e)
        {
            ListViewItem item;

            // Call the state changed method.
            if ((item = this.OnConsoleStateChanged(e.Object)) != null)
            {
                // Do nothing.
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// An event handler called when the console has disconnected.
        /// </summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnControlDisconnected(object sender, PlObjectEventArgs<PlNode> e)
        {
            ListViewItem item;

            // Call the state changed method.
            if ((item = this.OnConsoleStateChanged(e.Object)) != null)
            {
                // Close the console.
                this.OnConsoleClose(item);
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// An event handler called when the current slice has changed.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnSliceChanged(object sender, PlObjectEventArgs e)
 {
     // Update the slice information.
     this.OnUpdateSlice();
 }
Exemplo n.º 12
0
        /// <summary>
        /// An event handler called when a PlanetLab site has changed.
        /// </summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnSiteChanged(object sender, PlObjectEventArgs e)
        {
            this.Invoke(() =>
                {
                    // Get the site.
                    PlSite site = e.Object as PlSite;
                    // Get the list item corresponding to the selected node.
                    ListViewItem item = this.listViewNodes.Items.FirstOrDefault((ListViewItem it) =>
                    {
                        // Get the node info.
                        NodeInfo info = it.Tag as NodeInfo;
                        // Check the tag node equals the current node.
                        return object.ReferenceEquals(info.Site, site);
                    });
                    // Update the item information.
                    if (null != item)
                    {
                        // Get the node information.
                        NodeInfo info = item.Tag as NodeInfo;

                        // If the marker is not null.
                        if (null != info.Marker)
                        {
                            // Update the marker location.
                            info.Marker.Location = new MapPoint(site.Longitude.Value, site.Latitude.Value);
                        }
                        else
                        {
                            // If the site has coordinates.
                            if (site.Latitude.HasValue && site.Longitude.HasValue)
                            {
                                // Create a circular marker.
                                info.Marker = new MapBulletMarker(new MapPoint(site.Longitude.Value, site.Latitude.Value));
                                info.Marker.Name = "{0}{1}{2}".FormatWith(info.Node.Hostname, Environment.NewLine, site.Name);
                                // Add the marker to the map.
                                this.mapControl.Markers.Add(marker);
                            }
                        }
                    }
                });
        }
Exemplo n.º 13
0
        /// <summary>
        /// An event handler called when a PlanetLab site has changed.
        /// </summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnSiteChanged(object sender, PlObjectEventArgs e)
        {
            // Execute on the UI thread.
            this.Invoke(() =>
                {
                    // Get the site.
                    PlSite site = e.Object as PlSite;
                    // Get the list item corresponding to the selected node.
                    ListViewItem item = this.listViewNodes.Items.FirstOrDefault((ListViewItem it) =>
                    {
                        // Get the node info.
                        NodeInfo info = it.Tag as NodeInfo;
                        // Check the tag node equals the current node.
                        return object.ReferenceEquals(info.Site, site);
                    });
                    // Update the item information.
                    if (null != item)
                    {
                        // Get the node information.
                        NodeInfo info = item.Tag as NodeInfo;

                        // Set the item information.
                        item.SubItems[2].Text = site.Name;
                    }
                });
        }
Exemplo n.º 14
0
 /// <summary>
 /// An event handler called when a slice is removed.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnSlicesRemoved(object sender, PlObjectEventArgs<PlSlice> e)
 {
     // If the slice has a valid identifier.
     if (e.Object.Id.HasValue)
     {
         // Get the current configuration.
         PlConfigSlice configSlice;
         if (this.configSlices.TryGetValue(e.Object.Id.Value, out configSlice))
         {
             // Remove the configuration.
             this.configSlices.Remove(e.Object.Id.Value);
             // Dispose the configuration.
             configSlice.Dispose();
             // Delete the configuration.
             PlConfigSlice.Delete(configSlice, this.keySlices);
         }
     }
 }
Exemplo n.º 15
0
 // Private methods.
 /// <summary>
 /// An event handler called when a slice has changed.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnSliceChanged(object sender, PlObjectEventArgs e)
 {
     // Get the slice.
     PlSlice slice = e.Object as PlSlice;
     // Find the list view item corresponding to the slice.
     ListViewItem item = this.listViewSlices.Items.FirstOrDefault((ListViewItem it) =>
     {
         // Get the slice info.
         SliceInfo info = (SliceInfo)it.Tag;
         // Return true if the item corresponds to the same slice.
         return object.ReferenceEquals(slice, info.Slice);
     });
     // If the item is not null.
     if (null != item)
     {
         // Update the item.
         item.SubItems[0].Text = slice.Id.HasValue ? slice.Id.Value.ToString() : string.Empty;
         item.SubItems[1].Text = slice.Name;
         item.SubItems[2].Text = slice.Created.ToString();
         item.SubItems[3].Text = slice.Expires.ToString();
         item.SubItems[4].Text = slice.NodeIds != null ? slice.NodeIds.Length.ToString() : "0";
         item.SubItems[5].Text = slice.MaxNodes.ToString();
     }
 }
Exemplo n.º 16
0
 /// <summary>
 /// An event handler called when the current slice configuration has changed.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnSliceChanged(object sender, PlObjectEventArgs e)
 {
     // Call the changed event handler.
     this.OnChanged();
 }
Exemplo n.º 17
0
 /// <summary>
 /// An event handler called when a slice has been added to the local slices list.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnSlicesAdded(object sender, PlObjectEventArgs<PlSlice> e)
 {
     // Add the slice.
     this.OnAddSlice(e.Object);
 }
 /// <summary>
 /// An event handler called when the user selects a PlanetLab person.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnSelected(object sender, PlObjectEventArgs<PlPerson> e)
 {
     // Set the result.
     this.Result = e.Object;
     // Set the dialog result.
     this.DialogResult = DialogResult.OK;
 }
Exemplo n.º 19
0
 // Private methods.
 /// <summary>
 /// An event handler called when the node has changed.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnNodeChanged(object sender, PlObjectEventArgs e)
 {
     this.Invoke(() =>
         {
             // Get the node.
             PlNode node = e.Object as PlNode;
             // Find the list view item corresponding to the node.
             ListViewItem item = this.listViewNodes.Items.FirstOrDefault((ListViewItem it) =>
             {
                 // Return true if the item corresponds to the same node.
                 return object.ReferenceEquals(node, it.Tag);
             });
             // If the item is not null.
             if (null != item)
             {
                 // Update the item.
                 item.SubItems[0].Text = node.Id.HasValue ? node.Id.Value.ToString() : string.Empty;
                 item.SubItems[1].Text = node.Hostname;
                 item.SubItems[2].Text = node.BootState;
                 item.SubItems[3].Text = node.Model;
                 item.SubItems[4].Text = node.Version;
                 item.SubItems[5].Text = node.DateCreated.HasValue ? node.DateCreated.Value.ToString() : string.Empty;
                 item.SubItems[6].Text = node.LastUpdated.HasValue ? node.LastUpdated.Value.ToString() : string.Empty;
                 item.SubItems[7].Text = node.NodeType;
                 item.ImageKey = ControlNodes.nodeImageKeys[(int)node.GetBootState()];
             }
         });
 }