private void GanttTimeline_MouseMove(Object sender, MouseEventArgs e)
        {
            List <string> toolTipText = new List <string>();

            if (ganttTimeline.MouseOverRowText.Length > 0)
            {
                BarInformation val = (BarInformation)ganttTimeline.MouseOverRowValue;
                toolTipText.Add("[b]Date:");
                toolTipText.Add("From ");
                toolTipText.Add(val.FromTime.ToLongDateString() + " - " + val.FromTime.ToString("HH:mm"));
                toolTipText.Add("To ");
                toolTipText.Add(val.ToTime.ToLongDateString() + " - " + val.ToTime.ToString("HH:mm"));
            }
            else
            {
                toolTipText.Add("");
            }

            ganttTimeline.ToolTipTextTitle = ganttTimeline.MouseOverRowText;
            ganttTimeline.ToolTipText      = toolTipText;
        }
Example #2
0
        //Methode voor popup informatie van chart 1
        void ganttChart1_MouseMove(object sender, MouseEventArgs e)
        {
            List <String> toolTipText = new List <String>();

            BarInformation bar = (BarInformation)ganttChart1.MouseOverRowValue;

            if (bar != null)
            {
                if (bar.Color == Color.DarkRed)
                {
                    type = "Offerte";
                }
                else if (bar.Color == Color.CornflowerBlue)
                {
                    type = "Opdracht";
                }
                else if (bar.Color == Color.Gray)
                {
                    type = "Factuur";
                }
                else if (bar.Color == Color.DarkGreen)
                {
                    type = "Contract";
                }
            }
            else
            {
            }

            if (ganttChart1.MouseOverRowText.Length > 0)
            {
                toolTipText.Add("Type: " + type);
                toolTipText.Add("Begin: " + bar.FromTime.ToString());
                toolTipText.Add("Einde: " + bar.ToTime.ToString());
            }

            ganttChart1.ToolTipTextTitle = ganttChart1.MouseOverRowText;
            ganttChart1.ToolTipText      = toolTipText;
        }
Example #3
0
        public static GanttChart.GanttChart returnGantt(Project project)
        {
            /*
             * This method takes a project and returns a Gantt Chart object that can be displayed and manipulated
             */
            GanttChart.GanttChart ganttChart1 = new GanttChart.GanttChart();
            try
            {
                //Gantt chart settings
                ganttChart1.AllowChange = false;
                ganttChart1.FromDate    = project.dateStarted.AddDays(-2);
                ganttChart1.ToDate      = ModelView.taskLastFinishing(project).AddDays(2);
                ganttChart1.GridColor   = Pens.Black;
                ganttChart1.ForeColor   = Color.Black;
                ganttChart1.BackColor   = UI.chartColour;
                int barIndex = 0;

                //For each task add a relevant row in the gantt chart
                foreach (Task task in project.taskList)
                {
                    string   taskName      = task.TaskName;
                    DateTime fromTime      = task.StartDate;
                    DateTime toTime        = task.EstimatedFinishingDate;
                    Color    barColor      = UI.dataPointColour;
                    Color    barHoverColor = UI.dataPointHoverColour;
                    barIndex++;

                    BarInformation bInf = new BarInformation(taskName, fromTime, toTime, barColor, barHoverColor, barIndex);

                    ganttChart1.AddChartBar(taskName, bInf, fromTime, toTime, barColor, barHoverColor, barIndex);
                }
                return(ganttChart1);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Example #4
0
        public void GanttChart_MouseMove(object sender, MouseEventArgs e)
        {
            if (shownHeaderList == null)
            {
                return;
            }
            if (shownHeaderList.Count == 0)
            {
                return;
            }

            if (e.Button != System.Windows.Forms.MouseButtons.Left)
            {
                //mouseHoverPart = MouseOverPart.Empty;

                // If bar has changed manually, but left mouse button is no longer pressed the BarChanged event will be raised

                if (AllowManualEditBar == true)
                {
                    if (barIsChanging >= 0)
                    {
                        if (AllowChange)
                        {
                            if (BarChanged != null)
                            {
                                BarChanged(bars[barIsChanging].Value, new EventArgs());
                            }

                            BarInformation barInfo   = bars[barIsChanging].Value as BarInformation;
                            DateTime       tempValue = _mouseOverColumnValue;
                            if (mouseHoverPart == MouseOverPart.BarLeftSide)
                            {
                                barInfo.FromTime = tempValue;
                            }
                            else if (mouseHoverPart == MouseOverPart.BarRightSide)
                            {
                                barInfo.ToTime = tempValue;
                            }
                        }
                        barIsChanging = -1;
                    }
                }

                mouseHoverPart = MouseOverPart.Empty;
            }

            mouseHoverBarIndex = -1;

            Point LocalMousePosition = default(Point);

            LocalMousePosition = PointToClient(Cursor.Position);

            // Finds pixels per minute

            TimeSpan timeBetween    = shownHeaderList[1].Time - shownHeaderList[0].Time;
            int      minutesBetween = (timeBetween.Days * 1440) + (timeBetween.Hours * 60) + timeBetween.Minutes;
            dynamic  widthBetween   = (shownHeaderList[1].StartLocation - shownHeaderList[0].StartLocation);
            float    perMinute      = (float)widthBetween / (float)minutesBetween;

            if (perMinute == 0)
            {
                perMinute = 1;
            }

            // Finds the time at mousepointer

            int minutesAtCursor = 0;

            if (LocalMousePosition.X > barStartLeft)
            {
                minutesAtCursor       = (int)((LocalMousePosition.X - barStartLeft) / perMinute);
                _mouseOverColumnValue = FromDate.AddMinutes(minutesAtCursor);
            }
            else
            {
                _mouseOverColumnValue = DateTime.MinValue;
            }

            // Finds the row at mousepointer

            string rowText  = "";
            object rowValue = null;

            // Tests to see if the mouse pointer is hovering above the scrollbar

            bool scrollBarStatusChanged = false;

            // Tests to see if the mouse is hovering over the scroll-area bottom-arrow

            if (LocalMousePosition.X > BottomPart.Left & LocalMousePosition.Y < BottomPart.Right & LocalMousePosition.Y <BottomPart.Bottom& LocalMousePosition.Y> BottomPart.Top)
            {
                if (mouseOverBottomPart == false)
                {
                    scrollBarStatusChanged = true;
                }

                mouseOverBottomPart = true;
            }
            else
            {
                if (mouseOverBottomPart == false)
                {
                    scrollBarStatusChanged = true;
                }

                mouseOverBottomPart = false;
            }

            // Tests to see if the mouse is hovering over the scroll-area top-arrow

            if (LocalMousePosition.X > topPart.Left & LocalMousePosition.Y < topPart.Right & LocalMousePosition.Y <topPart.Bottom& LocalMousePosition.Y> topPart.Top)
            {
                if (mouseOverTopPart == false)
                {
                    scrollBarStatusChanged = true;
                }

                mouseOverTopPart = true;
            }
            else
            {
                if (mouseOverTopPart == false)
                {
                    scrollBarStatusChanged = true;
                }

                mouseOverTopPart = false;
            }

            // Tests to see if the mouse is hovering over the scroll

            if (LocalMousePosition.X > scroll.Left & LocalMousePosition.Y < scroll.Right & LocalMousePosition.Y <scroll.Bottom& LocalMousePosition.Y> scroll.Top)
            {
                if (mouseOverScrollBar == false)
                {
                    scrollBarStatusChanged = true;
                }

                mouseOverScrollBar     = true;
                mouseOverScrollBarArea = true;
            }
            else
            {
                if (mouseOverScrollBar == false)
                {
                    scrollBarStatusChanged = true;
                }

                mouseOverScrollBar     = false;
                mouseOverScrollBarArea = false;
            }

            // If the mouse is not above the scroll, test if it's over the scroll area (no need to test if it's not above the scroll)

            if (mouseOverScrollBarArea == false)
            {
                if (LocalMousePosition.X > scrollBarArea.Left & LocalMousePosition.Y < scrollBarArea.Right & LocalMousePosition.Y <scrollBarArea.Bottom& LocalMousePosition.Y> scrollBarArea.Top)
                {
                    mouseOverScrollBarArea = true;
                }
            }


            // Tests to see if the mouse pointer is hovering above a bar

            int index = 0;


            foreach (ChartBarDate bar in bars)
            {
                // If the bar is set to be hidden from mouse move, the current bar will be ignored

                if (bar.HideFromMouseMove == false)
                {
                    if (bar.EndValue == null)
                    {
                        bar.EndValue = DateTime.Now;
                    }

                    // Mouse pointer needs to be inside the X and Y positions of the bar

                    if (LocalMousePosition.Y > bar.TopLocation.Left.Y & LocalMousePosition.Y < bar.BottomLocation.Left.Y)
                    {
                        if (LocalMousePosition.X > bar.TopLocation.Left.X & LocalMousePosition.X < bar.TopLocation.Right.X)
                        {
                            // If the current bar is the one where the mouse is above, the rowText and rowValue needs to be set correctly

                            rowText            = bar.Text;
                            rowValue           = bar.Value;
                            mouseHoverBarIndex = index;

                            if (mouseHoverPart != MouseOverPart.BarLeftSide & mouseHoverPart != MouseOverPart.BarRightSide)
                            {
                                mouseHoverPart = MouseOverPart.Bar;
                            }
                        }

                        // If mouse pointer is near the edges of the bar it will open up for editing the bar

                        if (AllowManualEditBar == true)
                        {
                            int areaSize = 5;

                            if (e.Button == System.Windows.Forms.MouseButtons.Left)
                            {
                                areaSize = 50;
                            }

                            if (LocalMousePosition.X > bar.TopLocation.Left.X - areaSize & LocalMousePosition.X < bar.TopLocation.Left.X + areaSize & mouseHoverPart != MouseOverPart.BarRightSide)
                            {
                                Cursor             = Cursors.VSplit;
                                mouseHoverPart     = MouseOverPart.BarLeftSide;
                                mouseHoverBarIndex = index;
                            }
                            else if (LocalMousePosition.X > bar.TopLocation.Right.X - areaSize & LocalMousePosition.X < bar.TopLocation.Right.X + areaSize & mouseHoverPart != MouseOverPart.BarLeftSide)
                            {
                                Cursor             = Cursors.VSplit;
                                mouseHoverPart     = MouseOverPart.BarRightSide;
                                mouseHoverBarIndex = index;
                            }
                            else
                            {
                                Cursor = Cursors.Default;
                            }
                        }
                    }
                }

                index += 1;
            }

            // Sets the mouseover row value and text

            _mouseOverRowText  = rowText;
            _mouseOverRowValue = rowValue;

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                if (MouseDragged != null)
                {
                    MouseDragged(sender, e);
                }
            }
            else
            {
                // A simple test to see if the mousemovement has caused any changes to how it should be displayed
                // It only redraws if mouse moves from a bar to blank area or from blank area to a bar
                // This increases performance compared to having a redraw every time a mouse moves

                if ((_mouseOverRowValue == null & (rowValue != null)) | ((_mouseOverRowValue != null) & rowValue == null) | scrollBarStatusChanged == true)
                {
                    PaintChart();
                }
            }
        }