コード例 #1
0
        private void OnSelectedFolderChanged()
        {
            App.Logger.TraceExt("NotesViewHierarchical",
                                "OnSelectedFolderChanged",
                                Tuple.Create("SelectedNote", SelectedNote?.Title),
                                Tuple.Create("SelectedFolder", SelectedFolder?.Header));

            if (SelectedFolder != null && (SelectedNote == null || !SelectedFolder.AllSubNotes.Contains(SelectedNote)) && SelectedFolder.AllSubNotes.Any())
            {
                var n         = SelectedFolder.AllSubNotes.FirstOrDefault();
                var oldfolder = SelectedFolder.GetInternalPath();
                new Thread(() =>
                {
                    Thread.Sleep(50);
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        if (SelectedFolder == null)
                        {
                            return;
                        }
                        if (!SelectedFolder.GetInternalPath().EqualsWithCase(oldfolder))
                        {
                            App.Logger.Debug("NotesViewHierarchical", "Prevent invalidated SelectedFolderChanged event to execute", $"'{SelectedFolder.GetInternalPath()}' <> '{oldfolder}'");
                            return;
                        }

                        if (SelectedFolder != null && (SelectedNote == null || !SelectedFolder.AllSubNotes.Contains(SelectedNote)) && SelectedFolder.AllSubNotes.Any())
                        {
                            App.Logger.TraceExt("NotesViewHierarchical",
                                                "OnSelectedFolderChanged (1) [thread]",
                                                Tuple.Create("SelectedNote", n?.Title));

                            SelectedNote = n;
                        }
                    }));
                }).Start();
            }

            var p = SelectedFolder?.GetInternalPath() ?? DirectoryPath.Root();

            if (!p.EqualsIgnoreCase(SelectedFolderPath))
            {
                App.Logger.TraceExt("NotesViewHierarchical",
                                    "OnSelectedFolderChanged (2)",
                                    Tuple.Create("SelectedFolderPath", p.Formatted));

                SelectedFolderPath = p;
            }

            if (_isNotesInitialized)
            {
                _hierarchyCache.UpdateAndRequestSave(RepositoryAccountID, SelectedFolderPath, SelectedNote?.UniqueName);
            }
        }
コード例 #2
0
        private void OnSelectedFolderChanged()
        {
            App.Logger.TraceExt("NotesViewHierachical",
                                "OnSelectedFolderChanged",
                                Tuple.Create("SelectedNote", SelectedNote?.Title),
                                Tuple.Create("SelectedFolder", SelectedFolder?.Header));

            if (SelectedFolder != null && (SelectedNote == null || !SelectedFolder.AllSubNotes.Contains(SelectedNote)) && SelectedFolder.AllSubNotes.Any())
            {
                var n = SelectedFolder.AllSubNotes.FirstOrDefault();
                new Thread(() =>
                {
                    Thread.Sleep(50);
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        if (SelectedFolder != null && (SelectedNote == null || !SelectedFolder.AllSubNotes.Contains(SelectedNote)) && SelectedFolder.AllSubNotes.Any())
                        {
                            App.Logger.TraceExt("NotesViewHierachical",
                                                "OnSelectedFolderChanged (1) [thread]",
                                                Tuple.Create("SelectedNote", n?.Title));

                            SelectedNote = n;
                        }
                    }));
                }).Start();
            }

            var p = SelectedFolder?.GetInternalPath() ?? DirectoryPath.Root();

            if (!p.EqualsIgnoreCase(SelectedFolderPath))
            {
                App.Logger.TraceExt("NotesViewHierachical",
                                    "OnSelectedFolderChanged (2)",
                                    Tuple.Create("SelectedFolderPath", p.Formatted));

                SelectedFolderPath = p;
            }
        }
コード例 #3
0
        private void OnSelectedFolderPathChanged()
        {
            App.Logger.TraceExt("NotesViewHierarchical",
                                "OnSelectedFolderPathChanged",
                                Tuple.Create("SelectedFolderPath", SelectedFolderPath?.Formatted));

            if (SelectedFolderPath == null)
            {
                return;
            }
            if (DisplayItems == null)
            {
                return;
            }

            var f = DisplayItems.Find(SelectedFolderPath, true);

            if (f != null)
            {
                if (!f.IsSelected)
                {
                    App.Logger.TraceExt("NotesViewHierarchical",
                                        "OnSelectedFolderPathChanged (1)",
                                        Tuple.Create("f.IsSelected", "true"));

                    f.IsSelected = true;
                }
            }
            else
            {
                if (AllNotes == null && !SelectedFolderPath.IsRoot() && !SelectedFolderPath.EqualsIgnoreCase(SelectedFolder?.GetInternalPath()))
                {
                    App.Logger.TraceExt("NotesViewHierarchical", "OnSelectedFolderPathChanged (2)",
                                        Tuple.Create("SelectedFolder", SelectedFolder?.Header));

                    _initFolderPath    = SelectedFolderPath;
                    SelectedFolderPath = SelectedFolder?.GetInternalPath() ?? DirectoryPath.Root();
                }
                else
                {
                    if (DisplayItems.AllNotesViewWrapper != null)
                    {
                        if (!DisplayItems.AllNotesViewWrapper.IsSelected)
                        {
                            App.Logger.TraceExt("NotesViewHierarchical",
                                                "OnSelectedFolderPathChanged (3)",
                                                Tuple.Create("DisplayItems.AllNotesWrapper.IsSelected", "true"));

                            DisplayItems.AllNotesViewWrapper.IsSelected = true;
                        }
                    }
                    else
                    {
                        var fod = DisplayItems.SubFolder.FirstOrDefault(p => !p.IsSpecialNode);
                        if (fod != null && !fod.IsSelected)
                        {
                            App.Logger.TraceExt("NotesViewHierarchical",
                                                "OnSelectedFolderPathChanged (4)",
                                                Tuple.Create("DisplayItems.SubFolder.FirstOrDefault().IsSelected", "true"));

                            fod.IsSelected = true;
                        }
                    }
                }
            }

            if (_isNotesInitialized)
            {
                _hierarchyCache.UpdateAndRequestSave(RepositoryAccountID, SelectedFolderPath, SelectedNote?.UniqueName);
            }
        }