Ejemplo n.º 1
0
        private void AddRootNode(TreeView tree, string path, string title)
        {
            var sitecorePath = new SitecorePath(title, path);

            sitecorePath.GetDecendents();
            var node = sitecorePath.GetNode();

            UpdateNode.AddTreeNode(sitecorePath, node.Nodes);
            tree.Nodes.Add(node);
        }
        static void InsertDocument(SitecorePath path)
        {
            var media     = SitecoreClient.GetMediaStatistics(path.Path);
            var app       = Globals.SitecoreAddin.Application;
            var selection = app.Selection.Range;

            selection.Text = path.DisplayName + "." + media.Extension;
            app.ActiveDocument.Hyperlinks.Add(selection, media.Url, null,
                                              SupportingDocumentsReferenceBuilder.DocumentHyperlinkTooltip + ":" + path.Path);
            var toSelect = app.ActiveDocument.Range(selection.End, selection.End);

            toSelect.Select();
        }
Ejemplo n.º 3
0
        private static void AddRootNode(TreeView tree, string path, string title)
        {
            var sitecorePath = new SitecorePath(title, path);

            try
            {
                sitecorePath.GetDecendents();
            }
            catch (WebException)
            {
                Globals.SitecoreAddin.AlertConnectionFailure();
            }

            var node = sitecorePath.GetNode();

            UpdateNode.AddTreeNode(sitecorePath, node.Nodes);
            tree.Nodes.Add(node);
        }
Ejemplo n.º 4
0
        private void AddRootNode(TreeView tree, string path, string title)
        {
            var sitecorePath = new SitecorePath(title, path);

            try
            {
                sitecorePath.GetDecendents();
            }
            catch (WebException)
            {
                MessageBox.Show(ConnectionLostMessage);
            }

            var node = sitecorePath.GetNode();

            UpdateNode.AddTreeNode(sitecorePath, node.Nodes);
            tree.Nodes.Add(node);
        }
Ejemplo n.º 5
0
        static void InsertImage(string header, string title, SitecorePath path, string caption, string source, string floatType)
        {
            var app          = Globals.SitecoreAddin.Application;
            int numParagraph = 2;

            if (!string.IsNullOrEmpty(header))
            {
                numParagraph = numParagraph + 2;
            }
            if (!string.IsNullOrEmpty(title))
            {
                numParagraph = numParagraph + 2;
            }
            if (!string.IsNullOrEmpty(caption))
            {
                numParagraph = numParagraph + 2;
            }
            if (!string.IsNullOrEmpty(source))
            {
                numParagraph = numParagraph + 2;
            }
            for (int i = 0; i < numParagraph + 1; i++)
            {
                app.Selection.TypeParagraph();
            }
            Range selection = app.Selection.Previous(WdUnits.wdParagraph, numParagraph);

            if (!string.IsNullOrWhiteSpace(header))
            {
                selection.Text = header;
                selection.set_Style(DocumentAndParagraphStyles.ExhibitNumberStyle);
                selection = selection.Next(WdUnits.wdParagraph);
            }

            if (!string.IsNullOrEmpty(title))
            {
                selection.Text = title;
                selection.set_Style(DocumentAndParagraphStyles.ExhibitTitleStyle);
                selection = selection.Next(WdUnits.wdParagraph);
            }

            selection.Text = "Image: ";
            selection.set_Style(DocumentAndParagraphStyles.ImagePreviewStyle);
            selection.Collapse(WdCollapseDirection.wdCollapseEnd);
            selection.Text = path.DisplayName;
            try
            {
                string mediaUrl = SitecoreClient.MediaPreviewUrl(path.Path);
                if (mediaUrl.StartsWith("\""))
                {
                    mediaUrl = mediaUrl.TrimStart('"');
                }
                if (mediaUrl.EndsWith("\""))
                {
                    mediaUrl = mediaUrl.TrimEnd('"');
                }

                app.ActiveDocument.Hyperlinks.Add(selection, mediaUrl, null, floatType, path.Path);
                //app.ActiveDocument.Hyperlinks.Add(selection, SitecoreClient.MediaPreviewUrl(path.Path), null, floatType, path.Path);
            }
            catch (WebException)
            {
                Globals.SitecoreAddin.AlertConnectionFailure();
            }
            finally
            {
                selection = selection.Next(WdUnits.wdParagraph);
            }

            if (!string.IsNullOrEmpty(caption))
            {
                selection.Text = caption;
                selection.set_Style(DocumentAndParagraphStyles.ExhibitCaptionStyle52);
                selection = selection.Next(WdUnits.wdParagraph);
            }

            if (!string.IsNullOrWhiteSpace(source))
            {
                selection.Text = source;
                selection.set_Style(DocumentAndParagraphStyles.SourceStyle);
                selection.Next(WdUnits.wdParagraph).Select();
            }
        }