Beispiel #1
0
        public TreeViewItem SelectItem(ItemsControl container, DocNode newNode)
        {
            if (container == null)
            {
                return(null);
            }

            var item = container.ItemContainerGenerator.ContainerFromItem(newNode) as TreeViewItem;

            if (item != null)
            {
                return(item);
            }

            foreach (var i in container.Items)
            {
                item = container.ItemContainerGenerator.ContainerFromItem(i) as TreeViewItem;
                item = SelectItem(item, newNode);
                if (item != null)
                {
                    return(item);
                }
            }

            return(null);
        }
Beispiel #2
0
        private bool SelectItem(DocNode newNode)
        {
            var item = SelectItem(outline, newNode);

            if (item != null)
            {
                item.IsSelected = true;
            }
            return(item != null);
        }
Beispiel #3
0
        private void Window_Closing(object sender, CancelEventArgs e)
        {
            // save last selected node
            if (CurrentObject != null)
            {
                Settings.Default.LastExpandedNode = CurrentObject.ReferenceString;
                Settings.Default.Save();
            }

            CurrentObject = null;
        }
Beispiel #4
0
        private void OpenDirectory(string path)
        {
            WindowPath = path;

            DocModel = new DocModel(WindowPath);

            outline.ItemsSource = DocModel.Namespaces;
            Title = "DocWriter - " + WindowPath;

            // restore the last open node
            CurrentObject = DocModel.ParseReference(Settings.Default.LastExpandedNode);
        }
Beispiel #5
0
        bool SelectItem(DocNode docNode)
        {
            var docN = docNode as DocNamespace;

            if (docN != null)
            {
                outline.ExpandItem(docN);

                var row = outline.RowForItem(docN);
                outline.SelectRow(row, false);
                outline.ScrollRowToVisible(row);

                return(true);
            }

            var docT = docNode as DocType;

            if (docT != null)
            {
                outline.ExpandItem(docT.Namespace);
                outline.ExpandItem(docT);

                var row = outline.RowForItem(docT);
                outline.SelectRow(row, false);
                outline.ScrollRowToVisible(row);

                return(true);
            }

            var docM = docNode as DocMember;

            if (docM != null)
            {
                outline.ExpandItem(docM.Type.Namespace);
                outline.ExpandItem(docM.Type);
                outline.ExpandItem(docM);

                var row = outline.RowForItem(docM);
                outline.SelectRow(row, false);
                outline.ScrollRowToVisible(row);

                return(true);
            }

            return(false);
        }
Beispiel #6
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            outline.DataSource   = new DocumentTreeDataSource(DocModel);
            outline.WeakDelegate = this;
            Title = "DocWriter - " + WindowPath;

            // Restore the last node
            var lastOpenedNode = NSUserDefaults.StandardUserDefaults.StringForKey("currentNode" + WindowPath);

            if (lastOpenedNode != null)
            {
                CurrentObject = DocModel.ParseReference(lastOpenedNode);
            }
            webView.DecidePolicyForNavigation += HandleDecidePolicyForNavigation;
            NSTimer.CreateRepeatingScheduledTimer(1, () => this.CheckContents());
        }
Beispiel #7
0
        void HandleDecidePolicyForNavigation(object sender, MonoMac.WebKit.WebNavigationPolicyEventArgs e)
        {
            switch (e.OriginalUrl.Scheme)
            {
            case "ecma":
                WebView.DecideIgnore(e.DecisionToken);
                var url = e.OriginalUrl.AbsoluteString.Substring(7);
                CurrentObject = DocModel.ParseReference(url);
                return;

            // This is one of our rendered ecma links, we want to extract the target
            // from the text, not the href attribute value (since this is not easily
            // editable, and the text is.
            case "goto":
                url           = RunJS("getText", e.OriginalUrl.Host);
                CurrentObject = DocModel.ParseReference(url);
                break;
            }
            WebView.DecideUse(e.DecisionToken);
        }
Beispiel #8
0
        private void webView_Navigating(object sender, NavigatingCancelEventArgs e)
        {
            if (e.Uri == null)
            {
                return;
            }

            switch (e.Uri.Scheme)
            {
            case "ecma":
                var url = e.Uri.AbsolutePath.Substring(7);
                CurrentObject = DocModel.ParseReference(url);
                return;

            // This is one of our rendered ecma links, we want to extract the target
            // from the text, not the href attribute value (since this is not easily
            // editable, and the text is.
            case "goto":
                url           = RunJS("getText", e.Uri.Host);
                CurrentObject = DocModel.ParseReference(url);
                break;
            }
        }
Beispiel #9
0
        void SelectionDidChange(NSNotification notification)
        {
            var outlineView = (NSOutlineView)notification.Object;

            CurrentObject = (DocNode)outlineView.ItemAtRow(outlineView.SelectedRow);
        }
Beispiel #10
0
 private void outline_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
 {
     CurrentObject = e.NewValue as DocNode;
 }
Beispiel #11
0
 public static void InsertReference(this IWebView webView, DocNode docNode, string text = null)
 {
     webView.InsertHtml("<a href=''>" + docNode.ReferenceString + "</a>");
 }