예제 #1
0
        public Form1()
        {
            InitializeComponent();
            // create a project manager
            var manager = new ProjectManager();
            // create built-in task or use your own derived task
            var task = new Braincase.GanttChart.Task() { Name = "Hello "};
            var task1 = new Braincase.GanttChart.Task() { Name = " World" };
            var task2 = new Braincase.GanttChart.Task() { Name = "Helly" };
            var task3 = new Braincase.GanttChart.Task() { Name = "Hel7875" };
            var task5 = new Braincase.GanttChart.Task() { Name = "gmmail" };


            // add the task to the manager
            manager.Add(task2);
            manager.Add(task);
            manager.Add(task1);

            manager.Add(task3);
            manager.Split(task2,task1,2);

            
            //manager.SetDuration(task, 3);
            
            // create a chart control
            var chart = new Chart();
            // initialise the chart with the manager
            chart.Init(manager);
            // add chart to the form controls collection.
            this.Controls.Add(chart);
            
            // throughout your own code, call chart.Invalidate()
            // where you expect updates to the drawn chart,
            // to tell the chart to Paint() itself.
        }
예제 #2
0
        public void DrawPeople(IEnumerable <string> names, RallyData data)
        {
            _data = data;

            Boxes.Clear();
            foreach (string name in names)
            {
                var task = new Braincase.GanttChart.Task {
                    ID = name, Name = name
                };
                Boxes.Add(name, task);
                _manager.Add(task);

                DrawNewLine();
            }

            List <Story> orderedStories = data.Stories.Values.OrderBy(o => o.StartDate).ToList();

            foreach (Story story in orderedStories)
            {
                var storyTask = new Braincase.GanttChart.Task();
                storyTask.ID   = story.FormattedID;
                storyTask.Name = GetStoryName(story);
                Boxes.Add(story.FormattedID, storyTask);
                _manager.Add(storyTask);
                _manager.Group(Boxes[story.Owner], storyTask);

                DrawStory(story, storyTask);
            }

            DrawIterations(data.Iterations.Values);
            _chart.Invalidate();
        }
예제 #3
0
        public void SetBoxLength(Braincase.GanttChart.Task task, DateTime start, DateTime end, List <string> tags)
        {
            int startdate = (start - _startDate).Days;
            int duration  = (end - start).Days;

            ParseStoryDates(tags, ref startdate, ref duration);

            _manager.SetStart(task, startdate / _chartScale);
            _manager.SetDuration(task, duration / _chartScale);
        }
예제 #4
0
        public void DrawStory(Story story, Braincase.GanttChart.Task box)
        {
            _manager.Add(box);

            string toolTip = story.Owner + " (" + story.IterationName + ")" + Environment.NewLine + story.Description;

            _chart.SetToolTip(box, toolTip);

            if (string.IsNullOrEmpty(story.IterationName))
            {
                box.Name = box.Name + " (Unscheduled)";
                _manager.SetDuration(box, 1);
                return;
            }

            string state = GetState(story);

            if (state == "Accepted" || state == "Completed")
            {
                _manager.SetComplete(box, 1f);
                box.IsAccepted = (state == "Accepted");
                box.Collapse(box.IsAccepted);
            }
            else if (state == "In-Progress")
            {
                float estimate  = GetEstimate(story);
                float remaining = GetRemaining(story);
                float progress  = (estimate - remaining) / estimate;
                if (float.IsNaN(progress) || progress == 0)
                {
                    progress = 0.1f;
                }
                _manager.SetComplete(box, progress);
            }

            if (story.EndDate > _startDate)
            {
                SetBoxLength(box, story.StartDate, story.EndDate, story.Tags);
            }

            foreach (var ppltask in story.Tasks)
            {
                Braincase.GanttChart.Task taskbox;
                if (!Boxes.TryGetValue(ppltask.FormattedID, out taskbox))
                {
                    continue;
                }

                DrawStory(ppltask, taskbox);
                box.Children.Add(taskbox);
            }
        }
예제 #5
0
        public Form1()
        {
            InitializeComponent();
            // create a project manager
            var manager = new ProjectManager();
            // create built-in task or use your own derived task
            var task = new Braincase.GanttChart.Task()
            {
                Name = "Hello "
            };
            var task1 = new Braincase.GanttChart.Task()
            {
                Name = " World"
            };
            var task2 = new Braincase.GanttChart.Task()
            {
                Name = "Helly"
            };
            var task3 = new Braincase.GanttChart.Task()
            {
                Name = "Hel7875"
            };
            var task5 = new Braincase.GanttChart.Task()
            {
                Name = "gmmail"
            };


            // add the task to the manager
            manager.Add(task2);
            manager.Add(task);
            manager.Add(task1);

            manager.Add(task3);
            manager.Split(task2, task1, 2);


            //manager.SetDuration(task, 3);

            // create a chart control
            var chart = new Chart();

            // initialise the chart with the manager
            chart.Init(manager);
            // add chart to the form controls collection.
            this.Controls.Add(chart);

            // throughout your own code, call chart.Invalidate()
            // where you expect updates to the drawn chart,
            // to tell the chart to Paint() itself.
        }
 private void ProjectsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     foreach (var p in Projects)
     {
         Braincase.GanttChart.Task _task = p.Tasks.FirstOrDefault();
         if (_task == ((Braincase.GanttChart.Task)ProjectsComboBox.SelectedItem))
         {
             _Chart.Init(p);
             _Chart.Invalidate();
             GanttHost.InvalidateVisual();
             return;
         }
     }
 }
예제 #7
0
        private void InitializeBoxes(IEnumerable <SagaFeature> sagas)
        {
            this.Boxes.Clear();
            this.SagaBoxes.Clear();
            this.StoryBoxes.Clear();
            var list = this.Boxes;

            foreach (var saga in sagas)
            {
                var sagaBox = new Braincase.GanttChart.Task {
                    ID = saga.FormattedID
                };
                sagaBox.Sizing     = 1.0f;
                sagaBox.Name       = "   " + saga.FormattedID + ": " + saga.Name;
                sagaBox.HeaderSize = HeaderSize.Big;

                list.Add(saga.FormattedID, sagaBox);
                this.SagaBoxes.Add(saga.FormattedID, sagaBox);

                foreach (var story in saga.Stories)
                {
                    var storyBox = new Braincase.GanttChart.Task {
                        ID = story.FormattedID
                    };
                    storyBox.Sizing     = 0.8f;
                    storyBox.Name       = GetStoryName(story);
                    storyBox.HeaderSize = HeaderSize.Medium;

                    list.Add(story.FormattedID, storyBox);
                    this.StoryBoxes.Add(story.FormattedID, storyBox);

                    foreach (var task in story.Tasks)
                    {
                        var taskBox = new Braincase.GanttChart.Task {
                            ID = task.FormattedID
                        };
                        taskBox.Sizing     = 0.5f;
                        taskBox.Name       = GetStoryName(task);
                        taskBox.HeaderSize = HeaderSize.Small;

                        list.Add(task.FormattedID, taskBox);
                    }
                }
            }
        }
예제 #8
0
파일: Form1.cs 프로젝트: radtek/RallyViewer
        private void ShowContextMenu(TaskMouseEventArgs e)
        {
            _selectedTask = e.Task;
            if (_selectedTask == null || string.IsNullOrEmpty(_selectedTask.ID))
            {
                return;
            }

            refreshToolStripMenuItem.Enabled    = setPredecessorToolStripMenuItem.Enabled = moveToToolStripMenuItem.Enabled =
                resizeToolStripMenuItem.Enabled = !_selectedTask.ID.ToLower().StartsWith("sf");

            setPredecessorToolStripMenuItem.DropDownItems.Clear();

            Story story;

            if (_data.Stories.TryGetValue(_selectedTask.ID, out story))
            {
                SagaFeature sf;
                if (story.SagaFeatureUUID != null &&
                    _data.Sagas.TryGetValue(story.SagaFeatureUUID, out sf))
                {
                    foreach (Story sibling in sf.Stories)
                    {
                        if (sibling == story)
                        {
                            continue;
                        }
                        var item = new ToolStripMenuItem(sibling.FormattedID);
                        item.Checked = story.Predecessors.Contains(sibling.FormattedID);
                        item.Click  += predecessorItem_Click;
                        setPredecessorToolStripMenuItem.DropDownItems.Add(item);
                    }
                }

                SetMoveMenu(story);
                SetResizeMenu(story);

                moveToToolStripMenuItem.Enabled = story.ProjectName == _data.ProjectName;
            }

            contextMenu.Show(_chart, e.Location);
        }
예제 #9
0
        public void Populate_list()
        {
            //var pmanager = new ProjectManager();
            pManager = new ProjectManager();
            ganttChart1.Init(pManager);

            taskList1.Items.Clear();
            //ColumnClickEventArgs args = new ColumnClickEventArgs(0);
            ColumnHeaderClick(this, new ColumnClickEventArgs(0));

            try
            {
                foreach (string project in Directory.EnumerateFiles(this.projdir, "*.xml"))
                {
                    XDocument doc = XDocument.Load(project);

                    var currPName = (from xml in doc.Element("Project").Descendants("Project_details")
                                     select xml.Element("Name").Value).First();

                    if (currPName == projname)
                    {
                        var query = from result in doc.Element("Project").Element("Tasks").Elements("Task")
                                    select result;
                        var membersquery = from result in doc.Element("Project").Element("Members").Elements("Member")
                                           select result;

                        if (query.Count() != 0)
                        {
                            string id;
                            string taskname;
                            string startdate;
                            string enddate;
                            string progress;

                            foreach (var fv in query)
                            {
                                id        = fv.Element("Id").Value;
                                taskname  = fv.Element("Name").Value;
                                startdate = fv.Element("Start_date").Value;
                                enddate   = fv.Element("End_date").Value;
                                progress  = fv.Element("Progress").Value;

                                //pManager.Add(new Braincase.GanttChart.Task() { Name = taskname });

                                List <string> row2 = new List <string>();
                                row2.Add(taskname); row2.Add(id); row2.Add(startdate); row2.Add(enddate); row2.Add(progress); //row2.Add(members);
                                string[] r2 = { row2[1], row2[2], row2[3], row2[4] };
                                taskList1.Items.Add(row2[0]).SubItems.AddRange(r2);
                            }

                            //Teraz należy posegregować zadania po datach i narysować je w wykresie Gantta
                            List <DateTime> tempstartdList = new List <DateTime>();
                            List <DateTime> tempenddList   = new List <DateTime>();
                            List <string>   tasknamesList  = new List <string>();
                            foreach (ListViewItem itm in taskList1.Items)
                            {
                                tempstartdList.Add(DateTime.ParseExact(itm.SubItems[2].Text, "dd/MM/yyyy", System.Globalization.CultureInfo.CurrentCulture));
                                tempenddList.Add(DateTime.ParseExact(itm.SubItems[3].Text, "dd/MM/yyyy", System.Globalization.CultureInfo.CurrentCulture));
                                tasknamesList.Add(itm.Text);
                            }
                            //Sortowanie dat od najwcześniejszych do najpóźniejszych
                            for (int j = 0; j < tempstartdList.Count; j++)
                            {
                                for (int i = 1; i < tempstartdList.Count; i++)
                                {
                                    if (tempstartdList[i - 1] > tempstartdList[i])
                                    {
                                        DateTime tempstartdate = tempstartdList[i];
                                        DateTime tempenddate   = tempenddList[i];
                                        string   tempname      = tasknamesList[i];

                                        tempstartdList[i] = tempstartdList[i - 1];
                                        tempenddList[i]   = tempenddList[i - 1];
                                        tasknamesList[i]  = tasknamesList[i - 1];

                                        tempstartdList[i - 1] = tempstartdate;
                                        tempenddList[i - 1]   = tempenddate;
                                        tasknamesList[i - 1]  = tempname;
                                    }
                                }
                            }
                            ////foreach (var itm in tempstartdList) MessageBox.Show("" + itm.Date.ToString("dd/MM/yyyy"));
                            var span = tempenddList.Max(t => t.Date) - tempstartdList.Min(g => g.Date);
                            pManager.Start = tempstartdList[0];
                            //pManager.Now = (int)Math.Round(span.TotalDays);
                            for (int i = 0; i < tempstartdList.Count; i++)
                            {
                                Braincase.GanttChart.Task generatedtask = new Braincase.GanttChart.Task()
                                {
                                    Name = tasknamesList[i]
                                };
                                var taskduration = tempenddList[i] - tempstartdList[i];
                                int taskstart    = (int)(tempstartdList[i].Date - tempstartdList[0].Date).TotalDays;
                                pManager.Add(generatedtask);
                                pManager.SetStart(generatedtask, taskstart);//Convert.ToInt32(tempstartdList[i]));
                                pManager.SetDuration(generatedtask, (int)taskduration.TotalDays);
                                //pManager.Add(new Braincase.GanttChart.Task() { Name = taskname });
                                //ganttChart1.Invalidate();
                            }
                            ColumnHeaderClick(this, new ColumnClickEventArgs(1));

                            //ganttChart1.Invalidate();
                            break;
                        }
                    }
                }
            }
            catch (DirectoryNotFoundException)
            {
                ShowMessage(0, null);
            }
            catch (XmlException)
            {
                ShowMessage(1, null);
            }
            catch (Exception e)
            {
                ShowMessage(2, e);
            }
        }
예제 #10
0
 private void DrawNewLine()
 {
     Braincase.GanttChart.Task end = new Braincase.GanttChart.Task();
     _manager.Add(end);
     _manager.SetStart(end, 365);
 }