Beispiel #1
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            Properties.Add(new PropertyItem
            {
                Header     = "项目名称",
                Value      = _task.References.Project.Name,
                Glyph      = WtIconHelper.GetGlyph(_task.References.Project.Visibility),
                IsReadonly = true,
                Color      = new SolidColorBrush((Color)Resources["SystemAccentColor"])
            });

            string taskTypeId = _task.Value.TaskTypeId;
            var    taskType   = _task.References.TaskTypes.Single(t => t.Id == taskTypeId);

            Properties.Add(new PropertyItem
            {
                Header     = "任务类型",
                Value      = taskType.Name,
                Glyph      = WtIconHelper.GetGlyph("wtf-type-" + taskType.Icon),
                IsReadonly = true,
                Color      = WtColorHelper.GetSolidColorBrush(WtColorHelper.GetColorByClass(taskType.Icon))
            });

            var reader = new PropertiesReader();
            var props  = reader.Read(_task);

            foreach (var item in props)
            {
                Properties.Add(item);
            }

            reader.LoadOptions(_task.Value.Id, Properties, Dispatcher);
        }
Beispiel #2
0
 public override void Read(KanbanItem kanban, WtTaskProperty property, ValueElement task, TaskState state, ShowSetting setting, ApiMissionVnextKanbanContent data)
 {
     kanban.State = new Models.TaskState
     {
         Name       = state.Name,
         Foreground = WtColorHelper.GetNewColor(state.Color),
         BoldGlyph  = WtIconHelper.GetBoldGlyph(state.Type)
     };
 }
Beispiel #3
0
        public override void Read(KanbanItem kanban, WtTaskProperty property, ValueElement task, TaskState state, ShowSetting setting, ApiMissionVnextKanbanContent data)
        {
            JObject jObj  = JObject.FromObject(task);
            var     value = JTokenHelper.GetPropertyValue <string>(jObj, property.Key);

            if (value != null)
            {
                var priority = data.Data.References.Lookups.Priorities.Single(p => p.Id == value);
                kanban.Priority = WtColorHelper.GetNewBrush(priority.Color);
            }
        }
Beispiel #4
0
 protected void SetColor(KanbanItemProperty kbp, string color)
 {
     if (color == null)
     {
         kbp.Foreground = WtColorHelper.GetSolidColorBrush("#aaaaaa");
         kbp.Background = WtColorHelper.GetSolidColorBrush("#33aaaaaa");
     }
     else
     {
         string newColor = WtColorHelper.GetNewColor(color);
         kbp.Foreground = WtColorHelper.GetSolidColorBrush(newColor);
         kbp.Background = WtColorHelper.GetSolidColorBrush(newColor.Insert(1, "33"));
     }
 }
Beispiel #5
0
 public async Task LoadOptionsAsync(PropertyItem item, List <JObject> allProps, CoreDispatcher dispatcher)
 {
     foreach (var prop in allProps)
     {
         await dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                   () => item.DataSource.Add(new DropdownItem
         {
             Color = WtColorHelper.GetNewBrush(prop.Value <string>("color")),
             Glyph = WtIconHelper.GetGlyph("wtf-level-" + prop.Value <string>("icon")),
             Text  = prop.Value <string>("name"),
             Value = prop.Value <string>("_id")
         }));
     }
     await dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                               () => item.SelectedValue = item.DataSource.Single(p => p.Value == item.SelectedValue.Value));
 }
Beispiel #6
0
        public override void Read(KanbanItem kanban, WtTaskProperty property, ValueElement task, TaskState state, ShowSetting setting, ApiMissionVnextKanbanContent data)
        {
            JObject jObj = JObject.FromObject(task);

            string[] tagIds = JTokenHelper.GetPropertyValue <string[]>(jObj, property.Key);
            if (tagIds.Length > 0)
            {
                foreach (var id in tagIds)
                {
                    var tag = data.Data.References.Lookups.Tags.Single(t => t.Id == id);
                    var kbp = new KanbanItemProperty
                    {
                        Value      = tag.Name,
                        Foreground = new SolidColorBrush(Colors.White),
                        Background = WtColorHelper.GetNewBrush(tag.Color)
                    };
                    kanban.Properties.Add(kbp);
                }
            }
        }
Beispiel #7
0
        public void Read(Property property, PropertyItem item, Data data)
        {
            JObject task  = JObject.FromObject(data.Value);
            string  value = JTokenHelper.GetPropertyValue <string>(task, property.Key);

            if (value != null)
            {
                var lookup = JObject.FromObject(data.References.Lookups);
                if (property.Lookup != null)
                {
                    var jItem = lookup[property.Lookup].Single(l => l["_id"].Value <string>() == value);
                    var jObj  = jItem as JObject;
                    item.SelectedValue = new DropdownItem
                    {
                        Glyph = WtIconHelper.GetGlyph("wtf-level-" + jObj.Value <string>("icon")),
                        Text  = jObj.Value <string>("name"),
                        Value = jObj.Value <string>("_id"),
                        Color = WtColorHelper.GetNewBrush(jObj.Value <string>("color"))
                    };
                    item.PropertyId = JTokenHelper.GetPropertyValue <string>(task, property.PropertyKey + ".property_id");
                }
            }
        }
Beispiel #8
0
        public override async Task LoadOptionsAsync(PropertyItem item, List <JObject> allProps, CoreDispatcher dispatcher)
        {
            var selectedValues = new List <DropdownItem>();

            foreach (var prop in allProps)
            {
                string id = prop.Value <string>("_id");
                await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    var dropdownItem = new DropdownItem
                    {
                        Text  = prop.Value <string>("name"),
                        Value = id,
                        Color = WtColorHelper.GetNewBrush(prop.Value <string>("color"))
                    };
                    item.DataSource.Add(dropdownItem);
                    if (item.SelectedIds.Contains(id))
                    {
                        selectedValues.Add(dropdownItem);
                    }
                });
            }
            await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => item.SelectedValues = selectedValues);
        }
Beispiel #9
0
        private void ReadKanbanItem(ApiMissionVnextKanbanContent data, KanbanGroup kbGroup, string taskId)
        {
            var task  = data.Data.Value.Single(v => v.Id == taskId);
            var type  = data.Data.References.TaskTypes.Single(t => t.Id == task.TaskTypeId);
            var state = data.Data.References.Lookups.TaskStates.Single(t => t.Id == task.TaskStateId);

            KanbanPageHelper.ReadForProgressBar(kbGroup, state.Type);

            var kanban = new KanbanItem
            {
                Id       = task.Id,
                TaskType = new Models.TaskType
                {
                    Name  = type.Name,
                    Color = WtColorHelper.GetColorByClass(type.Icon),
                    Glyph = WtIconHelper.GetGlyph("wtf-type-" + type.Icon),
                },
                Properties = new List <KanbanItemProperty>()
            };

            foreach (var item in type.ShowSettings)
            {
                var            property = data.Data.References.Properties.Single(p => p.Id == item.TaskPropertyId);
                PropertyReader reader   = null;
                switch (property.Type)
                {
                case WtTaskPropertyType.Text:
                    reader = new TextReader();
                    break;

                case WtTaskPropertyType.DateTime:
                    reader = new DateTimeReader();
                    break;

                case WtTaskPropertyType.DateSpan:
                    reader = new DateSpanReader();
                    break;

                case WtTaskPropertyType.Member:
                    reader = new MemberReader();
                    break;

                case WtTaskPropertyType.Workload:
                    reader = new WorkloadReader();
                    break;

                case WtTaskPropertyType.State:
                    reader = new TaskStateReader();
                    break;

                case WtTaskPropertyType.Tag:
                    reader = new TagReader();
                    break;

                case WtTaskPropertyType.Priority:
                    reader = new PriorityReader();
                    break;

                case WtTaskPropertyType.File:
                    reader = new AttachmentReader();
                    break;

                case WtTaskPropertyType.TaskType:
                    continue;

                default:
                    reader = new DefaultReader();
                    break;
                }
                reader.Read(kanban, property, task, state, item, data);
            }

            kbGroup.Items.Add(kanban);
        }