Example #1
0
        private void TaskItem_MouseMove(object sender, MouseEventArgs e)
        {
            bool canMove = false;

            if (sender is WorkItemControl control)
            {
                canMove = control.CanMove;
            }
            Point  currentPosition = e.GetPosition(this);
            Vector diff            = _startPoint - currentPosition;

            if (e.LeftButton == MouseButtonState.Pressed && canMove && sender is FrameworkElement source && source.DataContext is Task)
            {
                DataObject data = new DataObject();
                data.SetData("Object", source);

                WorkItemControl workItem = sender as WorkItemControl;
                _adorner = new DragAdorner(workItem, currentPosition);
                AdornerLayer.GetAdornerLayer(workItem).Add(_adorner);
                DragDrop.DoDragDrop(source, data, DragDropEffects.Move);
                AdornerLayer layer = AdornerLayer.GetAdornerLayer(workItem);
                if (layer != null)
                {
                    layer.Remove(_adorner);
                }
                _startPoint = currentPosition;
            }
        }
Example #2
0
 /// <summary>
 /// Creates a new instance of the WorkitemControlManipulator class.
 /// </summary>
 /// <param name="workItemControl">Workitem upon which all visual changes are performed.</param>
 public WorkitemControlManipulator(WorkItemControl workItemControl)
 {
     if (workItemControl == null)
     {
         throw new ArgumentException("workItemControl");
     }
     _owningControl = workItemControl;
 }
Example #3
0
        public static WorkItemControl Clone(this WorkItemControl item)
        {
            string       itemXaml  = XamlWriter.Save(item);
            StringReader reader    = new StringReader(itemXaml);
            XmlReader    xmlReader = XmlReader.Create(reader);

            return((WorkItemControl)XamlReader.Load(xmlReader));
        }
 public WorkItemWindow(WorkItem workItem)
 {
     InitializeComponent();
     _workItem = workItem;
     _workItem.FieldChanged     += WorkItem_FieldChanged;
     _workItemControl            = new WorkItemControl();
     _workItemControl.Item       = workItem;
     this.ContentControl.Content = _workItemControl;
     ChangeTitle();
 }
Example #5
0
        public DraggedAdorner(WorkItem dragDropData, UIElement adornedElement, AdornerLayer adornerLayer)
            : base(adornedElement)
        {
            this.adornerLayer = adornerLayer;

            this.contentPresenter             = new WorkItemControl();
            this.contentPresenter.DataContext = dragDropData;
            var item = WpfHelper.FindVisualParent <TaskboardControl>(AdornedElement);

            if (item != null)
            {
                this.contentPresenter.Resources = item.Resources;
            }
            this.contentPresenter.Opacity = 0.7;

            this.adornerLayer.Add(this);
        }
Example #6
0
        private static void ShowWorkItem(WorkItem wi, string caption = "")
        {
            WorkItemControl witControl = new WorkItemControl();

            witControl.Item = wi;

            var container = new Window();

            if (caption == "")
            {
                container.Title = wi.Id.ToString();
            }
            else
            {
                container.Title = caption;
            }

            container.Content = witControl;
            container.ShowDialog();
        }
        private async Task <bool> MoveWorkItemControl(WorkItemControl control, string processId, string witRefName, string groupId, string fieldName, string oldGroupId = null)
        {
            var client = GetHttpClient(
                $"{new UriBuilder(Options.Organisation)}/_apis/work/processes" +
                $"/{processId}/workItemTypes/{witRefName}/layout/groups/{groupId}/Controls/{fieldName}?" +
                (!string.IsNullOrEmpty(oldGroupId) ? $"&removeFromGroupId={oldGroupId}" : ""),
                "api-version=6.1-preview.1");

            DefaultContractResolver contractResolver = new DefaultContractResolver
            {
                NamingStrategy = new CamelCaseNamingStrategy()
            };
            var jsonSettings = new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                ContractResolver  = contractResolver,
            };
            string body = JsonConvert.SerializeObject(control.ToJson(), jsonSettings);

            var content = new StringContent(body, Encoding.UTF8, "application/json");
            var result  = await client.PutAsync(client.BaseAddress, content);

            var responseContent = await result.Content.ReadAsStringAsync();

            if (result.StatusCode != HttpStatusCode.OK && result.StatusCode != HttpStatusCode.Created)
            {
                Log.LogError("Error moving {DefinitionType}: {processId}::{witRefName}::{groupLabel}::{controlLabel}. Please migrate it manually. \r\nUrl: PUT {Url}\r\n{ErrorText}", typeof(WorkItemGroup).Name, processId, witRefName, groupId, control.Label, result.RequestMessage.RequestUri.ToString(), responseContent);
                return(false);
            }
            else
            {
                var targetObject = JsonConvert.DeserializeObject <WorkItemControl>(responseContent);
                control.Id = targetObject.Id;
                return(true);
            }
        }
 /// <summary>
 /// Adds a work item control to an existing Layout->Group
 /// </summary>
 /// <param name="control"></param>
 /// <param name="processId"></param>
 /// <param name="witRefName"></param>
 /// <param name="groupId"></param>
 /// <param name="fieldName"></param>
 /// <returns></returns>
 public async Task <bool> AddWorkItemControlToGroup(WorkItemControl control, string processId, string witRefName, string groupId, string fieldName)
 {
     return(await MoveWorkItemControl(control, processId, witRefName, groupId, fieldName));
 }