public void AddTask() { var id = Guid.NewGuid().ToString(); var task = new Task { Title = "New RFI", Date = DateTime.UtcNow }; var taskDetailsViewModel = new TaskDetailsViewModel { Task = task, Service = Service, Plugin = Plugin, FloatingElementId = id}; var size = new Size(300, 500); var fe = FloatingHelpers.CreateFloatingElement("RFI", new Point(300, 300), size, taskDetailsViewModel); fe.Id = id; AppStateSettings.Instance.FloatingItems.AddFloatingElement(fe); }
private void AddTaskWithScreenshot() { if (Service == null) return; var id2 = Guid.NewGuid().ToString(); var task = new Task { Title = "New RFI", Date = DateTime.UtcNow }; var taskDetailsViewModel = new TaskDetailsViewModel { Task = task, Service = Service, Plugin = Plugin, FloatingElementId = id2 }; var size = new Size(300, 500); var id = Guid.NewGuid() + ".png"; var media = new Media { Id = id, LocalPath = Service.store.GetLocalUrl(Service.Folder, id), Type = MediaType.Photo, Title = task.Title }; Screenshots.SaveImageOfControl(AppStateSettings.Instance.ViewDef.MapControl, media.LocalPath); //media.Image = Screenshot as BitmapSource; foreach (var m in task.AllMedia) { try { if (File.Exists(m.LocalPath)) File.Delete(m.LocalPath); } catch (Exception) { } } task.AllMedia.Clear(); task.AllMedia.Add(media); //await Service.store.SaveBytes(id, media.ByteArray); var fe = FloatingHelpers.CreateFloatingElement("RFI", new Point(300, 300), size, taskDetailsViewModel); fe.Id = id2; AppStateSettings.Instance.FloatingItems.AddFloatingElement(fe); }
public void Drop(object sender, SurfaceDragDropEventArgs e) { var border = sender as Border; if (border == null) return; border.Background = Brushes.Red; if (!visitedBorders.Contains(border)) visitedBorders.Add(border); taskDragItem = e.Cursor.Data as TaskDragItem; if (taskDragItem == null || taskDragItem.Service == null || taskDragItem.Task == null) return; activeTask = taskDragItem.Task; Lead = Followers = string.Empty; if (visitedBorders.Count > 0) { Lead = (string) visitedBorders[0].DataContext; if (visitedBorders.Count > 1) { var sb = new StringBuilder(); for (var i = 1; i < visitedBorders.Count; i++) { var visitedBorder = visitedBorders[i]; sb.Append((string) visitedBorder.DataContext); sb.Append(", "); } Followers = sb.ToString().TrimEnd(new[] {',', ' '}); } else Followers = "-"; } activeTask.Labels[RecipientsKey] = visitedBorders.Count <= 1 ? Lead : string.Format("{0}, {1}", Lead, Followers); ShowConfirmation = true; RemoveFloatingElement(); e.Handled = true; }