Esempio n. 1
0
        /********************************************************************************************
        ********************************************************************************************
        ** Auxillery methods
        ********************************************************************************************
        ********************************************************************************************/

        // Color the cell according to the State
        protected void ColorCellAccordingToState(DataGridViewCell cell, string state)
        {
            cell.Style.BackColor = DecisionStateColor.ConvertStateToColor(state);
            HSLColor hsl = DecisionStateColor.ConvertStateToColor(state);

            hsl.Luminosity = (hsl.Luminosity * SelectionLuminosityFactor);
            hsl.Saturation = (hsl.Saturation * SelectionSaturationFactor);
            cell.Style.SelectionBackColor = hsl;
        }
        public CreateDecisionDialog(string nameProposal)
        {
            InitializeComponent();
            comboState.DataSource   = EAConstants.States.ToList();
            comboState.SelectedItem = EAConstants.StateDecided;
            comboState.BackColor    = DecisionStateColor.ConvertStateToColor(EAConstants.StateDecided);
            textName.Text           = nameProposal;
            comboBox1.DataSource    = EAMain.Repository.GetAllPackages();
            comboBox1.DisplayMember = "Name";
            comboBox1.ValueMember   = "GUID";

            if (comboBox1.Items.Count == 0)
            {
                errorProvider1.SetError(comboBox1, Messages.ErrorSelectDecisionViewPackage);
                createButton.Enabled = false;
            }
        }
        private Color GetColorForAction(string action)
        {
            switch (action.ToLower())
            {
            case "propose":
                return(DecisionStateColor.ConvertStateToColor("Idea"));

            case "reject":
                return(DecisionStateColor.ConvertStateToColor("Rejected"));

            case "confirm":
                return(DecisionStateColor.ConvertStateToColor("Approved"));

            case "challenge":
                return(DecisionStateColor.ConvertStateToColor("Challenged"));

            case "discard":
                return(DecisionStateColor.ConvertStateToColor("Discarded"));
            }
            return(DecisionStateColor.ConvertStateToColor("Approved"));
        }
        private void DrawEntry(IHistoryEntry entry, DataGridViewCellPaintingEventArgs e, int i)
        {
            var color = DecisionStateColor.ConvertStateToColor(entry.State);

            var rectangle = new Rectangle(
                e.CellBounds.X + RectangleMargin,
                e.CellBounds.Y + (i * dataGridView1.RowTemplate.Height) + RectangleMargin,
                e.CellBounds.Width - (2 * RectangleMargin),
                dataGridView1.RowTemplate.Height - 2 * RectangleMargin);


            var path = RoundedRectangle.Create(rectangle);

            e.Graphics.FillPath(new SolidBrush(color), path);

            //e.Graphics.FillRectangle(new SolidBrush(color), rectangle);

            var text       = entry.Decision.Name;
            var temp       = text;
            var stringSize = e.Graphics.MeasureString(text, DefaultFont);

            while (stringSize.Width > rectangle.Width)
            {
                if (text.Length < 2)
                {
                    break;
                }
                text       = text.Substring(0, text.Length - 2);
                temp       = text + "..";
                stringSize = e.Graphics.MeasureString(temp, DefaultFont);
            }
            var horizontalMargin = (rectangle.Width - stringSize.Width) / 2;
            var verticalMargin   = (rectangle.Height - stringSize.Height) / 2;



            var textRectangle = new RectangleF(rectangle.X + horizontalMargin, rectangle.Y + verticalMargin, stringSize.Width, stringSize.Height);

            e.Graphics.DrawString(temp, DefaultFont, Brushes.Black, textRectangle);
        }
Esempio n. 5
0
 /// <summary>
 /// Retrieves the colour belonging to the state
 /// </summary>
 /// <param name="state"></param>
 /// <returns></returns>
 private Color RetrieveColorByState(string state)
 {
     return(DecisionStateColor.ConvertStateToColor(state));
 }
 /// <summary>
 ///     Change background color of state combobox to state color.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cbxState_SelectedValueChanged(object sender, EventArgs e)
 {
     cbxState.BackColor = DecisionStateColor.ConvertStateToColor(cbxState.Text);
 }
        private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            if (IsNameRow(e.RowIndex))
            {
                return;
            }

            e.Graphics.FillRectangle(Brushes.White, e.CellBounds);                                                                    //background
            e.Graphics.DrawLine(Pens.Black, e.CellBounds.Left, e.CellBounds.Bottom - 1, e.CellBounds.Right, e.CellBounds.Bottom - 1); //border

            var action = GetStakeholderActionForRow(e.RowIndex);


            //var horizontalRectMargin = (e.CellBounds.Width - RectangleWidth)/2;
            var horizontalRectMargin = (e.CellBounds.Width - RectangleWidth - ActionWidth - ArrowWidth) / 2;
            var verticalRectMargin   = 5;

            var actionColor = DecisionStateColor.ConvertStateToColor(action.Decision.State);

            if (_currentSortState == SortState.Stakeholder)
            {
                actionColor = GetColorForAction(action.Action);
            }


            //draw action button
            var actionRectangle = new Rectangle(
                e.CellBounds.X + horizontalRectMargin,
                e.CellBounds.Y + verticalRectMargin,
                ActionWidth,
                dataGridView1.RowTemplate.Height - 2 * verticalRectMargin);
            var actionPath = RoundedRectangle.Create(actionRectangle);

            e.Graphics.FillPath(new SolidBrush(actionColor), actionPath);

            var text = GetActionButtonText(action);

            DrawText(e.Graphics, text, actionRectangle);

            //draw arrow between
            var arrowPen = new Pen(Color.Black, 5f);

            arrowPen.StartCap = LineCap.Flat;
            arrowPen.EndCap   = LineCap.ArrowAnchor;
            e.Graphics.DrawLine(arrowPen,
                                e.CellBounds.X + horizontalRectMargin + ActionWidth + ArrowMargin,
                                e.CellBounds.Y + (e.CellBounds.Height / 2),
                                e.CellBounds.X + horizontalRectMargin + ActionWidth + ArrowWidth - ArrowMargin,
                                e.CellBounds.Y + (e.CellBounds.Height / 2)
                                );

            var color = DecisionStateColor.ConvertStateToColor(action.Decision.State);

            if (_currentSortState == SortState.Decision)
            {
                color = GetColorForAction(action.Action);
            }
            var decisionRectangle = new Rectangle(
                e.CellBounds.X + horizontalRectMargin + ActionWidth + ArrowWidth,
                e.CellBounds.Y + verticalRectMargin,
                RectangleWidth,
                dataGridView1.RowTemplate.Height - 2 * verticalRectMargin);


            text = GetReceiverButtonText(action);
            var path = RoundedRectangle.Create(decisionRectangle);

            e.Graphics.FillPath(new SolidBrush(color), path);
            DrawText(e.Graphics, text, decisionRectangle);

            //var text = ActionToSentence(action.Action, action.Decision);
            //var stringSize = e.Graphics.MeasureString(text, DefaultFont);
            //var horizontalMargin = (rectangle.Width - stringSize.Width) / 2;
            //var verticalMargin = (rectangle.Height - stringSize.Height) / 2;



            //textRectangle = new RectangleF(rectangle.X + horizontalMargin, rectangle.Y + verticalMargin, stringSize.Width, stringSize.Height);
            //e.Graphics.DrawString(text, DefaultFont, Brushes.Black, textRectangle);
            e.Handled = true;
        }
 private void comboState_SelectedValueChanged(object sender, EventArgs e)
 {
     comboState.BackColor = DecisionStateColor.ConvertStateToColor(GetState());
 }