示例#1
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);
      }
    }
示例#2
0
    public void NewOrRename(BaseTreeViewItem item, bool rename) {
      InputDialog inputDialog = new InputDialog {
        Owner = ACore.WMain,
        IconName = "appbar_tag",
        Title = rename ? "Rename Keyword" : "New Keyword",
        Question = rename ? "Enter the new name for the keyword." : "Enter the name of the new keyword.",
        Answer = rename ? ((Keyword) item).Title : string.Empty
      };

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

        var root = rename ? item.Parent : item;
        if (root.Items.Cast<Keyword>().SingleOrDefault(x => x.Title.Equals(inputDialog.Answer)) != null) {
          inputDialog.ShowErrorMessage("Keyword name already exists!");
          return;
        }

        inputDialog.DialogResult = true;
      };

      inputDialog.TxtAnswer.SelectAll();

      if (inputDialog.ShowDialog() ?? true) {
        if (rename) {
          var keyword = (Keyword) item;
          var path = keyword.FullPath;
          path = path.Contains("/")
            ? path.Substring(0, path.LastIndexOf("/", StringComparison.OrdinalIgnoreCase) + 1) + inputDialog.Answer
            : inputDialog.Answer;
          keyword.FullPath = path;
          keyword.Data.Name = path;
          keyword.Title = inputDialog.Answer;
          (keyword.Parent as Keywords)?.Sort();
          (keyword.Parent as Keyword)?.Sort();
          ACore.Db.Update(keyword.Data);
        } else CreateKeyword(item, inputDialog.Answer);
      }
    }
示例#3
0
    private void CmdKeywordsComment_Executed(object sender, ExecutedRoutedEventArgs e) {
      var current = ACore.MediaItems.Current;
      InputDialog inputDialog = new InputDialog {
        Owner = this,
        IconName = "appbar_notification",
        Title = "Comment",
        Question = "Add a comment.",
        Answer = current.Comment
      };

      inputDialog.BtnDialogOk.Click += delegate {
        if (inputDialog.TxtAnswer.Text.Length > 256) {
          inputDialog.ShowErrorMessage("Comment is too long!");
          return;
        }

        if (ACore.IncorectChars.Any(inputDialog.TxtAnswer.Text.Contains)) {
          inputDialog.ShowErrorMessage("Comment contains incorrect character(s)!");
          return;
        }

        inputDialog.DialogResult = true;
      };

      inputDialog.TxtAnswer.SelectAll();

      if (inputDialog.ShowDialog() ?? true) {
        current.Comment = inputDialog.TxtAnswer.Text;
        current.SaveMediaItemInToDb(false, false);
        current.TryWriteMetadata();
        ACore.Db.SubmitChanges();
      }
    }
示例#4
0
    public void NewOrRenamePerson(Person person, PeopleGroup peopleGroup, bool rename) {
      InputDialog inputDialog = new InputDialog {
        Owner = ACore.WMain,
        IconName = "appbar_people",
        Title = rename ? "Rename Person" : "New Person",
        Question = rename ? "Enter the new name of the person." : "Enter the name of the new person.",
        Answer = rename ? person.Title : string.Empty
      };

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

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

        inputDialog.DialogResult = true;
      };

      inputDialog.TxtAnswer.SelectAll();

      if (inputDialog.ShowDialog() ?? true) {
        if (rename) {
          person.Title = inputDialog.Answer;
          person.Data.Name = inputDialog.Answer;
          ACore.Db.UpdateOnSubmit(person.Data);
          ACore.Db.SubmitChanges();
          SetInPalce(person, false);
        } else CreatePerson(inputDialog.Answer, peopleGroup);
      }
    }
示例#5
0
    public void NewOrRename(bool rename) {
      InputDialog inputDialog = new InputDialog {
        Owner = ACore.WMain,
        IconName = "appbar_folder",
        Title = rename ? "Rename Folder" : "New Folder",
        Question = rename ? "Enter the new name for the folder." : "Enter the name of the new folder.",
        Answer = rename ? Title : string.Empty
      };

      inputDialog.BtnDialogOk.Click += delegate {
        if (Directory.Exists($"{(rename ? ((Folder) Parent).FullPath : FullPath)}\\{inputDialog.TxtAnswer.Text}")) {
          inputDialog.ShowErrorMessage("Folder already exists!");
          return;
        }

        if (!IsItCorrectFolderName(inputDialog.TxtAnswer.Text)) {
          inputDialog.ShowErrorMessage("New folder's name contains incorrect character(s)!");
          return;
        }

        inputDialog.DialogResult = true;
      };

      inputDialog.TxtAnswer.SelectAll();

      if (inputDialog.ShowDialog() ?? true) {
        if (rename) Rename(inputDialog.Answer);
        else New(inputDialog.Answer);
      }
    }