예제 #1
0
        protected override Result <EComponentResult> OnInitialized()
        {
            ComponentName = "KaNote managment";

            var result = base.OnInitialized();

            // TODO: pending check result correctrly

            try
            {
                using (new WaitCursor())
                {
                    NotesSelectorComponent.Run();
                    FoldersSelectorComponent.Run();
                    FilterParamComponent.Run();
                    NoteEditorComponent.Run();
                    MessagesManagmentComponent.Run();

                    NotifyView.ShowView();
                }
            }
            catch (Exception ex)
            {
                result.AddErrorMessage(ex.Message);
            }

            return(result);
        }
예제 #2
0
        public async void MoveSelectedNotes()
        {
            var selectedNotes = NotesSelectorComponent.GetSelectedListNotesInfo();

            if (selectedNotes == null || selectedNotes?.Count == 0)
            {
                View.ShowInfo("You have not selected notes .");
                return;
            }

            var folderSelector = new FoldersSelectorComponent(Store);
            var services       = new List <ServiceRef>();

            services.Add(SelectedServiceRef);
            folderSelector.ServicesRef = services;
            var res = folderSelector.RunModal();

            if (res.Entity != EComponentResult.Executed)
            {
                return;
            }

            var newFolderId = folderSelector.SelectedEntity.FolderInfo.FolderId;

            foreach (var n in selectedNotes)
            {
                await SelectedServiceRef.Service.Notes.PatchFolder(n.NoteId, newFolderId);
            }

            ForceRefreshListNotes();
        }
예제 #3
0
        private void OnNoteEditorDeleted(NoteInfoDto noteInfo)
        {
            NotesSelectorComponent.DeleteItem(noteInfo);

            if (NotesSelectorComponent.ListEntities?.Count == 0)
            {
                NoteEditorComponent.View.CleanView();
                _selectedNoteInfo = null;
            }
        }
예제 #4
0
        private async void OnNoteEditorSaved(NoteInfoDto noteInfo)
        {
            if (NoteEditorComponent.Model.NoteId == noteInfo.NoteId)
            {
                await NoteEditorComponent.LoadModelById(SelectedServiceRef.Service, noteInfo.NoteId);
            }

            NotesSelectorComponent.RefreshItem(noteInfo);

            if (NotesSelectorComponent.ListEntities?.Count == 0)
            {
                NoteEditorComponent.View.CleanView();
                _selectedNoteInfo = null;
            }
        }
예제 #5
0
        private async void OnNoteEditorAdded(NoteInfoDto noteInfo)
        {
            if (NotesSelectorComponent.ListEntities == null)
            {
                return;
            }

            if (NotesSelectorComponent.ListEntities.Count == 0)
            {
                await NoteEditorComponent.LoadModelById(SelectedServiceRef.Service, noteInfo.NoteId);

                _selectedNoteInfo = noteInfo;
            }
            NotesSelectorComponent.AddItem(noteInfo);
        }
예제 #6
0
 public void RefreshRepositoryAndFolderTree()
 {
     NotifyMessage("Refreshing tree folder ...");
     SelectedFilterWithServiceRef = null;
     SelectedFolderWithServiceRef = null;
     SelectedNoteInfo             = null;
     FolderPath = "";
     CountNotes = 0;
     FoldersSelectorComponent.ServicesRef = null;  // force get repostiroy list form store
     FoldersSelectorComponent.Refresh();
     NoteEditorComponent.CleanView();
     NotesSelectorComponent.CleanView();
     View.ShowInfo(null);
     NotifyMessage("Refreshed tree folder ...");
 }
예제 #7
0
        private async void RefreshActiveFilterWithServiceRef(NotesFilterWithServiceRef notesFilterWithServiceRef)
        {
            SelectMode = EnumSelectMode.Filters;

            NotifyMessage($"Loading notes filter: {notesFilterWithServiceRef?.NotesFilter?.TextSearch}");

            FolderPath = $"Notes filter: {notesFilterWithServiceRef?.NotesFilter?.TextSearch}";

            _selectedNoteInfo = null;
            NoteEditorComponent.View.CleanView();
            await NotesSelectorComponent.LoadFilteredEntities(notesFilterWithServiceRef?.ServiceRef?.Service, notesFilterWithServiceRef?.NotesFilter);

            CountNotes = NotesSelectorComponent.ListEntities?.Count;

            View.ShowInfo(null);
            NotifyMessage($"Loaded notes filter {notesFilterWithServiceRef?.NotesFilter?.TextSearch}");
        }
예제 #8
0
        public void RunScriptSelectedNotes()
        {
            var selectedNotes = NotesSelectorComponent.GetSelectedListNotesInfo();

            if (selectedNotes == null || selectedNotes?.Count == 0)
            {
                View.ShowInfo("You have not selected notes for run scripts .");
                return;
            }

            foreach (var note in selectedNotes)
            {
                if (!string.IsNullOrEmpty(note.Script))
                {
                    Store.RunScript(note.Script);
                }
            }
        }
예제 #9
0
        private async void RefreshActiveFolderWithServiceRef(FolderWithServiceRef folderWithServideRef)
        {
            if (folderWithServideRef == null)
            {
                return;
            }

            SelectMode = EnumSelectMode.Folders;

            NotifyMessage($"Loading notes list for folder {folderWithServideRef.FolderInfo?.FolderNumber}");

            FolderPath = FoldersSelectorComponent.Path;

            _selectedNoteInfo = null;
            NoteEditorComponent.CleanView();
            await NotesSelectorComponent.LoadEntities(folderWithServideRef.ServiceRef.Service, folderWithServideRef.FolderInfo);

            CountNotes = NotesSelectorComponent.ListEntities?.Count;

            View.ShowInfo(null);
            NotifyMessage($"Loaded notes list for folder {folderWithServideRef.FolderInfo?.FolderNumber}");
        }
예제 #10
0
        private async void ChangeTags(EnumChangeTag action)
        {
            var strTmp = "";

            var selectedNotes = NotesSelectorComponent.GetSelectedListNotesInfo();

            if (selectedNotes == null || selectedNotes?.Count == 0)
            {
                if (action == EnumChangeTag.Add)
                {
                    View.ShowInfo("You have not selected notes for add tags .");
                }
                else
                {
                    View.ShowInfo("You have not selected notes for remove tags .");
                }
                return;
            }

            if (action == EnumChangeTag.Add)
            {
                strTmp = "Type new tag:";
            }
            else
            {
                strTmp = "Type tag for remove:";
            }

            var listVars = new List <ReadVarItem> {
                new ReadVarItem
                {
                    Label           = strTmp,
                    VarIdent        = "Tag",
                    VarValue        = "",
                    VarNewValueText = ""
                }
            };

            var formReadVar = new ReadVarForm(listVars);

            if (action == EnumChangeTag.Add)
            {
                formReadVar.Text = "New tags for selected notes";
            }
            else
            {
                formReadVar.Text = "Remove tags in selected notes";
            }
            formReadVar.Size = new Size(500, 150);
            var result = formReadVar.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }
            else
            {
                var tag = listVars[0].VarNewValueText;
                foreach (var note in selectedNotes)
                {
                    if (action == EnumChangeTag.Add)
                    {
                        await SelectedServiceRef.Service.Notes.PatchChangeTags(note.NoteId, "", tag);
                    }
                    else
                    {
                        await SelectedServiceRef.Service.Notes.PatchChangeTags(note.NoteId, tag, "");
                    }
                }

                ForceRefreshListNotes();
            }
        }