Example #1
0
        private void ReturnUserData(object sender, FormClosingEventArgs e)
        {
            var name        = NameTextBox.Text;
            var description = DescriptionTextBox.Text;
            var owner       = OwnerComboBox.Text;
            var link        = LinkTextBox.Text;
            var hasDate     = checkBox1.Checked;
            var date        = DatePicker.Value;
            var status      = ((TaskStatusWriter)StatusPicker.SelectedItem).Status;
            var tags        = new HashSet <string>();
            var color       = ColourPicker.Colour;

            foreach (var ctrl in TagLayoutPanel.Controls)
            {
                if (ctrl is RemovableTagStrip ts)
                {
                    tags.Add(ts.TagText);
                }
            }
            if (hasDate)
            {
                var returnTask = new TH_Task(name, description, owner, link, color, date, status, tags, Source.Source);
                Component.SetTask(returnTask);
            }
            else
            {
                var returnTask = new TH_Task(name, description, owner, link, color, status, tags, Source.Source);
                Component.SetTask(returnTask);
            }
        }
Example #2
0
        public EditTaskForm(TH_Task source, IEnumerable <string> ownerSource, IEnumerable <string> tagSource, TaskCardComponent component)
        {
            OwnerSource = ownerSource.ToList();
            TagSource   = tagSource.ToList();
            Source      = source;
            Component   = component;
            InitializeComponent();
            NameTextBox.Text        = source.Name;
            DescriptionTextBox.Text = source.Description;
            checkBox1.Checked       = source.HasDate;
            if (source.HasDate)
            {
                DatePicker.Value   = source.Date;
                DatePicker.Enabled = true;
            }
            else
            {
                DatePicker.Value   = DateTime.Now;
                DatePicker.Enabled = false;
            }

            LinkTextBox.Text = source.Link;
            StatusPicker.Items.AddRange(TaskStatusWriter.All);
            StatusPicker.SelectedItem = new TaskStatusWriter(source.Status);
            OwnerComboBox.Items.AddRange(ownerSource.ToArray());
            ColourPicker.Colour        = source.Color;
            OwnerComboBox.SelectedItem = source.Owner;
            TagComboBox.Items.AddRange(tagSource.ToArray());
            foreach (var tag in source.Tags)
            {
                TagLayoutPanel.Controls.Add(new RemovableTagStrip(tag, TagLayoutPanel));
            }

            this.FormClosing += ReturnUserData;
        }
Example #3
0
        public TaskCardControl(
            IGH_Attributes parent,
            TH_Task task)
            : base(parent)
        {
            _task = task;
            AddControl(ControlLibrary.TaskName(task.Name, this), new SizeF(CardLeftMargin, CardPadV));
            var labelHost = ControlLibrary.LabelHost(task, this);

            AddControl(labelHost, new SizeF(CardLeftMargin, 2 * CardPadV + TitleHeight));

            float h = 3 * CardPadV + TitleHeight + labelHost.Size.Height;

            if (task.Description != "")
            {
                h += CardPadV;
                var dBox = ControlLibrary.DescriptionBox(task.Description, this);
                AddControl(dBox, new SizeF(CardLeftMargin, h));
                h += dBox.Size.Height + CardPadV;
            }

            h += ChinHeight;

            Size = new SizeF(CardWidth, h);

            var statusBar = new StatusBar(task.StatusIn, task.Status, CardWidth, FlowBarTotalHeight, FlowBarHeight, this);

            AddControl(statusBar, new SizeF(0f, h - FlowBarTotalHeight));

            Color = task.Color;
        }
        public void SetTask(TH_Task task)
        {
            InternalTask = task;
            UpdateAttributeTask();
            ExpireSolution(true);

            OnDisplayExpired(true);
        }
 public override bool Read(GH_IReader reader)
 {
     InternalTask = new TH_Task();
     InternalTask.Read(reader);
     InternalTask.Source = this;
     SolvedTask          = InternalTask;
     base.Read(reader);
     UpdateAttributeTask();
     return(true);
 }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Grasshopper.Kernel.Data.GH_Structure <IGH_Goo> tree;
            DA.GetDataTree(0, out tree);
            var tasksIn = tree.Where(goo => goo is TH_Task_Goo).Select(goo => ((TH_Task_Goo)goo).Value);

            if (tasksIn.Count() != 0)
            {
                var statusIn = (TaskStatus)tasksIn.Select(t => Math.Min((int)t.Status, (int)t.StatusIn)).Min();
                InternalTask = InternalTask.SetStatusIn(statusIn);
                UpdateAttributeTask();
            }
            else
            {
                InternalTask = InternalTask.SetStatusIn(InternalTask.Status);
                UpdateAttributeTask();
            }

            DA.SetData(0, new TH_Task_Goo(InternalTask));
        }
        /// <summary>
        /// Initializes a new instance of the TaskCardComponent class.
        /// </summary>
        ///

        public TaskCardComponent()
            : base("TaskCardComponent", "Nickname",
                   "Description",
                   "TaskHopper", "Tasks")
        {
            var tags = new List <string>();

            InternalTask = new TH_Task(
                "Task Name",
                "Task Description",
                "Owner Name",
                "",
                Color.LightSkyBlue,
                DateTime.Now,
                TaskStatus.ToDo,
                tags,
                this);
            SolvedTask = InternalTask;
            Attributes = CanvasControlAttributes.TaskCardAttributes(this, InternalTask);
        }
 private int taskSorter(TH_Task x, TH_Task y)
 {
     if (x.Status.CompareTo(y.Status) != 0)
     {
         return(x.Status.CompareTo(y.Status));
     }
     else if (x.HasDate && y.HasDate)
     {
         return(x.Date.CompareTo(y.Date));
     }
     else if ((!x.HasDate) && y.HasDate)
     {
         return(1);
     }
     else if (x.HasDate && (!y.HasDate))
     {
         return(-1);
     }
     else
     {
         return(0);
     }
 }
Example #9
0
        public TaskCard(TH_Task task, PointF pivot)
        {
            Name        = task.Name;
            Description = task.Description;
            Color       = task.Color;
            var parts = new List <CardPart>();

            if (task.Owner != "")
            {
                parts.Add(CardPart.PersonPart(task.Owner));
            }

            parts.Add(CardPart.StatusPart(task.Status));

            if (task.Date != default)
            {
                parts.Add(CardPart.DatePart(task.Date, task.IsLate));
            }

            if (task.Link != "")
            {
                parts.Add(ButtonCardPart.FolderButton(task.Link));
            }

            foreach (var tag in task.Tags)
            {
                parts.Add(new TagCardPart(tag));
            }

            Parts   = parts.ToArray();
            Buttons = parts
                      .Where(part => part is ButtonCardPart)
                      .Select(btn => (ButtonCardPart)btn)
                      .ToArray();

            Layout(pivot);
        }
Example #10
0
        public static FlowLayoutCanvasControlHost LabelHost(TH_Task task, CanvasControl host)
        {
            var labels = new List <CanvasControl>();

            //nulls are used as each label's initial, as this is later added during the Host object construction

            if (task.Owner != "")
            {
                labels.Add(PersonLabel(task.Owner, null));
            }

            labels.Add(StatusLabel(task.Status, null));

            if (task.HasDate)
            {
                labels.Add(DatePart(task.Date, task.IsLate, null));
            }

            if (task.Link != "")
            {
                labels.Add(FolderButton(task.Link, null));
            }

            foreach (var tag in task.Tags)
            {
                labels.Add(Tag(tag, null));
            }

            return(new FlowLayoutCanvasControlHost(
                       host.TopLevelAttributes,
                       labels,
                       InnerWidth,
                       LabelsPadH,
                       LabelsPadV,
                       new Separator(null, SeparatorThk, LabelHeight, Color.LightGray)));
        }
        public static CanvasControlAttributes TaskCardAttributes(IGH_Component parent, TH_Task task)
        {
            var atts    = new CanvasControlAttributes(parent);
            var control = new TaskCardControl(atts, task);

            atts.Control = control;
            return(atts);
        }
Example #12
0
 internal void UpdateCard(TH_Task task)
 {
     Card = new TaskCard(task, Pivot);
 }