Example #1
0
        /// <summary>
        /// Handler when the user has added a risk to the project.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addRiskToProject(object sender, AddRiskToProjectEvent e)
        {
            if (e.projectID != this.projectID)
            {
                return;
            }
            ARA_ListItem clickedText = (ARA_ListItem)sender;

            if (clickedText != null)
            {
                //Is the risk already in the project?
                if (clickedText.BackgroundColor == ARA_Colors.ARA_Green)
                {
                    //Change its color and remove it from the database.
                    clickedText.BackgroundColor = Color.White;
                    this.queriesTableAdapter1.Delete_From_ProjectRisks(e.projectID, e.riskID);
                }
                else
                {
                    //Change its color and add a new risk to the database.
                    clickedText.BackgroundColor = ARA_Colors.ARA_Green;
                    this.queriesTableAdapter1.Insert_In_ProjectRisks(e.projectID, e.riskID);
                }
                //Update the text.
                clickedText.Invalidate();
            }

            //Let the application know we added a risk.
            ARA_Events.triggerRiskAddedToProjectEvent(this.projectID);
        }
Example #2
0
        /// <summary>
        /// Add style for the listItems.
        /// </summary>
        /// <param name="listParent"></param>
        /// <param name="listItem"></param>
        private void styleListItemAsRisk(ARA_ListGroup listParent, ARA_ListItem listItem)
        {
            listItem.Font = new System.Drawing.Font(ARA_Globals.ARA_Font, ARA_Globals.ARA_BaseFontSize - 4F);
            listItem.HorizontalAlignment = System.Drawing.StringAlignment.Near;
            listItem.Location            = new System.Drawing.Point(111, 65);
            listItem.Margin     = new System.Windows.Forms.Padding(0);
            listItem.Size       = new System.Drawing.Size(750, 24);
            listItem.Name       = "addRisksToProjectTextID";
            listItem.ListParent = listParent;

            listParent.addChild(listItem);
            listParent.addControlToDropDownButton(listItem);
            listItem.Scale(new SizeF(ARA_Globals.ARA_BaseFontSize / ARA_Constants.noScaleFontSize, ARA_Globals.ARA_BaseFontSize / ARA_Constants.noScaleFontSize));
        }
Example #3
0
        /// <summary>
        /// Add risks in component type into the component type listGroup.
        /// </summary>
        /// <param name="parentGroup"></param>
        /// <param name="parentType"></param>
        public void addRiskControlsToTypeControl(ARA_ListGroup parentGroup, ARA_ListGroup parentType)
        {
            //Did we already create the controls?
            if (parentType.ARA_ListGroupDropDownButton.ConnectedPanel.Controls.Count != 0)
            {
                return;
            }
            //Execute querye and loop through the results.
            foreach (DataRow datarow in this.get_Risks_In_ProjectGroupTypeTableAdapter.GetData(this.projectID, parentGroup.DropDownButtonText, parentType.DropDownButtonText).Rows)
            {
                ARA_ListItem listItem = new ARA_ListItem();
                styleListItemAsRisk(parentType, listItem);

                if (datarow["FileObject"].ToString() != "")
                {
                    var data   = (Byte[])(datarow["FileObject"]);
                    var stream = new MemoryStream(data);
                    listItem.Tag = Image.FromStream(stream);
                }

                //Set text of listItem.
                listItem.TextFirstControl  = "ID " + datarow["RiskID"].ToString();
                listItem.TextSecondControl = datarow["HazardSituation"].ToString();
                listItem.BackgroundColor   = datarow["InProject"].ToString() == "1" ? ARA_Colors.ARA_Green : System.Drawing.Color.White;

                //Add let it execute an event on click.
                listItem.Click += delegate(object o, System.EventArgs e)
                {
                    ARA_Events.triggerAddRiskToProjectEvent(o, this.projectID, Int32.Parse(datarow["RiskID"].ToString()));
                };
                listItem.addFunction(delegate()
                {
                    listItem.BackgroundColor = this.is_Risk_In_ProjectTableAdapter.GetData(this.projectID, Int32.Parse(datarow["RiskID"].ToString())).Rows[0]["InProject"].ToString() == "1" ? ARA_Colors.ARA_Green : Color.White;
                });
            }
        }