Exemplo n.º 1
0
        // Token: 0x06007BC7 RID: 31687 RVA: 0x0022C590 File Offset: 0x0022A790
        public override ContentLocator GenerateLocator(PathNode node, out bool continueGenerating)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            continueGenerating = true;
            ContentLocator   contentLocator   = null;
            DocumentPageView documentPageView = node.Node as DocumentPageView;
            int num = -1;

            if (documentPageView != null)
            {
                if (documentPageView.DocumentPage is FixedDocumentPage || documentPageView.DocumentPage is FixedDocumentSequenceDocumentPage)
                {
                    num = documentPageView.PageNumber;
                }
            }
            else
            {
                FixedTextSelectionProcessor.FixedPageProxy fixedPageProxy = node.Node as FixedTextSelectionProcessor.FixedPageProxy;
                if (fixedPageProxy != null)
                {
                    num = fixedPageProxy.Page;
                }
            }
            if (num >= 0)
            {
                contentLocator = new ContentLocator();
                ContentLocatorPart item = FixedPageProcessor.CreateLocatorPart(num);
                contentLocator.Parts.Add(item);
            }
            return(contentLocator);
        }
Exemplo n.º 2
0
        // Token: 0x06007C12 RID: 31762 RVA: 0x0022E560 File Offset: 0x0022C760
        private bool ResolveLocatorPart(DependencyObject dependencyObject, LocatorManager.ResolvingLocatorState data, bool visitedViaVisualTree)
        {
            if (data.Finished)
            {
                return(false);
            }
            ContentLocator     contentLocatorBase = data.ContentLocatorBase;
            bool               result             = true;
            ContentLocatorPart contentLocatorPart = contentLocatorBase.Parts[data.LocatorPartIndex];

            if (contentLocatorPart == null)
            {
                result = false;
            }
            SubTreeProcessor subTreeProcessorForLocatorPart = this.GetSubTreeProcessorForLocatorPart(contentLocatorPart);

            if (subTreeProcessorForLocatorPart == null)
            {
                result = false;
            }
            if (contentLocatorPart != null && subTreeProcessorForLocatorPart != null)
            {
                DependencyObject dependencyObject2 = subTreeProcessorForLocatorPart.ResolveLocatorPart(contentLocatorPart, dependencyObject, out result);
                if (dependencyObject2 != null)
                {
                    data.AttachmentLevel = AttachmentLevel.Incomplete;
                    data.AttachedAnchor  = dependencyObject2;
                    result = true;
                    data.LastNodeMatched = dependencyObject2;
                    data.LocatorPartIndex++;
                    if (data.LocatorPartIndex == contentLocatorBase.Parts.Count)
                    {
                        data.AttachmentLevel = AttachmentLevel.Full;
                        data.AttachedAnchor  = dependencyObject2;
                        result = false;
                    }
                    else if (data.LocatorPartIndex == contentLocatorBase.Parts.Count - 1)
                    {
                        contentLocatorPart = contentLocatorBase.Parts[data.LocatorPartIndex];
                        SelectionProcessor selectionProcessorForLocatorPart = this.GetSelectionProcessorForLocatorPart(contentLocatorPart);
                        if (selectionProcessorForLocatorPart != null)
                        {
                            AttachmentLevel attachmentLevel;
                            object          obj = selectionProcessorForLocatorPart.ResolveLocatorPart(contentLocatorPart, dependencyObject2, out attachmentLevel);
                            if (obj != null)
                            {
                                data.AttachmentLevel = attachmentLevel;
                                data.AttachedAnchor  = obj;
                                result = false;
                            }
                            else
                            {
                                result = false;
                            }
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        // Token: 0x06007C0D RID: 31757 RVA: 0x0022E17C File Offset: 0x0022C37C
        private ContentLocatorBase GenerateLocatorGroup(PathNode node, object selection)
        {
            SubTreeProcessor    subTreeProcessor    = this.GetSubTreeProcessor(node.Node);
            ContentLocatorGroup contentLocatorGroup = new ContentLocatorGroup();

            foreach (object obj in node.Children)
            {
                PathNode startNode = (PathNode)obj;
                IList <ContentLocatorBase> list = this.GenerateLocators(subTreeProcessor, startNode, selection);
                if (list != null && list.Count > 0 && list[0] != null)
                {
                    ContentLocator contentLocator = list[0] as ContentLocator;
                    if (contentLocator != null && contentLocator.Parts.Count != 0)
                    {
                        contentLocatorGroup.Locators.Add(contentLocator);
                    }
                    else
                    {
                        ContentLocatorGroup contentLocatorGroup2 = list[0] as ContentLocatorGroup;
                    }
                }
            }
            if (contentLocatorGroup.Locators.Count == 0)
            {
                return(null);
            }
            if (contentLocatorGroup.Locators.Count == 1)
            {
                ContentLocator contentLocator2 = contentLocatorGroup.Locators[0];
                contentLocatorGroup.Locators.Remove(contentLocator2);
                return(contentLocator2);
            }
            return(contentLocatorGroup);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Do the GetAnnotations work inside a lock statement for thread safety reasons
        /// </summary>
        /// <param name="query"></param>
        /// <param name="anchorLocator"></param>
        /// <returns></returns>
        private IList <Annotation> InternalGetAnnotations(string query, ContentLocator anchorLocator)
        {
            // anchorLocator being null is handled appropriately below
            Invariant.Assert(query != null, "Parameter 'query' is null.");

            lock (SyncRoot)
            {
                CheckStatus();

                List <Guid> annotationIds = FindAnnotationIds(query);
                Dictionary <Guid, Annotation> annotations = null;

                // Now, get the annotations in the map that satisfies the query criterion
                if (anchorLocator == null)
                {
                    annotations = _storeAnnotationsMap.FindAnnotations();
                }
                else
                {
                    annotations = _storeAnnotationsMap.FindAnnotations(anchorLocator);
                }

                // merge both query results
                return(MergeAndCacheAnnotations(annotations, annotationIds));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Queries the Xml stream for annotations that have an anchor
        ///     that contains a locator that begins with the locator parts
        ///     in anchorLocator.
        /// </summary>
        /// <param name="anchorLocator">the locator we are looking for</param>
        /// <returns>
        ///    A list of annotations that have locators in their anchors
        ///    starting with the same locator parts list as of the input locator
        ///    If no such annotations an empty list will be returned. The method
        ///    never returns null.
        /// </returns>
        /// <exception cref="ObjectDisposedException">if object has been Disposed</exception>
        /// <exception cref="InvalidOperationException">the stream is null</exception>
        public override IList <Annotation> GetAnnotations(ContentLocator anchorLocator)
        {
            // First we generate the XPath expression
            if (anchorLocator == null)
            {
                throw new ArgumentNullException("anchorLocator");
            }

            if (anchorLocator.Parts == null)
            {
                throw new ArgumentNullException("anchorLocator.Parts");
            }

            //fire trace event
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.GetAnnotationByLocBegin);
            IList <Annotation> annotations = null;

            try
            {
                string query = @"//" + AnnotationXmlConstants.Prefixes.CoreSchemaPrefix + ":" + AnnotationXmlConstants.Elements.ContentLocator;

                if (anchorLocator.Parts.Count > 0)
                {
                    query += @"/child::*[1]/self::";
                    for (int i = 0; i < anchorLocator.Parts.Count; i++)
                    {
                        if (anchorLocator.Parts[i] != null)
                        {
                            if (i > 0)
                            {
                                query += @"/following-sibling::";
                            }

                            string fragment = anchorLocator.Parts[i].GetQueryFragment(_namespaceManager);

                            if (fragment != null)
                            {
                                query += fragment;
                            }
                            else
                            {
                                query += "*";
                            }
                        }
                    }
                }

                query += @"/ancestor::" + AnnotationXmlConstants.Prefixes.CoreSchemaPrefix + ":Anchors/ancestor::" + AnnotationXmlConstants.Prefixes.CoreSchemaPrefix + ":Annotation";

                annotations = InternalGetAnnotations(query, anchorLocator);
            }
            finally
            {
                //fire trace event
                EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.GetAnnotationByLocEnd);
            }

            return(annotations);
        }
Exemplo n.º 6
0
        // Token: 0x06007C04 RID: 31748 RVA: 0x0022DB84 File Offset: 0x0022BD84
        public IList <IAttachedAnnotation> ProcessAnnotations(DependencyObject node)
        {
            base.VerifyAccess();
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            IList <IAttachedAnnotation> list  = new List <IAttachedAnnotation>();
            IList <ContentLocatorBase>  list2 = this.GenerateLocators(node);

            if (list2.Count > 0)
            {
                AnnotationStore annotationStore;
                if (this._internalStore != null)
                {
                    annotationStore = this._internalStore;
                }
                else
                {
                    AnnotationService service = AnnotationService.GetService(node);
                    if (service == null || !service.IsEnabled)
                    {
                        throw new InvalidOperationException(SR.Get("AnnotationServiceNotEnabled"));
                    }
                    annotationStore = service.Store;
                }
                ContentLocator[] array = new ContentLocator[list2.Count];
                list2.CopyTo(array, 0);
                IList <Annotation> annotations = annotationStore.GetAnnotations(array[0]);
                foreach (ContentLocatorBase contentLocatorBase in list2)
                {
                    ContentLocator contentLocator = (ContentLocator)contentLocatorBase;
                    if (contentLocator.Parts[contentLocator.Parts.Count - 1].NameValuePairs.ContainsKey("IncludeOverlaps"))
                    {
                        contentLocator.Parts.RemoveAt(contentLocator.Parts.Count - 1);
                    }
                }
                foreach (Annotation annotation in annotations)
                {
                    foreach (AnnotationResource annotationResource in annotation.Anchors)
                    {
                        foreach (ContentLocatorBase locator in annotationResource.ContentLocators)
                        {
                            AttachmentLevel attachmentLevel;
                            object          attachedAnchor = this.FindAttachedAnchor(node, array, locator, out attachmentLevel);
                            if (attachmentLevel != AttachmentLevel.Unresolved)
                            {
                                list.Add(new AttachedAnnotation(this, annotation, annotationResource, attachedAnchor, attachmentLevel));
                                break;
                            }
                        }
                    }
                }
            }
            return(list);
        }
Exemplo n.º 7
0
        // -------------------------- GoToMark_Click --------------------------
        void GoToMark_Click(object sender, RoutedEventArgs e)
        {
            Annotation ann = null;

            if (sender is Button)
            {
                ann = ((Button)sender).Tag as Annotation;
            }
            else if (sender is MenuItem)
            {
                ann = ((MenuItem)sender).Tag as Annotation;
            }
            if (ann == null)
            {
                return;
            }

            ContentLocator cloc =
                ann.Anchors[0].ContentLocators[0] as ContentLocator;

            if (cloc == null)
            {
                return;
            }
            if (cloc.Parts.Count < 2)
            {
                return;
            }

            ContentLocatorPart cPart = cloc.Parts[1];

            if (cPart == null)
            {
                return;
            }
            if (cPart.NameValuePairs["Segment0"] != null)
            {
                string[]     charPos = cPart.NameValuePairs["Segment0"].Split(',');
                FlowDocument fd      = FDPV.Document as FlowDocument;
                TextPointer  tp      = fd.ContentStart.GetPositionAtOffset(
                    int.Parse(charPos[0]), LogicalDirection.Forward);
                if (tp == null)
                {
                    return;
                }

                FrameworkContentElement fce = tp.Parent as FrameworkContentElement;
                if (fce == null)
                {
                    return;
                }

                fce.BringIntoView();
            }
        }
Exemplo n.º 8
0
        // Token: 0x06007BBD RID: 31677 RVA: 0x0022C1DC File Offset: 0x0022A3DC
        public Dictionary <Guid, Annotation> FindAnnotations(ContentLocator anchorLocator)
        {
            if (anchorLocator == null)
            {
                throw new ArgumentNullException("locator");
            }
            Dictionary <Guid, Annotation> dictionary = new Dictionary <Guid, Annotation>();

            foreach (StoreAnnotationsMap.CachedAnnotation cachedAnnotation in this._currentAnnotations.Values)
            {
                Annotation annotation = cachedAnnotation.Annotation;
                bool       flag       = false;
                foreach (AnnotationResource annotationResource in annotation.Anchors)
                {
                    foreach (ContentLocatorBase contentLocatorBase in annotationResource.ContentLocators)
                    {
                        ContentLocator contentLocator = contentLocatorBase as ContentLocator;
                        if (contentLocator != null)
                        {
                            if (contentLocator.StartsWith(anchorLocator))
                            {
                                flag = true;
                            }
                        }
                        else
                        {
                            ContentLocatorGroup contentLocatorGroup = contentLocatorBase as ContentLocatorGroup;
                            if (contentLocatorGroup != null)
                            {
                                foreach (ContentLocator contentLocator2 in contentLocatorGroup.Locators)
                                {
                                    if (contentLocator2.StartsWith(anchorLocator))
                                    {
                                        flag = true;
                                        break;
                                    }
                                }
                            }
                        }
                        if (flag)
                        {
                            dictionary.Add(annotation.Id, annotation);
                            break;
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                }
            }
            return(dictionary);
        }
        /// <summary>Returns a list of annotations that have <see cref="P:System.Windows.Annotations.Annotation.Anchors" /> with locators that begin with a matching <see cref="T:System.Windows.Annotations.ContentLocatorPart" /> sequence.</summary>
        /// <param name="anchorLocator">The starting <see cref="T:System.Windows.Annotations.ContentLocatorPart" /> sequence to return matching annotations for.</param>
        /// <returns>The list of annotations that have <see cref="P:System.Windows.Annotations.Annotation.Anchors" /> with locators that start and match the given <paramref name="anchorLocator" />; otherwise, <see langword="null" /> if no matching annotations were found.</returns>
        // Token: 0x0600636F RID: 25455 RVA: 0x001BF5A4 File Offset: 0x001BD7A4
        public override IList <Annotation> GetAnnotations(ContentLocator anchorLocator)
        {
            if (anchorLocator == null)
            {
                throw new ArgumentNullException("anchorLocator");
            }
            if (anchorLocator.Parts == null)
            {
                throw new ArgumentNullException("anchorLocator.Parts");
            }
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.GetAnnotationByLocBegin);
            IList <Annotation> result = null;

            try
            {
                string text = "//anc:ContentLocator";
                if (anchorLocator.Parts.Count > 0)
                {
                    text += "/child::*[1]/self::";
                    for (int i = 0; i < anchorLocator.Parts.Count; i++)
                    {
                        if (anchorLocator.Parts[i] != null)
                        {
                            if (i > 0)
                            {
                                text += "/following-sibling::";
                            }
                            string queryFragment = anchorLocator.Parts[i].GetQueryFragment(this._namespaceManager);
                            if (queryFragment != null)
                            {
                                text += queryFragment;
                            }
                            else
                            {
                                text += "*";
                            }
                        }
                    }
                }
                text  += "/ancestor::anc:Anchors/ancestor::anc:Annotation";
                result = this.InternalGetAnnotations(text, anchorLocator);
            }
            finally
            {
                EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.GetAnnotationByLocEnd);
            }
            return(result);
        }
        // Token: 0x06007BF0 RID: 31728 RVA: 0x0022D58C File Offset: 0x0022B78C
        public override ContentLocator GenerateLocator(PathNode node, out bool continueGenerating)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            continueGenerating = true;
            ContentLocator     contentLocator     = null;
            ContentLocatorPart contentLocatorPart = this.CreateLocatorPart(node.Node);

            if (contentLocatorPart != null)
            {
                contentLocator = new ContentLocator();
                contentLocator.Parts.Add(contentLocatorPart);
            }
            return(contentLocator);
        }
Exemplo n.º 11
0
        // Token: 0x06007C06 RID: 31750 RVA: 0x0022DE04 File Offset: 0x0022C004
        public object ResolveLocator(ContentLocatorBase locator, int offset, DependencyObject startNode, out AttachmentLevel attachmentLevel)
        {
            base.VerifyAccess();
            if (locator == null)
            {
                throw new ArgumentNullException("locator");
            }
            if (startNode == null)
            {
                throw new ArgumentNullException("startNode");
            }
            ContentLocator contentLocator = locator as ContentLocator;

            if (contentLocator != null && (offset < 0 || offset >= contentLocator.Parts.Count))
            {
                throw new ArgumentOutOfRangeException("offset");
            }
            return(this.InternalResolveLocator(locator, offset, startNode, false, out attachmentLevel));
        }
Exemplo n.º 12
0
        // Token: 0x06007C0A RID: 31754 RVA: 0x0022DEF4 File Offset: 0x0022C0F4
        internal object FindAttachedAnchor(DependencyObject startNode, ContentLocator[] prefixes, ContentLocatorBase locator, out AttachmentLevel attachmentLevel)
        {
            if (startNode == null)
            {
                throw new ArgumentNullException("startNode");
            }
            if (locator == null)
            {
                throw new ArgumentNullException("locator");
            }
            attachmentLevel = AttachmentLevel.Unresolved;
            object result = null;
            bool   flag   = true;
            int    num    = this.FindMatchingPrefix(prefixes, locator, out flag);

            if (flag)
            {
                ContentLocator contentLocator = locator as ContentLocator;
                if (contentLocator == null || num < contentLocator.Parts.Count)
                {
                    result = this.InternalResolveLocator(locator, num, startNode, num != 0, out attachmentLevel);
                }
                if (attachmentLevel == AttachmentLevel.Unresolved && num > 0)
                {
                    if (num == 0)
                    {
                        attachmentLevel = AttachmentLevel.Unresolved;
                    }
                    else if (contentLocator != null && num < contentLocator.Parts.Count)
                    {
                        attachmentLevel = AttachmentLevel.Incomplete;
                        result          = startNode;
                    }
                    else
                    {
                        attachmentLevel = AttachmentLevel.Full;
                        result          = startNode;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 13
0
        /// <summary>
        ///     Generates locators identifying 'chunks'.  If node is a chunk,
        ///     generates a locator with a single locator part containing a
        ///     fingerprint of the chunk.  Otherwise null is returned.
        /// </summary>
        /// <param name="node">the node to generate a locator for</param>
        /// <param name="continueGenerating">return flag indicating whether the search
        /// should continue (presumably because the search was not exhaustive).
        /// This processor will always return true because it is possible to locate
        /// parts of the node (if it is FixedPage or FixedPageProxy)</param>
        /// <returns>if node is a FixedPage or FixedPageProxy, a ContentLocator
        /// with  a single locator part containing the page number; null if node is not
        /// FixedPage or FixedPageProxy </returns>
        /// <exception cref="ArgumentNullException">node is null</exception>
        /// <exception cref="ArgumentException">node points to a Document Page View which
        /// doesn't contain a FixedDocumentPage</exception>
        public override ContentLocator GenerateLocator(PathNode node, out bool continueGenerating)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            // Initial value
            continueGenerating = true;

            ContentLocator   locator = null;
            DocumentPageView dpv     = node.Node as DocumentPageView;

            int pageNb = -1;

            if (dpv != null)
            {
                // Only produce locator parts for FixedDocumentPages
                if (dpv.DocumentPage is FixedDocumentPage || dpv.DocumentPage is FixedDocumentSequenceDocumentPage)
                {
                    pageNb = dpv.PageNumber;
                }
            }
            else
            {
                FixedTextSelectionProcessor.FixedPageProxy fPage = node.Node as FixedTextSelectionProcessor.FixedPageProxy;
                if (fPage != null)
                {
                    pageNb = fPage.Page;
                }
            }

            if (pageNb >= 0)
            {
                locator = new ContentLocator();
                ContentLocatorPart locatorPart = CreateLocatorPart(pageNb);
                locator.Parts.Add(locatorPart);
            }

            return(locator);
        }
Exemplo n.º 14
0
 public QuickOrderBlockController(
     IQuickOrderService quickOrderService,
     ICartService cartService,
     IFileHelperService fileHelperService,
     IOrderRepository orderRepository,
     ReferenceConverter referenceConverter,
     ICommerceSearchService _searchService,
     ICustomerService customerService,
     IContentLoader contentLoader,
     ContentLocator contentLocator)
 {
     _quickOrderService  = quickOrderService;
     _cartService        = cartService;
     _fileHelperService  = fileHelperService;
     _orderRepository    = orderRepository;
     _referenceConverter = referenceConverter;
     __searchService     = _searchService;
     _customerService    = customerService;
     _contentLoader      = contentLoader;
     _contentLocator     = contentLocator;
 }
Exemplo n.º 15
0
        // Token: 0x06007C0B RID: 31755 RVA: 0x0022DF94 File Offset: 0x0022C194
        private int FindMatchingPrefix(ContentLocator[] prefixes, ContentLocatorBase locator, out bool matched)
        {
            matched = true;
            int            result         = 0;
            ContentLocator contentLocator = locator as ContentLocator;

            if (contentLocator != null && prefixes != null && prefixes.Length != 0)
            {
                matched = false;
                foreach (ContentLocator contentLocator2 in prefixes)
                {
                    if (contentLocator.StartsWith(contentLocator2))
                    {
                        result  = contentLocator2.Parts.Count;
                        matched = true;
                        break;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 16
0
        public BunnyHopGame()
        {
            config   = new Config();
            database = new InMemoryDatabase();
            ConfigLocator.Provide(config);
            ContentLocator.Provide(Content);
            InMemoryDatabaseLocator.Provide(database);

            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth  = ConfigLocator.Config.VirtualWidth * ConfigLocator.Config.Scale;
            graphics.PreferredBackBufferHeight = ConfigLocator.Config.VirtualHeight * ConfigLocator.Config.Scale;
            graphics.PreferMultiSampling       = false;
            graphics.ApplyChanges();
            GraphicsLocator.Provide(graphics);

            var viewportAdapter = new BoxingViewportAdapter(Window,
                                                            GraphicsDevice,
                                                            ConfigLocator.Config.VirtualWidth,
                                                            ConfigLocator.Config.VirtualHeight);

            camera = new Camera2D(viewportAdapter);
            CameraLocator.Provide(camera);

            soundEffects = new List <SoundEffect>();
            SoundLocator.Provide(soundEffects);

            Content.RootDirectory = "Content";
            stateStack            = new Stack <State>();
            stateStack.Push(new SplashState());

            //https://docs.microsoft.com/pt-br/dotnet/api/system.globalization.cultureinfo.currentculture?view=netcore-3.1
            //CultureInfo culture = new CultureInfo("ko-KR", false); // us-EN ko-KR ja-JP
            //Thread.CurrentThread.CurrentCulture = culture;
            //Thread.CurrentThread.CurrentUICulture = culture;
            //Resources.Culture = CultureInfo.CurrentCulture;
            //Debug.Print(CultureInfo.CurrentCulture.Name);
            //Debug.Print(CultureInfo.CurrentCulture.TwoLetterISOLanguageName);
            //Debug.Print(Resources.Culture.Name);
        }
        // Token: 0x0600637F RID: 25471 RVA: 0x001BFC54 File Offset: 0x001BDE54
        private IList <Annotation> InternalGetAnnotations(string query, ContentLocator anchorLocator)
        {
            Invariant.Assert(query != null, "Parameter 'query' is null.");
            object             syncRoot = base.SyncRoot;
            IList <Annotation> result;

            lock (syncRoot)
            {
                this.CheckStatus();
                List <Guid> storeAnnotationsId = this.FindAnnotationIds(query);
                Dictionary <Guid, Annotation> mapAnnotations;
                if (anchorLocator == null)
                {
                    mapAnnotations = this._storeAnnotationsMap.FindAnnotations();
                }
                else
                {
                    mapAnnotations = this._storeAnnotationsMap.FindAnnotations(anchorLocator);
                }
                result = this.MergeAndCacheAnnotations(mapAnnotations, storeAnnotationsId);
            }
            return(result);
        }
 public CarouselBlockController(ContentLocator contentLocator, IContentLoader contentLoader)
 {
     this.contentLocator = contentLocator;
     this.contentLoader  = contentLoader;
 }
        public ContentLocator RegisterUrl(HtmlHelper helper, DisplayOptions options)
        {
            var view = helper.ViewContext.View as RazorView;
            string viewPath = view.ViewPath.ToLower();

            if (viewPath.Contains("/index.cshtml"))
            {
                viewPath = viewPath.Replace("/index.cshtml", string.Empty);
            }

            var pageUrl = viewPath.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries).LastOrDefault();
            var locator = _contentLocators.FirstOrDefault(l => l.PageUrl == pageUrl && (options.Url != null ? options.Url.ToLower() == l.ContentUrl : l.ContentUrl == null));

            if (locator == null)
            {
                locator = new ContentLocator { ContentUrl = options.Url != null ? options.Url.ToLower() : null, PageUrl = pageUrl.ToLower() };
                _contentLocators.Add(locator);
            }

            return locator;
        }
Exemplo n.º 20
0
        // ----------------------- AddBookmarkOrComment -----------------------
        private void AddBookmarkOrComment(ListBox collection, Annotation ann)
        {
            if (ann.Cargos.Count <= 1)
            {
                ann.Cargos.Add(
                    new AnnotationResource(FDPV.MasterPageNumber.ToString()));
            }

            Assembly a = System.Reflection.Assembly.GetExecutingAssembly();

            string path = System.IO.Path.Combine(
                a.Location.Remove(a.Location.LastIndexOf('\\')), "GoButton.xaml");

            StackPanel EntryInList =
                XamlReader.Load(File.OpenRead(path)) as StackPanel;

            EntryInList.Width = BookmarkList.Width - 10;

            Button GoToMark = LogicalTreeHelper.FindLogicalNode(
                EntryInList, "GoToMark") as Button;

            if (GoToMark != null)
            {
                GoToMark.Tag    = ann;
                GoToMark.Click += new RoutedEventHandler(GoToMark_Click);
            }

            MenuItem GoToMenu = LogicalTreeHelper.FindLogicalNode(
                GoToMark.ContextMenu, "GoToMenu") as MenuItem;

            GoToMenu.Click += new RoutedEventHandler(GoToMark_Click);
            GoToMenu.Tag    = ann;

            MenuItem DeleteMark = LogicalTreeHelper.FindLogicalNode(
                GoToMark.ContextMenu, "DeleteMark") as MenuItem;

            DeleteMark.Click += new RoutedEventHandler(DeleteMark_Click);
            DeleteMark.Tag    = ann;

            System.Windows.Shapes.Path markPath =
                LogicalTreeHelper.FindLogicalNode(EntryInList, "MarkPath")
                as System.Windows.Shapes.Path;

            if ((collection == CommentsList) && (markPath != null))
            {
                LinearGradientBrush    lBrush = new LinearGradientBrush();
                GradientStopCollection gColl  = new GradientStopCollection();
                GradientStop           gStop  = new GradientStop(Colors.LightGreen, 0);
                gColl.Add(gStop);
                lBrush.GradientStops = gColl;
                markPath.Fill        = lBrush;
            }

            collection.Items.Add(EntryInList);

            TextBlock spText =
                LogicalTreeHelper.FindLogicalNode(EntryInList, "TB") as TextBlock;

            string MarkText = "";

            if (spText != null)
            {
                ContentLocator cloc =
                    ann.Anchors[0].ContentLocators[0] as ContentLocator;
                if (cloc == null)
                {
                    return;
                }
                if (cloc.Parts.Count < 2)
                {
                    return;
                }

                ContentLocatorPart cPart = cloc.Parts[1];
                if (cPart == null)
                {
                    return;
                }
                if (cPart.NameValuePairs["Segment0"] != null)
                {
                    string[]     charPos = cPart.NameValuePairs["Segment0"].Split(',');
                    FlowDocument fd      = FDPV.Document as FlowDocument;
                    TextPointer  tp      = fd.ContentStart.GetPositionAtOffset(
                        int.Parse(charPos[0]), LogicalDirection.Forward);

                    if (tp == null)
                    {
                        return;
                    }
                    if (tp.GetPointerContext(LogicalDirection.Forward)
                        == TextPointerContext.Text)
                    {
                        MarkText += tp.GetTextInRun(LogicalDirection.Forward);
                    }
                    spText.Text = MarkText.Substring(0,
                                                     (MarkText.Length > 150) ? 150 : MarkText.Length);
                }
            }
        }// end:AddBookmarkOrComment()
 public PageListBlockViewComponent(ContentLocator contentLocator, IContentLoader contentLoader)
 {
     this.contentLocator = contentLocator;
     this.contentLoader  = contentLoader;
 }
Exemplo n.º 22
0
        /// <summary>
        ///     Queries the store map for annotations that have an anchor
        ///     that contains a locator that begins with the locator parts
        ///     in anchorLocator.
        /// </summary>
        /// <param name="anchorLocator">the locator we are looking for</param>
        /// <returns>
        ///    A list of annotations that have locators in their anchors
        ///    starting with the same locator parts list as of the input locator
        ///    If no such annotations an empty list will be returned. The method
        ///    never returns null.
        /// </returns>
        public Dictionary <Guid, Annotation> FindAnnotations(ContentLocator anchorLocator)
        {
            if (anchorLocator == null)
            {
                throw new ArgumentNullException("locator");
            }

            Dictionary <Guid, Annotation> annotations = new Dictionary <Guid, Annotation>();

            // In the future, this probably has to be done in a way more effecient than linear search
            // the plan of record is to start with this and improve later
            // the map is already solving a perf bottleneck for tablet
            Dictionary <Guid, CachedAnnotation> .ValueCollection.Enumerator annotationsEnumerator = _currentAnnotations.Values.GetEnumerator();

            while (annotationsEnumerator.MoveNext())
            {
                Annotation annotation   = annotationsEnumerator.Current.Annotation;
                bool       matchesQuery = false;

                foreach (AnnotationResource resource in annotation.Anchors)
                {
                    foreach (ContentLocatorBase locator in resource.ContentLocators)
                    {
                        ContentLocator ContentLocator = locator as ContentLocator;
                        if (ContentLocator != null)
                        {
                            if (ContentLocator.StartsWith(anchorLocator))
                            {
                                matchesQuery = true;
                            }
                        }
                        else
                        {
                            ContentLocatorGroup ContentLocatorGroup = locator as ContentLocatorGroup;
                            if (ContentLocatorGroup != null)
                            {
                                foreach (ContentLocator list in ContentLocatorGroup.Locators)
                                {
                                    if (list.StartsWith(anchorLocator))
                                    {
                                        matchesQuery = true;
                                        break;
                                    }
                                }
                            }
                        }

                        if (matchesQuery)
                        {
                            annotations.Add(annotation.Id, annotation);
                            break;
                        }
                    }

                    if (matchesQuery)
                    {
                        break;
                    }
                }
            }

            return(annotations);
        }
Exemplo n.º 23
0
        public void Start()
        {
            string content = new ContentLocator("testContent").LocateContent();

            StartServer(content);
        }
 public BlogStartPageController(ContentLocator contentLocator, IContentLoader contentLoader)
 {
     this.contentLocator = contentLocator;
     this.contentLoader  = contentLoader;
 }
Exemplo n.º 25
0
 public TagCloudBlockController(ContentLocator contentLocator, IContentLoader contentLoader)
 {
     this.contentLocator = contentLocator;
     this.contentLoader  = contentLoader;
 }
Exemplo n.º 26
0
 public ContactPageSelectionFactory(ContentLocator contentLocator)
 {
     _contentLocator = contentLocator;
 }
Exemplo n.º 27
0
 public SidebarNavBlockController(ContentLocator contentLocator, IContentLoader contentLoader)
 {
     this.contentLocator = contentLocator;
     this.contentLoader  = contentLoader;
 }
Exemplo n.º 28
0
        public void Start()
        {
            string content = new ContentLocator("TestContent/AspNetApp").LocateContent();

            StartServer(content);
        }
Exemplo n.º 29
0
 /// <summary>
 ///     Queries the AnnotationStore for annotations that have an anchor
 ///     that contains a locator that begins with the locator parts
 ///     in anchorLocator.
 /// </summary>
 /// <param name="anchorLocator">the locator we are looking for</param>
 /// <returns>
 ///     A list of annotations that have locators in their anchors
 ///    starting with the same locator parts list as of the input locator
 ///    Can return an empty list, but never null.
 /// </returns>
 /// <exception cref="ObjectDisposedException">if object has been disposed</exception>
 public abstract IList <Annotation> GetAnnotations(ContentLocator anchorLocator);
Exemplo n.º 30
0
 public PageListBlockController(ContentLocator contentLocator, IContentLoader contentLoader, IRenderingContextResolver renderingContextResolver)
 {
     this.contentLocator       = contentLocator;
     this.contentLoader        = contentLoader;
     _renderingContextResolver = renderingContextResolver;
 }
 public void Start()
 {
     string content = new ContentLocator("testContent").LocateContent();
     StartServer(content);
 }
Exemplo n.º 32
0
 public PageListBlockController(ContentLocator contentLocator, IContentLoader contentLoader)
 {
     this.contentLocator = contentLocator;
     this.contentLoader  = contentLoader;
 }
 public void Start()
 {
     string content = new ContentLocator("TestContent/AspNetApp").LocateContent();
     StartServer(content);
 }