示例#1
0
        internal void Add(string key, HackyFileOrFolder fileOrFolder)
        {
            EntriesDictionary.Add(key, fileOrFolder);
            OnPropertyChanged("Entries");
            Dispatcher.UIThread.Post(() =>
            {
                int i = -1;
                int k = Entries.Count;
                while (k - i > 1)
                {
                    int j          = (k - i) / 2 + i;
                    int comparison = StringComparer.Ordinal.Compare(Entries[j].Name, fileOrFolder.Name);

                    if (comparison > 0)
                    {
                        k = j;
                    }
                    else if (comparison < 0)
                    {
                        i = j;
                    }
                    else if (comparison == 0)
                    {
                        throw new Exception("Unexpected string match: this should have been culled out before getting here");
                    }
                }

                Entries.Insert(k, fileOrFolder);
            });
        }
示例#2
0
 public HackyFileOrFolder(string n, HackyFileOrFolder p)
 {
     EntriesDictionary = new Dictionary <string, HackyFileOrFolder>(StringComparer.Ordinal);
     Entries           = new ObservableCollection <HackyFileOrFolder>();
     Name   = n;
     Parent = p;
 }
示例#3
0
 public void Clear()
 {
     EntriesDictionary.Clear();
     Dispatcher.UIThread.Post(() =>
     {
         Entries.Clear();
     });
     History.Clear();
     Parent = null;
 }
示例#4
0
        internal void PopulateWithFileAndCommitPair(string path, Commit c1)
        {
            HackyFileOrFolder currentFolder = BaseFolder;

            string[] directories = path.Split('/', '\\');
            for (int i = 0; i < directories.Length; i++)
            {
                if (!currentFolder.TryGetValue(directories[i], out HackyFileOrFolder fileOrFolder))
                {
                    bool isFile = i == directories.Length - 1;
                    if (isFile)
                    {
                        fileOrFolder = new HackyFile(directories[i], currentFolder);
                    }
                    else
                    {
                        fileOrFolder = new HackyFolder(directories[i], currentFolder);
                    }

                    currentFolder.Add(directories[i], fileOrFolder);
                }
                if (fileOrFolder.History.Count == 0 || fileOrFolder.History.Last() != c1)
                {
                    fileOrFolder.History.Add(c1);
                }
                currentFolder = fileOrFolder;


                /*
                 * if (!currentFolder.Entries.ContainsKey(directories[i]))
                 * {
                 *  HackyFileOrFolder fileOrFolder;
                 *  if (isFile)
                 *  {
                 *      fileOrFolder = new HackyFile(directories[i], currentFolder);
                 *  }
                 *  else
                 *  {
                 *      fileOrFolder = new HackyFolder(directories[i], currentFolder);
                 *  }
                 *  currentFolder.Entries[directories[i]] = fileOrFolder;
                 * }
                 * next = currentFolder.Entries[directories[i]];
                 * if (next.History.Count == 0 || next.History.Last() != c1)
                 * {
                 *  next.History.Add(c1);
                 * }
                 * currentFolder = next;
                 */
            }
        }
示例#5
0
 internal bool TryGetValue(string key, out HackyFileOrFolder fileOrFolder)
 {
     return(EntriesDictionary.TryGetValue(key, out fileOrFolder));
 }
示例#6
0
 public HackyFolder(string n, HackyFileOrFolder p)
     : base(n, p)
 {
 }