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 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 #3
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 #4
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);
        }