/// <summary>
 /// Creates a new event arguments instance.
 /// </summary>
 /// <param name="item">The progress item.</param>
 /// <param name="progress">The progress info.</param>
 /// <param name="oldLegend">The old legend.</param>
 /// <param name="newLegend">The new legend.</param>
 public ProgressItemLegendSetEventArgs(ProgressItem item, ProgressInfo progress, ProgressLegend oldLegend, ProgressLegend newLegend)
     : base(item)
 {
     this.Progress = progress;
     this.OldLegend = oldLegend;
     this.NewLegend = newLegend;
 }
        // Public declarations
        /// <summary>
        /// Creates a new control instance.
        /// </summary>
        public ControlSpiderStandardFeeds()
        {
            // Initialize component.
            InitializeComponent();

            // Set the default control properties.
            this.Visible = false;
            this.Dock = DockStyle.Fill;

            // Initialize the progress list box.
            for (int index = 0; index < YouTubeUri.StandardFeedNames.Length; index++)
            {
                // Initialize the progress item.
                progressItems[index] = new ProgressItem(YouTubeUri.StandardFeedNames[index], this.progressLegend);
                // Set the default progress.
                progressItems[index].Progress.Default = this.progressLegend.Items.Count - 1;
            }
            this.progressListBox.Items.AddRange(this.progressItems);
        }
Esempio n. 3
0
 /// <summary>
 /// An event handler called to update the maximum text width for the specified item.
 /// </summary>
 /// <param name="item">The progress item</param>
 private void OnUpdateItemText(ProgressItem item)
 {
     // If the object has been disposed, do nothing.
     if (this.IsDisposed) return;
     // Recompute the text maximum width.
     int width = TextRenderer.MeasureText(item.Text, this.fontText).Width;
     // If the text width is greater than the previous maximum.
     if (width > this.itemMaximumTextWidth)
     {
         // Set the maximum text width.
         this.itemMaximumTextWidth = width;
     }
     else if (width < this.itemMaximumTextWidth)
     {
         // Else, update the text width for all items.
         this.OnUpdateItemsText();
     }
 }
Esempio n. 4
0
 /// <summary>
 /// An event handler called to update the maximum progress count for the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 private void OnUpdateItemProgress(ProgressItem item)
 {
     // If the object has been disposed, do nothing.
     if (this.IsDisposed) return;
     // Compute the count digits for this item.
     int digits = item.Progress != null ? (int)Math.Ceiling(Math.Log10(item.Progress.Count)) : 0;
     // If the number of digits is greater than the current maximum.
     if (digits > this.itemProgressMaximumCountDigits)
     {
         // Set the maximum number of digits.
         this.itemProgressMaximumCountDigits = digits;
     }
     else if (digits < this.itemProgressMaximumCountDigits)
     {
         // Else, update the count digits for all items.
         this.OnUpdateItemsProgress();
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Updates the legend geometrics characteristics for the specified progress item.
        /// </summary>
        /// <param name="item">The progress item.</param>
        private void OnUpdateItemLegendGeometrics(ProgressItem item)
        {
            // If the object has been disposed, do nothing.
            if (this.IsDisposed) return;
            // Compute whether th item displays the legend.
            item.geometrics.showLegend = this.itemMaximumFixedWidth < item.geometrics.itemBounds.Width;
            // Compute the text width scale.
            double widthScale = item.geometrics.showLegend ?
                (this.itemMaximumWidth > item.geometrics.itemBounds.Width) ? (item.geometrics.itemBounds.Width - this.itemMaximumFixedWidth) / ((double)this.itemMaximumVariableWidth) : 1.0 :
                (this.itemMaximumTextWidth > item.geometrics.itemBounds.Width) ? widthScale = item.geometrics.itemBounds.Width / ((double)this.itemMaximumTextWidth) : 1.0;

            // The legend bounds.
            item.geometrics.legendBounds = new Rectangle(
                item.geometrics.textBounds.Right,
                item.geometrics.contentBounds.Y,
                item.geometrics.contentBounds.Width - item.geometrics.textBounds.Width,
                item.geometrics.contentBounds.Height);
            // The legend text bounds.
            item.geometrics.legendTextBounds = new Rectangle(
                0,
                item.geometrics.legendBounds.Y,
                (int)((this.itemProgressLegendMaximumTextWidth + this.itemProgressMaximumCountWidth) * widthScale),
                item.geometrics.legendBounds.Height);
            // The legend icon bounds.
            item.geometrics.legendIconBounds = new Rectangle(new Point(0, item.geometrics.legendBounds.Y), this.legendSize);
            // The legend item width.
            item.geometrics.legendItemWidth = item.geometrics.legendIconBounds.Width + this.spacing + item.geometrics.legendTextBounds.Width + this.spacing;

            // Set the legend as valid.
            item.geometrics.validLegend = true;
        }
Esempio n. 6
0
        /// <summary>
        /// An event handler called to update the maximum legend entries for the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        private void OnUpdateItemLegend(ProgressItem item)
        {
            // If the object has been disposed, do nothing.
            if (this.IsDisposed) return;
            // Set the item legend as invalid.
            item.geometrics.validLegend = false;
            // Set the maximum number of legend items to zero.
            int count = 0;
            // Set the maximum text width to zero.
            int width = 0;

            // If the item has a progress info.
            if (null != item.Progress)
            {
                // If the item has a legend.
                if (null != item.Progress.Legend)
                {
                    // Get the legend.
                    ProgressLegend legend = item.Progress.Legend;

                    // Set the legent items count.
                    count = legend.Items.Count;
                    // Update the legend maximum items width.
                    foreach (ProgressLegendItem legendItem in legend.Items)
                    {
                        // Compute the legend item width.
                        int itemWidth = TextRenderer.MeasureText(legendItem.Text, this.Font).Width;
                        // Get the maximum width.
                        if (width < itemWidth)
                        {
                            width = itemWidth;
                        }
                    }
                }
            }

            // If the legend item count is greater, update the legend item count.
            if (count > this.itemProgressLegendMaximumCount)
            {
                this.itemProgressLegendMaximumCount = count;
            }

            // If the legend item width is greater, update the legend item width.
            if (width > this.itemProgressLegendMaximumTextWidth)
            {
                this.itemProgressLegendMaximumTextWidth = width;
            }

            // If either the legend item count or the legend item width is smaller, update all the legend for all items.
            if ((count < this.itemProgressLegendMaximumCount) || (width < this.itemProgressLegendMaximumTextWidth))
            {
                this.OnUpdateItemsLegend();
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Updates the geometrics characteristics of the specified progress item.
        /// </summary>
        /// <param name="item">The progress item.</param>
        /// <param name="bounds">The item bounds.</param>
        private void OnUpdateItemGeometrics(ProgressItem item, Rectangle bounds)
        {
            // If the object has been disposed, do nothing.
            if (this.IsDisposed) return;

            // Only updated the geometrics if the bounds are different.
            if (bounds != item.geometrics.bounds)
            {
                // Save the bounds.
                item.geometrics.bounds = bounds;

                // Compute the item bounds.
                item.geometrics.itemBounds = new Rectangle(
                    item.geometrics.bounds.X + this.itemPadding.Left,
                    item.geometrics.bounds.Y + this.itemPadding.Top,
                    item.geometrics.bounds.Width - this.itemPadding.Left - this.itemPadding.Right - 1,
                    item.geometrics.bounds.Height - this.itemPadding.Top - this.itemPadding.Bottom - 1);
                // Compute the progress border.
                item.geometrics.progressBorder = new Rectangle(
                    item.geometrics.itemBounds.X,
                    item.geometrics.itemBounds.Bottom - this.progressHeight,
                    item.geometrics.itemBounds.Width,
                    this.progressHeight);
                // Compute the progress bounds.
                item.geometrics.progressBounds = new Rectangle(
                    item.geometrics.progressBorder.X + 1,
                    item.geometrics.progressBorder.Y + 1,
                    item.geometrics.progressBorder.Width - 1,
                    item.geometrics.progressBorder.Height - 1);
                // Compute the content bounds.
                item.geometrics.contentBounds = new Rectangle(
                    item.geometrics.itemBounds.X,
                    item.geometrics.itemBounds.Y,
                    item.geometrics.itemBounds.Width,
                    item.geometrics.progressBorder.Top - item.geometrics.itemBounds.Y);
            }

            // Compute the text bounds.
            item.geometrics.textBounds = new Rectangle(
                item.geometrics.contentBounds.X,
                item.geometrics.contentBounds.Y,
                this.itemMaximumTextWidth,
                item.geometrics.contentBounds.Height);

            // If the legend is invalid, update the legend geometric characteristics.
            //if (!item.geometrics.validLegend)
                this.OnUpdateItemLegendGeometrics(item);
        }
Esempio n. 8
0
 /// <summary>
 /// An event handler called when an item has been removed from the progress list box.
 /// </summary>
 /// <param name="item">The item.</param>
 private void OnItemRemoved(ProgressItem item)
 {
     // If the item is null, do nothing.
     if (null == item) return;
     // Remove the item event handlers.
     item.TextChanged -= this.OnItemTextChanged;
     item.SubtextChanged -= this.OnItemSubtextChanged;
     item.EnabledChanged -= this.OnItemEnabledChanged;
     item.ProgressSet -= this.OnItemProgressSet;
     item.ProgressLevelChanged -= this.OnItemProgressLevelChanged;
     item.ProgressDefaultChanged -= this.OnItemProgressDefaultChanged;
     item.ProgressCountChanged -= this.OnItemProgressCountChanged;
     item.ProgressLegendSet -= this.OnItemProgressLegendSet;
     item.ProgressLegendChanged -= this.OnItemProgressLegendChanged;
     // Update the items text.
     this.OnUpdateItemsText();
     // Update the items progress.
     this.OnUpdateItemsProgress();
     // Update the items legend.
     this.OnUpdateItemsLegend();
     // Update the item measurements.
     this.OnUpdateGeometrics();
     // Refresh the list box.
     this.Refresh();
 }
 /// <summary>
 /// Creates a new event arguments instance.
 /// </summary>
 /// <param name="item">The progress item.</param>
 public ProgressItemEventArgs(ProgressItem item)
 {
     this.Item = item;
 }
        /// <summary>
        /// An event handler called when starting the PlanetLab commands.
        /// </summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnStart(object sender, EventArgs e)
        {
            // Get the session information.
            if (this.formRunInformation.ShowDialog(this) != DialogResult.OK)
            {
                // Return;
                return;
            }

            // Save the session information.
            this.sessionId = this.formRunInformation.Id;
            this.sessionAuthor = this.formRunInformation.Author;
            this.sessionDescription = this.formRunInformation.Description;
            this.sessionTimestamp = DateTime.Now;

            lock (this.managerSync)
            {
                // If the manager state is not null.
                if (null == this.managerState)
                {
                    // Create a list of nodes.
                    List<PlNode> nodes = new List<PlNode>();

                    // Clear the progress list.
                    this.listProgress.Items.Clear();
                    // Clear the list of progress items.
                    this.managerProgressItems.Clear();
                    // Clear the combo-box items.
                    this.comboBoxNodes.Items.Clear();

                    // Clear the results.
                    this.listViewResults.Items.Clear();
                    this.controlResult.Clear();

                    // For all the selected nodes.
                    foreach (ListViewItem item in this.listViewNodes.CheckedItems)
                    {
                        // Get the node information.
                        NodeInfo info = item.Tag as NodeInfo;

                        // If the node information does not have the PlanetLab node.
                        if (null == info.Node)
                        {
                            // Show an error message.
                            MessageBox.Show(this, "Cannot start the PlanetLab commands because the information on PlanetLab node {0} is missing. Refresh the slice information and try again.", "Cannot Execute PlanetLab Commands".FormatWith(info.NodeId), MessageBoxButtons.OK, MessageBoxIcon.Error);
                            // Log an event.
                            this.controlLog.Add(this.config.Log.Add(
                                LogEventLevel.Important,
                                LogEventType.Error,
                                ControlSliceRun.logSource.FormatWith(this.slice.Id),
                                "Cannot start the PlanetLab commands because the information on PlanetLab node {0} is missing. Refresh the slice information and try again.",
                                new object[] { info.NodeId }));
                            // Return.
                            return;
                        }

                        // Else, add the node to the list.
                        nodes.Add(info.Node);
                    }

                    // For all the selected nodes.
                    foreach (PlNode node in nodes)
                    {
                        // Create a progress list item.
                        ProgressItem item = new ProgressItem(node.Hostname, this.progressLegend);
                        // Set the item tag.
                        item.Tag = node;
                        // Set the item default progress.
                        item.Progress.Default = this.progressLegend.Items.Count - 1;
                        // Add the item to the list.
                        this.managerProgressItems.Add(item);

                        // Create a combo box item.
                        this.comboBoxNodes.Items.Add(node.Hostname);
                    }

                    // Add the items to the progress list.
                    this.listProgress.Items.AddRange(this.managerProgressItems.ToArray());

                    try
                    {

                        // Request a status lock.
                        this.status.Lock();

                        // Start the manager.
                        this.managerState = this.manager.Start(this.config, nodes);
                    }
                    catch (Exception exception)
                    {
                        // Release the status lock.
                        this.status.Unlock();

                        // Log an event.
                        this.controlLog.Add(this.config.Log.Add(
                            LogEventLevel.Important,
                            LogEventType.Error,
                            ControlSliceRun.logSource.FormatWith(this.slice.Id),
                            "An error occurred while starting the PlanetLab commands. {0}",
                            new object[] { exception.Message },
                            exception));
                    }
                }
                else
                {
                    try
                    {
                        // Else, call the manager.
                        this.manager.Resume(this.managerState);
                    }
                    catch (Exception exception)
                    {
                        // Log an event.
                        this.controlLog.Add(this.config.Log.Add(
                            LogEventLevel.Important,
                            LogEventType.Error,
                            ControlSliceRun.logSource.FormatWith(this.slice.Id),
                            "An error occurred while resuming the PlanetLab commands. {0}",
                            new object[] { exception.Message },
                            exception));
                    }
                }
            }
        }
 /// <summary>
 /// Creates a new event arguments instance.
 /// </summary>
 /// <param name="item">The progress item.</param>
 /// <param name="progress">The progress info.</param>
 /// <param name="legend">The legend.</param>
 public ProgressItemLegendChangedEventArgs(ProgressItem item, ProgressInfo progress, ProgressLegend legend)
     : base(item)
 {
     this.Progress = progress;
     this.Legend = legend;
 }