コード例 #1
0
ファイル: Viewer.cs プロジェクト: martin-holy/PictureManager
    public Viewer() {
      IncludedFolders = new BaseTreeViewItem {Title = "Included Folders", IconName = "appbar_folder_star", Parent = this};
      ExcludedFolders = new BaseTreeViewItem {Title = "Excluded Folders", IconName = "appbar_folder_star", Parent = this};

      Items.Add(IncludedFolders);
      Items.Add(ExcludedFolders);

      IconName = "appbar_eye";
    }
コード例 #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
ファイル: Viewers.cs プロジェクト: martin-holy/PictureManager
    public void RemoveFolder(BaseTreeViewItem folder) {
      var data = folder.Tag as DataModel.ViewerAccess;
      if (data == null) return;

      var viewer = Items.Cast<Viewer>().SingleOrDefault(x => x.Id == data.ViewerId);
      if (viewer == null) return;

      ACore.Db.DeleteOnSubmit(data);
      (data.IsIncluded ? viewer.IncludedFolders : viewer.ExcludedFolders).Items.Remove(folder);
      ACore.Db.SubmitChanges();
    }
コード例 #4
0
    public Keyword CreateKeyword(BaseTreeViewItem root, string name) {
      if (root == null) return null;

      var parent = root as Keyword;
      var dmKeyword = new DataModel.Keyword {
        Id = ACore.Db.GetNextIdFor<DataModel.Keyword>(),
        Name = parent == null ? name : $"{parent.FullPath}/{name}"
      };
      ACore.Db.Insert(dmKeyword);

      var vmKeyword = new Keyword(dmKeyword) {Parent = root};
      AllKeywords.Add(vmKeyword);

      try {
        Keyword keyword = root.Items.Cast<Keyword>().FirstOrDefault(k => k.Index == 0 && string.Compare(k.Title, name, StringComparison.OrdinalIgnoreCase) >= 0);
        root.Items.Insert(keyword == null ? 0 : root.Items.IndexOf(keyword), vmKeyword);
      }
      catch (Exception ex) {
        //BUG This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread.
      }

      return vmKeyword;
    }
コード例 #5
0
ファイル: AppCore.cs プロジェクト: martin-holy/PictureManager
    public void TreeView_KeywordsStackPanel_PreviewMouseUp(object item, MouseButton mouseButton, bool recursive) {
      if (item is ViewModel.Keywords || item is ViewModel.People || item is ViewModel.FolderKeywords || item is ViewModel.Ratings || item is ViewModel.PeopleGroup) return;

      switch (mouseButton) {
        case MouseButton.Left: {
          if (KeywordsEditMode) {
            var fk = item as ViewModel.FolderKeyword;
            if (fk != null) {
              fk.IsSelected = false;
              return;
            }

            var bti = item as ViewModel.BaseTreeViewTagItem;
            if (bti != null) {
                bti.IsMarked = !bti.IsMarked;
              if (bti.IsMarked)
                MarkedTags.Add(bti);
              else
                MarkedTags.Remove(bti);
            }

            MediaItems.EditMetadata(item);

            MarkUsedKeywordsAndPeople();
            UpdateStatusBarInfo();
          } else {
            //not KeywordsEditMode
            var baseTagItem = (ViewModel.BaseTreeViewTagItem) item;

            var rating = item as ViewModel.Rating;
            if (rating != null) {
              if (LastSelectedSource != null) LastSelectedSource.IsSelected = true;
              rating.BgBrush = rating.BgBrush == BgBrushes.Chosen ? BgBrushes.Default : BgBrushes.Chosen;
              rating.IsSelected = false;
            } else {
              baseTagItem.IsSelected = true;
              LastSelectedSource = baseTagItem;
            }

            if (ThumbsWebWorker != null && ThumbsWebWorker.IsBusy) {
              ThumbsWebWorker.CancelAsync();
              ThumbsResetEvent.WaitOne();
            }

            var folder = LastSelectedSource as ViewModel.Folder;
            if (folder != null) {
              MediaItems.LoadByFolder(folder.FullPath);
              InitThumbsPagesControl();
              return;
            }

            MediaItems.LoadByTag((ViewModel.BaseTreeViewTagItem) LastSelectedSource, recursive);
            InitThumbsPagesControl();
          }
          break;
        }
      }
    }
コード例 #6
0
ファイル: Viewer.cs プロジェクト: martin-holy/PictureManager
 private static void SetInPlace(BaseTreeViewItem item) {
   item.Parent.Items.Add(item);
   var idx = item.Parent.Items.OrderBy(x => x.ToolTip).ToList().IndexOf(item);
   item.Parent.Items.Move(item.Parent.Items.IndexOf(item), idx);
 }