private void CodeMetricComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            Cursor currentCursor = Cursor.Current;

            try
            {
                Cursor.Current = Cursors.WaitCursor;

                CodeMetric codeMetric = this.codeMetricComboBox.ComboBox.SelectedItem as CodeMetric;
                if (codeMetric != null)
                {
                    CodeMetricView codeMetricView = new CodeMetricView(codeMetric, this.serviceProvider);

                    this.contentHost.Controls.Add(codeMetricView);
                    codeMetricView.Activate();

                    for (int i = this.contentHost.Controls.Count - 2; i >= 0; i--)
                    {
                        this.contentHost.Controls.RemoveAt(i);
                    }
                }
            }
            finally
            {
                Cursor.Current = currentCursor;
            }
        }
Example #2
0
        public CodeMetricEventArgs(CodeMetric codeMetric)
        {
            if (codeMetric == null)
            {
                throw new ArgumentNullException("codeMetric");
            }

            this.codeMetric = codeMetric;
        }
Example #3
0
        protected override void OnValidate(object value)
        {
            base.OnValidate(value);

            CodeMetric codeMetric = value as CodeMetric;

            if (codeMetric == null)
            {
                throw new ArgumentNullException("value");
            }
        }
        private void CodeMetric_Progress(Object sender, ComputationProgressEventArgs e)
        {
            CodeMetric codeMetric = sender as CodeMetric;

            int index = this.codeMetricManager.CodeMetrics.IndexOf(codeMetric);
            int count = this.codeMetricManager.CodeMetrics.Count;

            int percentComplete = ((index * 100) + (e.PercentComplete)) / count;

            if (percentComplete > 100)
            {
                percentComplete = 100;
            }

            this.Invoke(new StatusBarUpdateCallback(this.StatusBarUpdate), new object[] { percentComplete });
        }
        private void EndRunUpdate()
        {
            this.contentHost.Controls.Clear();
            this.codeMetricComboBox.ComboBox.Items.Clear();

            if (this.codeMetricManager.IsAbortPending())
            {
                this.NewAnalysis();
            }
            else if (this.codeMetricManager.ErrorException != null)
            {
                throw this.codeMetricManager.ErrorException;
            }
            else
            {
                this.startButton.Image   = CommandBarImages.New;
                this.startButton.Text    = "New Analysis";
                this.startButton.Enabled = true;

                this.saveButton.Enabled = true;
                this.copyButton.Enabled = true;

                CodeMetric activeCodeMetric = null;

                foreach (CodeMetric codeMetric in this.codeMetricManager.CodeMetrics)
                {
                    this.codeMetricComboBox.ComboBox.Items.Add(codeMetric);

                    if (activeCodeMetric == null)
                    {
                        activeCodeMetric = codeMetric;
                    }
                }

                if (this.codeMetricComboBox.ComboBox.SelectedItem == null)
                {
                    this.codeMetricComboBox.ComboBox.SelectedItem = activeCodeMetric;
                }

                this.codeMetricComboBox.ComboBox.Enabled = true;
            }

            System.Windows.Forms.Application.DoEvents();
        }
Example #6
0
            public CodeMetricTreeMap(CodeMetric codeMetric)
            {
                this.codeMetric = codeMetric;

                this.SuspendLayout();

                this.treeMap          = new TreemapControl();
                this.treeMap.Dock     = DockStyle.Fill;
                this.treeMap.MinColor = Color.Red;
                this.treeMap.MaxColor = Color.Green;
                this.treeMap.DiscreteNegativeColors = 50;
                this.treeMap.DiscretePositiveColors = 50;
                this.treeMap.PaddingPx            = 1;
                this.treeMap.PenWidthPx           = 1;
                this.treeMap.SelectedNodeChanged += new TreemapControl.NodeEventHandler(this.TreeMap_SelectedNodeChanged);
                this.Controls.Add(this.treeMap);

                this.ResumeLayout();

                this.Populate();
            }
Example #7
0
        public CodeMetricView(CodeMetric codeMetric, IServiceProvider serviceProvider) : base(codeMetric.DisplayName)
        {
            this.TabStop = false;
            this.Dock    = DockStyle.Fill;

            this.assemblyBrowser = (IAssemblyBrowser)serviceProvider.GetService(typeof(IAssemblyBrowser));

            this.codeMetric = codeMetric;

            this.searchBox              = new TextBox();
            this.searchBox.TabIndex     = 1;
            this.searchBox.Dock         = DockStyle.Top;
            this.searchBox.TextChanged += new EventHandler(this.SearchBox_TextChanged);

            this.listView          = new CodeMetricListView(codeMetric);
            this.listView.TabIndex = 2;

            this.splitter      = new Splitter();
            this.splitter.Dock = DockStyle.Bottom;

            switch (codeMetric.Level)
            {
            case CodeMetricLevel.Type:
            case CodeMetricLevel.Module:
                this.treeMap         = new CodeMetricTreeMap(codeMetric);
                this.treeMap.TabStop = false;
                this.treeMap.Dock    = DockStyle.Bottom;
                this.treeMap.Height  = 200;
                break;
            }

            this.padding         = new Control();
            this.padding.TabStop = false;
            this.padding.Size    = new Size(1, 1);
            this.padding.Dock    = DockStyle.Top;
        }
Example #8
0
            public CodeMetricListView(CodeMetric codeMetric)
            {
                this.codeMetric = codeMetric;

                this.Dock           = DockStyle.Fill;
                this.View           = View.Details;
                this.FullRowSelect  = true;
                this.HeaderStyle    = ColumnHeaderStyle.Clickable;
                this.HideSelection  = false;
                this.SmallImageList = BrowserResource.ImageList;

                DataTable dataTable = this.codeMetric.Result;

                int columns = dataTable.Columns.Count;

                int index = 0;

                foreach (DataColumn column in dataTable.Columns)
                {
                    ColumnHeader columnHeader = new ColumnHeader();
                    columnHeader.Text  = column.ColumnName;
                    columnHeader.Width = (index == 0) ? 250 : 50;

                    this.Columns.Add(columnHeader);
                    index++;
                }

                foreach (DataRow row in dataTable.Rows)
                {
                    ListViewItem item = new ListViewItem();
                    item.Tag = row;
                    object target = this.codeMetric.FindItem(row);

                    if (target != null)
                    {
                        IMethodDeclaration methodDeclaration = target as IMethodDeclaration;
                        if (methodDeclaration != null)
                        {
                            item.ImageIndex = IconHelper.GetImageIndex(methodDeclaration);
                            item.ForeColor  = Color.FromArgb(IconHelper.GetColorDeclaringType(methodDeclaration));
                        }

                        ITypeDeclaration typeDeclaration = target as ITypeDeclaration;
                        if (typeDeclaration != null)
                        {
                            item.ImageIndex = IconHelper.GetImageIndex(typeDeclaration);
                            item.ForeColor  = Color.FromArgb(IconHelper.GetColor(typeDeclaration));
                        }

                        IModule module = target as IModule;
                        if (module != null)
                        {
                            item.ImageIndex = BrowserResource.Module;
                        }
                    }

                    item.Text = (string)row[0];

                    for (int i = 1; i < columns; i++)
                    {
                        ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem();
                        subItem.Text = row[i].ToString();
                        item.SubItems.Add(subItem);
                    }

                    this.Items.Add(item);

                    index++;
                }
            }
 public void Register(CodeMetric codeMetric)
 {
     this.codeMetrics.Add(codeMetric);
 }
Example #10
0
 public int IndexOf(CodeMetric value)
 {
     return(this.List.IndexOf(value));
 }
Example #11
0
 public void Add(CodeMetric value)
 {
     this.List.Add(value);
 }