Ejemplo n.º 1
0
 public static string RelativePath(DirectoryTree baseTree, string directory)
 {
     if (directory.StartsWith(baseTree.Path, StringComparison.CurrentCultureIgnoreCase))
     {
         var relative = directory.Substring(baseTree.Path.Length);
         if (relative.Length > 0 && relative[0] == System.IO.Path.DirectorySeparatorChar)
         {
             relative = relative.Substring(1);
         }
         return relative;
     }
     return directory;
 }
Ejemplo n.º 2
0
        public bool OpenFolderDirectly(string path)
        {
            directoryTree = new DirectoryTree(path);
            directoryView.ReloadData();
            directoryView.SelectRow(0, false);

            Preferences.Instance.LastOpenedFolder = path;
            Preferences.Instance.Save();

            // That's gross - Mono exposes SharedDocumentController as NSObject rather than NSDocumentcontroller
            (NSDocumentController.SharedDocumentController as NSDocumentController).NoteNewRecentDocumentURL(new NSUrl(path, true));
            return true;
        }
Ejemplo n.º 3
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            InitializeImageFilters();
            MapWebView.MainFrame.LoadRequest(new NSUrlRequest(new NSUrl(NSBundle.MainBundle.PathForResource("map", "html"))));
            searchField.Delegate = new SearchTextFieldDelegate(this);
            Window.Delegate = new MainWindowDelegate(this);
            tabSplitView.Delegate = new SplitViewDelegate(this);

            imageView.SetValueForKey(NSColor.DarkGray, IKImageBrowserView.BackgroundColorKey);
            var oldAttrs = imageView.ValueForKey(IKImageBrowserView.CellsTitleAttributesKey);
            var newAttrs = oldAttrs.MutableCopy();
            newAttrs.SetValueForKey(NSColor.White, NSAttributedString.ForegroundColorAttributeName);
            imageView.SetValueForKey(newAttrs, IKImageBrowserView.CellsTitleAttributesKey);
            imageView.SetValueForKey(newAttrs, IKImageBrowserView.CellsSubtitleAttributesKey);

            keywordEntry.Changed += delegate(object sender, EventArgs args) { KeywordsTextChanged((NSNotification) sender); };
            keywordEntry.DoCommandBySelector += KeywordsCommandSelector;
            keywordEntry.GetCompletions += KeywordsGetCompletions;
            keywordEntry.EditingEnded += delegate(object sender, EventArgs e) { ApplyKeyword(); };

            imageFilterSelector.SelectItem(Preferences.Instance.ImageFilterIndex);
            imageTypes = imageFilters[Preferences.Instance.ImageFilterIndex].Types;

            if (Preferences.Instance.LastOpenedFolder != null)
            {
                directoryTree = new DirectoryTree(Preferences.Instance.LastOpenedFolder);
            }
            else
            {
                var urlList = new NSFileManager().GetUrls(NSSearchPathDirectory.PicturesDirectory, NSSearchPathDomain.User);
                directoryTree = new DirectoryTree(urlList[0].Path);
            }

            var selectedPath = Preferences.Instance.LastSelectedFolder;
            if (!String.IsNullOrEmpty(selectedPath))
            {
                int bestRow = -1;
                for (int row = 0; row < directoryView.RowCount; ++row)
                {
                    var dt = directoryView.ItemAtRow(row) as DirectoryTree;
                    if (dt.Path == selectedPath)
                    {
                        bestRow = row;
                        break;
                    }

                    if (selectedPath.StartsWith(dt.Path))
                    {
                        bestRow = row;
                    }
                }

                if (bestRow >= 0)
                {
                    directoryView.SelectRow(bestRow, false);
                }
            }

            MapWebView.CompleteDropAction = CompleteDrop;
        }