Exemple #1
0
 private void menuMove_Click(object sender, EventArgs e)
 {
     Monitor.Enter(_System.LockObject);
     try
     {
         if (GetSelectedFile() == null)
         {
             return;
         }
         NoteFolder newNoteFolder = FolderNameForm.GetValue("Enter note tab to move to:", _System);
         if (newNoteFolder == null)
         {
             return;
         }
         string newFullPath = newNoteFolder.GetFullPath(GetSelectedFile().BareFileName);
         File.Move(GetSelectedFile().GetFullPath(), newFullPath);
         _System.RefreshCurrentFolder();
     }
     catch (Exception ex)
     {
         ShowException(ex);
     }
     finally
     {
         Monitor.Exit(_System.LockObject);
     }
 }
        public void LoadFolders()
        {
            int tabIndex = 0;

            MainTab.TabPages.Clear();
            MainTab.Controls.Clear();
            Folders = new List <NoteFolder>();
            DirectoryInfo rootInfo = new DirectoryInfo(RootFolder);

            foreach (DirectoryInfo tabFolder in rootInfo.EnumerateDirectories())
            {
                string dirName = Path.GetFileName(tabFolder.FullName);

                TabPage tabPage   = new TabPage();
                string  labelText = dirName;
                int     dashIndex = labelText.IndexOf("-");
                if (dashIndex > 0)
                {
                    int dummySortKey;
                    if (int.TryParse(labelText.Substring(0, dashIndex), out dummySortKey))
                    {
                        labelText = labelText.Substring(dashIndex + 1);
                    }
                }
                //tabPage.Size = new System.Drawing.Size(500, 400);
                //tabPage.BorderStyle = BorderStyle.None;
                tabPage.TabIndex = tabIndex++;
                MainTab.Controls.Add(tabPage);

                ListView lvw = new ListView();
                tabPage.Controls.Add(lvw);
                lvw.View          = View.Details;
                lvw.Dock          = DockStyle.Fill;
                lvw.BorderStyle   = BorderStyle.None;
                lvw.FullRowSelect = true;
                lvw.HideSelection = false;
                lvw.DoubleClick  += _ItemDoubleClickHandler;
                lvw.Visible       = true;

                NoteFolder folder = new NoteFolder(this);
                tabPage.Tag      = folder;
                folder.System    = this;
                folder.DirName   = dirName;
                folder.LabelText = labelText;
                folder.Tab       = tabPage;
                folder.LvwFiles  = lvw;
                folder.SetTabName();
                folder.RequestRefresh();
                Folders.Add(folder);
            }
            NeedsRefresh = false;
        }
Exemple #3
0
 public static string GetValue(string instructions, NoteFolder noteFolder)
 {
     using (FileNameForm frm = new FileNameForm())
     {
         frm._NoteFolder          = noteFolder;
         frm.lblInstructions.Text = instructions;
         DialogResult result = frm.ShowDialog();
         if (result == DialogResult.OK)
         {
             return(frm.txtFileName.Text);
         }
         return(null);
     }
 }
Exemple #4
0
        private NoteFile GetSelectedFile()
        {
            TabPage tab = this.tabMain.SelectedTab;

            if (tab == null)
            {
                return(null);
            }
            NoteFolder folder = (NoteFolder)tab.Tag;

            if (folder.LvwFiles.SelectedItems.Count == 0)
            {
                return(null);
            }
            return((NoteFile)folder.LvwFiles.SelectedItems[0].Tag);
        }
 public void RefreshIfNeeded()
 {
     Monitor.Enter(this.LockObject);
     try
     {
         if (NeedsRefresh)
         {
             LoadFolders();
             if (Folders.Count > 0)
             {
                 CurrentFolder = Folders[0];
                 CurrentFolder.LoadFolder();
             }
         }
         else
         {
             //TabPage tabPage = MainTab.SelectedTab;
             //if (tabPage != null)
             //{
             //    CurrentFolder = (NoteFolder)tabPage.Tag;
             //    if (CurrentFolder.NeedsRefresh)
             //        CurrentFolder.LoadFolder();
             //}
             foreach (NoteFolder folder in Folders)
             {
                 if (folder.NeedsRefresh)
                 {
                     folder.LoadFolder();
                 }
             }
         }
     }
     finally
     {
         Monitor.Exit(this.LockObject);
     }
 }
Exemple #6
0
 public FolderListItem(NoteFolder folder)
 {
     Folder = folder;
 }
Exemple #7
0
 public NoteFile(NoteSystem system, NoteFolder folder)
 {
     System     = system;
     Folder     = folder;
     DataFields = new Dictionary <string, string>();
 }