Example #1
0
    private void Button_OK(object sender, RoutedEventArgs e)
    {
      var view = new ViewPoint(!Issue.Viewpoints.Any());

      if (!Directory.Exists(Path.Combine(TempFolder, Issue.Topic.Guid)))
        Directory.CreateDirectory(Path.Combine(TempFolder, Issue.Topic.Guid));


      if (!string.IsNullOrEmpty(CommentBox.Text))
      {
        var c = new Comment
        {
          Comment1 = CommentBox.Text,
          Author = Utils.GetUsername(),
          Status = comboStatuses.SelectedValue.ToString(),
          VerbalStatus = VerbalStatus.Text,
          Date = DateTime.Now,
          Viewpoint = new CommentViewpoint { Guid = view.Guid }
        };
        Issue.Comment.Add(c);
      }
      //first save the image, then update path
      var path = Path.Combine(TempFolder, Issue.Topic.Guid, view.Snapshot);
      ImagingUtils.SaveImageSource(SnapshotImg.Source, path);
      view.SnapshotPath = path;

      //neede for UI binding
      Issue.Viewpoints.Add(view);

      var win = Window.GetWindow(this);
      if (win != null)
        win.DialogResult = true;
    }
Example #2
0
        public void RemoveView(ViewPoint view, Markup issue, bool delComm)
        {
            if (File.Exists(Path.Combine(TempPath, issue.Topic.Guid, view.Viewpoint)))
            File.Delete(Path.Combine(TempPath, issue.Topic.Guid, view.Viewpoint));
              if (File.Exists(view.SnapshotPath))
            File.Delete(view.SnapshotPath);

              var guid = view.Guid;
              issue.Viewpoints.Remove(view);
              //remove comments associated with that view
              var viewcomments = issue.Comment.Where(x => x.Viewpoint!=null && x.Viewpoint.Guid == guid).ToList();

              if (!viewcomments.Any())
            return;

              foreach (var viewcomm in viewcomments)
              {
            if (delComm)
              issue.Comment.Remove(viewcomm);
            else
              viewcomm.Viewpoint = null;
              }

              HasBeenSaved = false;
        }