예제 #1
0
 public void SetInPalce(Viewer viewer, bool isNew) {
   var idx = ACore.Db.Viewers.OrderBy(x => x.Name).ToList().IndexOf(viewer.Data);
   if (isNew)
     Items.Insert(idx, viewer);
   else
     Items.Move(Items.IndexOf(viewer), idx);
 }
예제 #2
0
    public void NewOrRenameViewer(Viewer viewer, bool rename) {
      InputDialog inputDialog = new InputDialog {
        Owner = ACore.WMain,
        IconName = "appbar_eye",
        Title = rename ? "Rename Viewer" : "New Viewer",
        Question = rename ? "Enter the new name of the viewer." : "Enter the name of the new viewer.",
        Answer = rename ? viewer.Title : string.Empty
      };

      inputDialog.BtnDialogOk.Click += delegate {
        if (rename && string.Compare(inputDialog.Answer, viewer.Title, StringComparison.OrdinalIgnoreCase) == 0) {
          inputDialog.DialogResult = true;
          return;
        }

        if (ACore.Db.Viewers.SingleOrDefault(x => x.Name.Equals(inputDialog.Answer)) != null) {
          inputDialog.ShowErrorMessage("Viewer's name already exists!");
          return;
        }

        inputDialog.DialogResult = true;
      };

      inputDialog.TxtAnswer.SelectAll();

      if (inputDialog.ShowDialog() ?? true) {
        if (rename) {
          viewer.Title = inputDialog.Answer;
          (viewer.Data).Name = inputDialog.Answer;
          ACore.Db.UpdateOnSubmit(viewer.Data);
          ACore.Db.SubmitChanges();
          SetInPalce(viewer, false);
        } else CreateViewer(inputDialog.Answer);
      }
    }
예제 #3
0
    public Viewer CreateViewer(string name) {
      var dmViewer = new DataModel.Viewer {
        Id = ACore.Db.GetNextIdFor<DataModel.Viewer>(),
        Name = name
      };

      ACore.Db.InsertOnSubmit(dmViewer);
      ACore.Db.SubmitChanges();

      var vmViewer = new Viewer(dmViewer);
      SetInPalce(vmViewer, true);
      return vmViewer;
    }