Beispiel #1
0
 public Solution PreviewChanges(
     string title,
     string helpString,
     string description,
     string topLevelName,
     Glyph topLevelGlyph,
     Solution newSolution,
     Solution oldSolution,
     bool showCheckBoxes = true)
 {
     var engine = new PreviewEngine(
         title,
         helpString,
         description,
         topLevelName,
         topLevelGlyph,
         newSolution,
         oldSolution,
         _componentModel,
         _imageService,
         showCheckBoxes);
     _previewChanges.PreviewChanges(engine);
     engine.CloseWorkspace();
     return engine.FinalSolution;
 }
        public FileSystemCompletionHelper(
            CompletionListProvider completionProvider,
            TextSpan textChangeSpan,
            ICurrentWorkingDirectoryDiscoveryService fileSystemDiscoveryService,
            Glyph folderGlyph,
            Glyph fileGlyph,
            ImmutableArray<string> searchPaths,
            IEnumerable<string> allowableExtensions,
            Func<string, bool> exclude = null,
            CompletionItemRules itemRules = null)
        {
            Debug.Assert(searchPaths.All(path => PathUtilities.IsAbsolute(path)));

            _completionProvider = completionProvider;
            _textChangeSpan = textChangeSpan;
            _searchPaths = searchPaths;
            _allowableExtensions = allowableExtensions.Select(e => e.ToLowerInvariant()).ToSet();
            _fileSystemDiscoveryService = fileSystemDiscoveryService;
            _folderGlyph = folderGlyph;
            _fileGlyph = fileGlyph;
            _exclude = exclude;
            _itemRules = itemRules;

            _lazyGetDrives = new Lazy<string[]>(() =>
                IOUtilities.PerformIO(Directory.GetLogicalDrives, SpecializedCollections.EmptyArray<string>()));
        }
Beispiel #3
0
 public SymbolCompletionItem(
     CompletionListProvider completionProvider,
     string displayText,
     string insertionText,
     string filterText,
     TextSpan filterSpan,
     int position,
     List<ISymbol> symbols,
     string sortText,
     AbstractSyntaxContext context,
     Glyph glyph,
     bool preselect = false,
     SupportedPlatformData supportedPlatforms = null,
     CompletionItemRules rules = null)
 : base(completionProvider, displayText, filterSpan,
    descriptionFactory: null, glyph: glyph,
    sortText: sortText, filterText: filterText, preselect: preselect, showsWarningIcon: supportedPlatforms != null, rules: rules,
    filters: GetFilters(symbols))
 {
     this.InsertionText = insertionText;
     this.Position = position;
     this.Symbols = symbols;
     this.Context = context;
     _supportedPlatforms = supportedPlatforms;
 }
Beispiel #4
0
 public static CompletionItem Create(
     string displayText,
     TextSpan span,
     ISymbol symbol,
     int contextPosition = -1,
     int descriptionPosition = -1,
     string sortText = null,
     string insertionText = null,
     Glyph? glyph = null,
     string filterText = null,
     bool preselect = false,
     SupportedPlatformData supportedPlatforms = null,
     bool isArgumentName = false,
     ImmutableDictionary<string, string> properties = null,
     CompletionItemRules rules = null)
 {
     return Create(
         displayText: displayText,
         span: span,
         symbols: ImmutableArray.Create(symbol),
         contextPosition: contextPosition,
         descriptionPosition: descriptionPosition,
         sortText: sortText,
         insertionText: insertionText,
         glyph: glyph,
         filterText: filterText,
         preselect: preselect,
         supportedPlatforms: supportedPlatforms,
         isArgumentName: isArgumentName,
         properties: properties,
         rules: rules);
 }
Beispiel #5
0
        /// <summary>
        ///     Reads a glyph description from the specified offset.
        /// </summary>
        public Glyph ReadGlyph(int glyphIndex) {
            FontFileStream stream = reader.Stream;

            // Offset from beginning of font file
            uint fileOffset = glyfEntry.Offset + loca[glyphIndex];
            long length = GetGlyphLength(glyphIndex);

            Glyph glyph = new Glyph(reader.IndexMappings.Map(glyphIndex));
            if (length != 0) {
                byte[] glyphData = new byte[length];

                // Read glyph description into byte array
                stream.Position = fileOffset;
                stream.Read(glyphData, 0, glyphData.Length);

                glyph.SetGlyphData(glyphData);

                FontFileStream glyphStream = new FontFileStream(glyphData);

                // This fields dictates whether the glyph is a simple or composite glyph
                bool compositeGlyph = (glyphStream.ReadShort() < 0);

                // Skip font bounding box
                glyphStream.Skip(PrimitiveSizes.Short*4);

                if (compositeGlyph) {
                    ReadCompositeGlyph(glyphStream, glyph);
                }
            }

            return glyph;
        }
 public static CompletionItem Create(
     string displayText,
     ISymbol symbol,
     int contextPosition = -1,
     string sortText = null,
     string insertionText = null,
     Glyph? glyph = null,
     string filterText = null,
     int? matchPriority = null,
     SupportedPlatformData supportedPlatforms = null,
     ImmutableDictionary<string, string> properties = null,
     CompletionItemRules rules = null)
 {
     return Create(
         displayText: displayText,
         symbols: ImmutableArray.Create(symbol),
         contextPosition: contextPosition,
         sortText: sortText,
         insertionText: insertionText,
         glyph: glyph,
         filterText: filterText,
         matchPriority: matchPriority.GetValueOrDefault(),
         supportedPlatforms: supportedPlatforms,
         properties: properties,
         rules: rules);
 }
Beispiel #7
0
		public static Surface RenderGlyph (Fnt font, Glyph g, byte[] palette, int offset)
		{
			byte[] buf = new byte[g.Width * g.Height * 4];
			int i = 0;

			for (int y = g.Height - 1; y >= 0; y--) {
				for (int x = g.Width - 1; x >= 0; x--) {
					if (g.Bitmap[y,x] == 0)
						buf [i + 0] = 0;
					else if (g.Bitmap[y,x] == 1)
						buf [i + 0] = 255;
					else
						buf [i + 0] = 128;

					buf[i + 1] = palette[ (g.Bitmap[y,x] + offset) * 3 + 2];
					buf[i + 2] = palette[ (g.Bitmap[y,x] + offset) * 3 + 1];
					buf[i + 3] = palette[ (g.Bitmap[y,x] + offset) * 3 ];

					if (buf[i+1] == 252 && buf[i+2] == 0 && buf[i+3] == 252)
						buf[i + 0] = 0;

					i += 4;
				}
			}

			return CreateSurfaceFromRGBAData (buf, (ushort)g.Width, (ushort)g.Height, 32, g.Width * 4);
		}
Beispiel #8
0
 public PreviewEngine(
     string title,
     string helpString,
     string description,
     string topLevelItemName,
     Glyph topLevelGlyph,
     Solution newSolution,
     Solution oldSolution,
     IComponentModel componentModel,
     IVsImageService2 imageService,
     bool showCheckBoxes = true)
 {
     _topLevelName = topLevelItemName;
     _topLevelGlyph = topLevelGlyph;
     _title = title;
     _helpString = helpString;
     _description = description;
     _newSolution = newSolution.WithMergedLinkedFileChangesAsync(oldSolution, cancellationToken: CancellationToken.None).Result;
     _oldSolution = oldSolution;
     _diffSelector = componentModel.GetService<ITextDifferencingSelectorService>();
     _editorFactory = componentModel.GetService<IVsEditorAdaptersFactoryService>();
     _componentModel = componentModel;
     this.ShowCheckBoxes = showCheckBoxes;
     _imageService = imageService;
 }
Beispiel #9
0
        public static void Crop(Glyph glyph)
        {
            // Crop the top.
            while ((glyph.Subrect.Height > 1) && BitmapUtils.IsAlphaEntirely(0, glyph.Bitmap, new Rectangle(glyph.Subrect.X, glyph.Subrect.Y, glyph.Subrect.Width, 1)))
            {
                glyph.Subrect.Y++;
                glyph.Subrect.Height--;

                glyph.YOffset++;
            }

            // Crop the bottom.
            while ((glyph.Subrect.Height > 1) && BitmapUtils.IsAlphaEntirely(0, glyph.Bitmap, new Rectangle(glyph.Subrect.X, glyph.Subrect.Bottom - 1, glyph.Subrect.Width, 1)))
            {
                glyph.Subrect.Height--;
            }

            // Crop the left.
            while ((glyph.Subrect.Width > 1) && BitmapUtils.IsAlphaEntirely(0, glyph.Bitmap, new Rectangle(glyph.Subrect.X, glyph.Subrect.Y, 1, glyph.Subrect.Height)))
            {
                glyph.Subrect.X++;
                glyph.Subrect.Width--;

                glyph.XOffset++;
            }

            // Crop the right.
            while ((glyph.Subrect.Width > 1) && BitmapUtils.IsAlphaEntirely(0, glyph.Bitmap, new Rectangle(glyph.Subrect.Right - 1, glyph.Subrect.Y, 1, glyph.Subrect.Height)))
            {
                glyph.Subrect.Width--;
            }
        }
		public Bitmap Rasterize(Glyph glyph, TextQuality quality)
		{
			EnsureSurfaceSize(ref glyph_surface, ref glyph_renderer, glyph.Font);
			SetTextRenderingOptions(glyph_renderer, glyph.Font, quality);

			RectangleF r2 = new RectangleF();

			glyph_renderer.Clear(Color.Transparent);

			glyph_renderer.DrawString(glyph.Character.ToString(), glyph.Font, Brushes.White, Point.Empty,  //new Point(glyph_surface.Width, 0),
				glyph.Font.Style == FontStyle.Italic ? load_glyph_string_format : load_glyph_string_format_tight);

			r2 = FindEdges(glyph_surface, true);

			//if ((default_string_format.FormatFlags & StringFormatFlags.DirectionRightToLeft) != 0)
			//{
			//    glyph_renderer.DrawString(glyph.Character.ToString(), glyph.Font, Brushes.White, Point.Empty, //new Point(glyph_surface.Width, 0),
			//        load_glyph_string_format);//glyph.Font.Style == FontStyle.Italic ? load_glyph_string_format : default_string_format);

			//    r2 = FindEdges(glyph_surface, true);
			//}
			//else
			//{
			//    glyph_renderer.DrawString(glyph.Character.ToString(), glyph.Font, Brushes.White, Point.Empty,
			//        load_glyph_string_format_tight); //glyph.Font.Style == FontStyle.Italic ? load_glyph_string_format : default_string_format);

			//    r2 = FindEdges(glyph_surface, false);
			//}

			return glyph_surface.Clone(r2, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
		}
        public SymbolGlyphDeferredContent(Glyph glyph, IGlyphService glyphService)
        {
            Contract.ThrowIfNull(glyphService);

            _glyph = glyph;
            _glyphService = glyphService;
        }
        public CSharpCompletionItem(
            Workspace workspace,
            CompletionListProvider completionProvider,
            string displayText,
            TextSpan filterSpan,
            Func<CancellationToken, Task<ImmutableArray<SymbolDisplayPart>>> descriptionFactory,
            Glyph? glyph,
            string sortText = null,
            string filterText = null,
            bool preselect = false,
            bool isBuilder = false,
            bool showsWarningIcon = false,
            bool shouldFormatOnCommit = false)
            : base(completionProvider,
                   displayText,
                   filterSpan,
                   descriptionFactory,
                   glyph,
                   sortText,
                   filterText,
                   preselect,
                   isBuilder,
                   showsWarningIcon,
                   shouldFormatOnCommit)
        {
            Contract.ThrowIfNull(workspace);

            this.Workspace = workspace;
        }
        public static CompletionItem Create(
            string displayText,
            TextSpan span,
            Glyph? glyph,
            DeclarationModifiers modifiers,
            int line,
            ISymbol symbol,
            SyntaxToken token,
            int descriptionPosition,
            CompletionItemRules rules)
        {
            var props = ImmutableDictionary<string, string>.Empty
                .Add("Line", line.ToString())
                .Add("Modifiers", modifiers.ToString())
                .Add("TokenSpanEnd", token.Span.End.ToString());

            return SymbolCompletionItem.Create(
                displayText: displayText,
                span: span,
                symbol: symbol,
                glyph: glyph,
                descriptionPosition: descriptionPosition,
                properties: props,
                rules: rules);
        }
Beispiel #14
0
 private QuickInfoModel(SemanticModel semanticModel, TextSpan span, Glyph glyph, SymbolMarkup markup, string documentation)
 {
     SemanticModel = semanticModel;
     Span = span;
     Glyph = glyph;
     Markup = markup;
     Documentation = documentation;
 }
 public ChangeSignatureResult(bool succeeded, Solution updatedSolution = null, string name = null, Glyph? glyph = null, bool previewChanges = false)
 {
     this.Succeeded = succeeded;
     this.UpdatedSolution = updatedSolution;
     this.Name = name;
     this.Glyph = glyph;
     this.PreviewChanges = previewChanges;
 }
 public EditorNavigationTarget(string name, SnapshotSpan span, SnapshotSpan seek, Glyph icon, ImageSource glyph)
 {
     Name = name;
     Span = span;
     Seek = seek;
     Icon = icon;
     Glyph = glyph;
 }
Beispiel #17
0
        private void Convert()
        {
            DefineShape shape;
            glyph = new Glyph(GlyphType.Symbol); ;
            Segment seg;
            PointF point0;
            PointF basePoint = new PointF(0, 0);
            PointF curvePoint1, curvePoint2;

            foreach (BaseTag tag in swf.Tags)
            {
                if (tag is DefineShape)
                {
                    shape = (DefineShape)tag;
                    glyph.Rect = shape.Rect.RectangleF;

                    foreach (ShapeRecord record in shape.ShapeWithStyle.Shapes)
                    {
                        if (record is StyleChangeRecord)
                        {
                            basePoint = ((StyleChangeRecord)record).Point0;
                            seg = new Segment(SegmentType.StartPoint, new PointF[] { basePoint });
                            glyph.Segments.Add(seg);
                        }
                        else if (record is StraightEdgeRecord)
                        {
                            point0 = ((StraightEdgeRecord)record).Point0;
                            basePoint.X += point0.X;
                            basePoint.Y += point0.Y;
                            seg = new Segment(SegmentType.Line, new PointF[] { basePoint });
                            glyph.Segments.Add(seg);
                        }
                        else if (record is CurvedEdgeRecord)
                        {
                            point0 = ((CurvedEdgeRecord)record).Point0;
                            curvePoint1 = basePoint;
                            curvePoint1.X += point0.X;
                            curvePoint1.Y += point0.Y;

                            point0 = ((CurvedEdgeRecord)record).Point1;
                            curvePoint2 = curvePoint1;
                            curvePoint2.X += point0.X;
                            curvePoint2.Y += point0.Y;

                            basePoint = curvePoint2;

                            seg = new Segment(SegmentType.QuadraticBezier, new PointF[] { curvePoint1, curvePoint2 });
                            glyph.Segments.Add(seg);
                        }
                    }
                }

                if (tag is ShowFrameTag)
                {
                    break;
                }
            }
        }
 protected CompletionItem CreateItem(
     Workspace workspace,
     string displayText,
     TextSpan textSpan,
     Func<CancellationToken, Task<ImmutableArray<SymbolDisplayPart>>> descriptionFactory,
     Glyph? glyph)
 {
     return new CompletionItem(this, displayText, textSpan, descriptionFactory, glyph, rules: ObjectInitializerCompletionItemRules.Instance);
 }
 public CompletionItem(string displayText, string insertionText, string description, Glyph? glyph, Symbol symbol, bool isBuilder)
 {
     DisplayText = displayText;
     InsertionText = insertionText;
     Description = description;
     Glyph = glyph;
     Symbol = symbol;
     IsBuilder = isBuilder;
 }
Beispiel #20
0
		public InformationQuickInfoContent(Glyph? symbolGlyph, Glyph? warningGlyph, ImmutableArray<TaggedText> mainDescription, ImmutableArray<TaggedText> documentation, ImmutableArray<TaggedText> typeParameterMap, ImmutableArray<TaggedText> anonymousTypes, ImmutableArray<TaggedText> usageText, ImmutableArray<TaggedText> exceptionText) {
			SymbolGlyph = symbolGlyph;
			WarningGlyph = warningGlyph;
			MainDescription = mainDescription.IsDefault ? ImmutableArray<TaggedText>.Empty : mainDescription;
			Documentation = documentation.IsDefault ? ImmutableArray<TaggedText>.Empty : documentation;
			TypeParameterMap = typeParameterMap.IsDefault ? ImmutableArray<TaggedText>.Empty : typeParameterMap;
			AnonymousTypes = anonymousTypes.IsDefault ? ImmutableArray<TaggedText>.Empty : anonymousTypes;
			UsageText = usageText.IsDefault ? ImmutableArray<TaggedText>.Empty : usageText;
			ExceptionText = exceptionText.IsDefault ? ImmutableArray<TaggedText>.Empty : exceptionText;
		}
        public Solution PreviewChanges(string title, string helpString, string description, string topLevelName, Glyph topLevelGlyph, Solution newSolution, Solution oldSolution, bool showCheckBoxes = true)
        {
            Called = true;
            Title = title;
            HelpString = helpString;
            Description = description;
            TopLevelName = topLevelName;
            TopLevelGlyph = topLevelGlyph;
            ShowCheckBoxes = showCheckBoxes;

            return ReturnsNull ? null : newSolution;
        }
Beispiel #22
0
 public NavigableItem(
     Glyph glyph, ImmutableArray<TaggedText> displayTaggedParts,
     bool displayFileLocation, bool isImplicitlyDeclared, Document document, TextSpan sourceSpan, ImmutableArray<INavigableItem> childItems)
 {
     Glyph = glyph;
     DisplayTaggedParts = displayTaggedParts;
     DisplayFileLocation = displayFileLocation;
     IsImplicitlyDeclared = isImplicitlyDeclared;
     Document = document;
     SourceSpan = sourceSpan;
     ChildItems = childItems;
 }
Beispiel #23
0
        public static CompletionItem Create(
            string displayText,
            TextSpan span,
            Glyph? glyph = null,
            ImmutableArray<SymbolDisplayPart> description = default(ImmutableArray<SymbolDisplayPart>),
            string sortText = null,
            string filterText = null,
            bool preselect = false,
            bool showsWarningIcon = false,
            bool shouldFormatOnCommit = false,
            bool isArgumentName = false,
            ImmutableDictionary<string, string> properties = null,
            ImmutableArray<string> tags = default(ImmutableArray<string>),
            CompletionItemRules rules = null)
        {
            tags = tags.IsDefault ? ImmutableArray<string>.Empty : tags;

            if (glyph != null)
            {
                // put glyph tags first
                tags = GlyphTags.GetTags(glyph.Value).AddRange(tags);
            }

            if (showsWarningIcon)
            {
                tags = tags.Add(CompletionTags.Warning);
            }

            if (isArgumentName)
            {
                tags = tags.Add(CompletionTags.ArgumentName);
            }

            properties = properties ?? ImmutableDictionary<string, string>.Empty;
            if (!description.IsDefault && description.Length > 0)
            {
                properties = properties.Add("Description", EncodeDescription(description));
            }

            rules = rules ?? CompletionItemRules.Default;
            rules = rules.WithPreselect(preselect)
                         .WithFormatOnCommit(shouldFormatOnCommit);

            return CompletionItem.Create(
                displayText: displayText,
                filterText: filterText,
                sortText: sortText,
                span: span,
                properties: properties,
                tags: tags,
                rules: rules);
        }
        public ImageMoniker GetImageMoniker(Glyph glyph)
        {
            // We can't do the compositing of these glyphs at the editor layer.  So just map them
            // to the non-add versions.
            switch (glyph)
            {
                case Glyph.AddReference:
                    glyph = Glyph.Reference;
                    break;
            }

            return glyph.GetImageMoniker();
        }
Beispiel #25
0
 public RecommendedKeyword(
     string keyword,
      Glyph glyph,
       Func<CancellationToken, ImmutableArray<SymbolDisplayPart>> descriptionFactory,
       bool isIntrinsic = false,
       bool shouldFormatOnCommit = false)
 {
     this.Keyword = keyword;
     this.Glyph = glyph;
     this.DescriptionFactory = descriptionFactory;
     this.IsIntrinsic = isIntrinsic;
     this.ShouldFormatOnCommit = shouldFormatOnCommit;
 }
 public Item(
     CompletionListProvider completionProvider,
     string displayText,
     string insertionText,
     TextSpan textSpan,
     Func<CancellationToken,
     Task<ImmutableArray<SymbolDisplayPart>>> descriptionFactory,
     Glyph? glyph,
     string sortText)
     : base(completionProvider, displayText, textSpan, descriptionFactory, glyph, sortText, rules: ItemRules.Instance)
 {
     this.InsertionText = insertionText;
 }
Beispiel #27
0
        public static CompletionItem Create(
            string displayText,
            TextSpan span,
            IReadOnlyList<ISymbol> symbols,
            int contextPosition = -1,
            int descriptionPosition = -1,
            string sortText = null,
            string insertionText = null,
            Glyph? glyph = null,
            string filterText = null,
            bool preselect = false,
            SupportedPlatformData supportedPlatforms = null,
            bool isArgumentName = false,
            ImmutableDictionary<string, string> properties = null,
            ImmutableArray<string> tags = default(ImmutableArray<string>),
            CompletionItemRules rules = null)
        {
            var props = properties ?? ImmutableDictionary<string, string>.Empty;

            props = props.Add("Symbols", EncodeSymbols(symbols));

            if (insertionText != null)
            {
                props = props.Add("InsertionText", insertionText);
            }

            if (contextPosition >= 0)
            {
                props = props.Add("ContextPosition", contextPosition.ToString());
            }

            if (descriptionPosition >= 0)
            {
                props = props.Add("DescriptionPosition", descriptionPosition.ToString());
            }

            var item = CommonCompletionItem.Create(
                displayText: displayText,
                span: span,
                filterText: filterText ?? (displayText.Length > 0 && displayText[0] == '@' ? displayText : symbols[0].Name),
                sortText: sortText ?? symbols[0].Name,
                glyph: glyph ?? symbols[0].GetGlyph(),
                preselect: preselect,
                isArgumentName: isArgumentName,
                showsWarningIcon: supportedPlatforms != null,
                properties: props,
                tags: tags,
                rules: rules);

            return WithSupportedPlatforms(item, supportedPlatforms);
        }
Beispiel #28
0
        /// <summary>
        ///     Populate the <i>composites</i>IList containing all child glyphs 
        ///     that this glyph uses.
        /// </summary>
        /// <remarks>
        ///     The <i>stream</i> parameter must be positioned 10 bytes from 
        ///     the beginning of the glyph description, i.e. the flags field.
        /// </remarks>
        /// <param name="stream"></param>
        private void ReadCompositeGlyph(FontFileStream stream, Glyph glyph) {
            bool moreComposites = true;
            while (moreComposites) {
                short flags = stream.ReadShort();
                long offset = stream.Position;
                int subsetIndex = reader.IndexMappings.Map(stream.ReadShort());

                glyph.AddChild(subsetIndex);

                // While we're here, remap the child glyph index
                stream.Position = stream.Position - PrimitiveSizes.Short;
                stream.WriteShort(subsetIndex);

                // The following code is based on the C pseudo code supplied 
                // in the glyf table specification.
                int skipBytes = 0;
                if ((flags & BitMasks.Arg1And2AreWords) > 0) {
                    skipBytes = PrimitiveSizes.Short*2;
                }
                else {
                    skipBytes = PrimitiveSizes.UShort;
                }

                if ((flags & BitMasks.WeHaveAScale) > 0) {
                    // Skip scale
                    skipBytes = PrimitiveSizes.F2DOT14;
                }
                else if ((flags & BitMasks.WeHaveAnXAndYScale) > 0) {
                    // Skip xscale and yscale
                    skipBytes = PrimitiveSizes.F2DOT14*2;
                }
                else if ((flags & BitMasks.WeHaveATwoByTwo) > 0) {
                    // Skip xscale, scale01, scale10 and yscale
                    skipBytes = PrimitiveSizes.F2DOT14*4;
                }

                // Glyph instructions
                if ((flags & BitMasks.WeHaveInstructions) > 0) {
                    skipBytes = PrimitiveSizes.Byte*stream.ReadUShort();
                }

                if ((flags & BitMasks.MoreComponents) > 0) {
                    moreComposites = true;
                }
                else {
                    moreComposites = false;
                }

                stream.Skip(skipBytes);
            }
        }
 public CrefCompletionItem(
     Workspace workspace,
     CompletionListProvider completionProvider,
     string displayText,
     string insertionText,
     TextSpan textSpan,
     Func<CancellationToken,
     Task<ImmutableArray<SymbolDisplayPart>>> descriptionFactory,
     Glyph? glyph,
     string sortText)
     : base(workspace, completionProvider, displayText, textSpan, descriptionFactory, glyph, sortText)
 {
     this.InsertionText = insertionText;
 }
        public ImageMoniker GetImageMoniker(Glyph glyph)
        {
            this.AssertIsForeground();

            switch (glyph)
            {
                case Glyph.AddReference:
                    return GetCompositedImageMoniker(
                        CreateLayer(Glyph.Reference.GetImageMoniker(), virtualXOffset: 1, virtualYOffset: 2),
                        CreateLayer(KnownMonikers.PendingAddNode, virtualWidth: 7, virtualXOffset: -1, virtualYOffset: -2));
            }

            return glyph.GetImageMoniker();
        }
Beispiel #31
0
 public override bool OnMouseHover(Glyph g, System.Drawing.Point mouseLoc)
 {
     return(base.OnMouseHover(g, mouseLoc));
 }
Beispiel #32
0
 public override bool OnMouseDoubleClick(Glyph g, System.Windows.Forms.MouseButtons button, System.Drawing.Point mouseLoc)
 {
     return(base.OnMouseDoubleClick(g, button, mouseLoc));
 }
Beispiel #33
0
        public static ImageReference?GetImageReference(this Glyph glyph)
        {
            switch (glyph)
            {
            case Glyph.Assembly:                            return(DsImages.Assembly);

            case Glyph.BasicFile:                           return(DsImages.VBFileNode);

            case Glyph.BasicProject:                        return(DsImages.VBProjectNode);

            case Glyph.ClassPublic:                         return(DsImages.ClassPublic);

            case Glyph.ClassProtected:                      return(DsImages.ClassProtected);

            case Glyph.ClassPrivate:                        return(DsImages.ClassPrivate);

            case Glyph.ClassInternal:                       return(DsImages.ClassInternal);

            case Glyph.CSharpFile:                          return(DsImages.CSFileNode);

            case Glyph.CSharpProject:                       return(DsImages.CSProjectNode);

            case Glyph.ConstantPublic:                      return(DsImages.ConstantPublic);

            case Glyph.ConstantProtected:           return(DsImages.ConstantProtected);

            case Glyph.ConstantPrivate:                     return(DsImages.ConstantPrivate);

            case Glyph.ConstantInternal:            return(DsImages.ConstantInternal);

            case Glyph.DelegatePublic:                      return(DsImages.DelegatePublic);

            case Glyph.DelegateProtected:           return(DsImages.DelegateProtected);

            case Glyph.DelegatePrivate:                     return(DsImages.DelegatePrivate);

            case Glyph.DelegateInternal:            return(DsImages.DelegateInternal);

            case Glyph.EnumPublic:                          return(DsImages.EnumerationPublic);

            case Glyph.EnumProtected:                       return(DsImages.EnumerationProtected);

            case Glyph.EnumPrivate:                         return(DsImages.EnumerationPrivate);

            case Glyph.EnumInternal:                        return(DsImages.EnumerationInternal);

            case Glyph.EnumMember:                          return(DsImages.EnumerationItemPublic);

            case Glyph.Error:                                       return(DsImages.StatusError);

            case Glyph.EventPublic:                         return(DsImages.EventPublic);

            case Glyph.EventProtected:                      return(DsImages.EventProtected);

            case Glyph.EventPrivate:                        return(DsImages.EventPrivate);

            case Glyph.EventInternal:                       return(DsImages.EventInternal);

            case Glyph.ExtensionMethodPublic:       return(DsImages.ExtensionMethod);

            case Glyph.ExtensionMethodProtected: return(DsImages.ExtensionMethod);

            case Glyph.ExtensionMethodPrivate:      return(DsImages.ExtensionMethod);

            case Glyph.ExtensionMethodInternal:     return(DsImages.ExtensionMethod);

            case Glyph.FieldPublic:                         return(DsImages.FieldPublic);

            case Glyph.FieldProtected:                      return(DsImages.FieldProtected);

            case Glyph.FieldPrivate:                        return(DsImages.FieldPrivate);

            case Glyph.FieldInternal:                       return(DsImages.FieldInternal);

            case Glyph.InterfacePublic:                     return(DsImages.InterfacePublic);

            case Glyph.InterfaceProtected:          return(DsImages.InterfaceProtected);

            case Glyph.InterfacePrivate:            return(DsImages.InterfacePrivate);

            case Glyph.InterfaceInternal:           return(DsImages.InterfaceInternal);

            case Glyph.Intrinsic:                           return(DsImages.Type);

            case Glyph.Keyword:                                     return(DsImages.IntellisenseKeyword);

            case Glyph.Label:                                       return(DsImages.Label);

            case Glyph.Local:                                       return(DsImages.LocalVariable);

            case Glyph.Namespace:                           return(DsImages.Namespace);

            case Glyph.MethodPublic:                        return(DsImages.MethodPublic);

            case Glyph.MethodProtected:                     return(DsImages.MethodProtected);

            case Glyph.MethodPrivate:                       return(DsImages.MethodPrivate);

            case Glyph.MethodInternal:                      return(DsImages.MethodInternal);

            case Glyph.ModulePublic:                        return(DsImages.ModulePublic);

            case Glyph.ModuleProtected:                     return(DsImages.ModuleProtected);

            case Glyph.ModulePrivate:                       return(DsImages.ModulePrivate);

            case Glyph.ModuleInternal:                      return(DsImages.ModuleInternal);

            case Glyph.OpenFolder:                          return(DsImages.FolderOpened);

            case Glyph.Operator:                            return(DsImages.OperatorPublic);

            case Glyph.Parameter:                           return(DsImages.LocalVariable);           // Same image as Local, just like what VS does

            case Glyph.PropertyPublic:                      return(DsImages.Property);

            case Glyph.PropertyProtected:           return(DsImages.PropertyProtected);

            case Glyph.PropertyPrivate:                     return(DsImages.PropertyPrivate);

            case Glyph.PropertyInternal:            return(DsImages.PropertyInternal);

            case Glyph.RangeVariable:                       return(DsImages.LocalVariable);

            case Glyph.Reference:                           return(DsImages.Reference);

            case Glyph.StructurePublic:                     return(DsImages.StructurePublic);

            case Glyph.StructureProtected:          return(DsImages.StructureProtected);

            case Glyph.StructurePrivate:            return(DsImages.StructurePrivate);

            case Glyph.StructureInternal:           return(DsImages.StructureInternal);

            case Glyph.TypeParameter:                       return(DsImages.Type);

            case Glyph.Snippet:                                     return(DsImages.Snippet);

            case Glyph.CompletionWarning:           return(DsImages.StatusWarning);

            case Glyph.AddReference:                        return(DsImages.AddReference);

            case Glyph.NuGet:                                       return(DsImages.NuGet);

            default:
                Debug.Fail($"Unknown {nameof(Glyph)}: {glyph}");
                return(null);
            }
        }
Beispiel #34
0
        public static StandardGlyphGroup GetStandardGlyphGroup(this Glyph glyph)
        {
            switch (glyph)
            {
            case Glyph.Assembly:
                return(StandardGlyphGroup.GlyphAssembly);

            case Glyph.BasicFile:
            case Glyph.BasicProject:
                return(StandardGlyphGroup.GlyphVBProject);

            case Glyph.ClassPublic:
            case Glyph.ClassProtected:
            case Glyph.ClassPrivate:
            case Glyph.ClassInternal:
                return(StandardGlyphGroup.GlyphGroupClass);

            case Glyph.ConstantPublic:
            case Glyph.ConstantProtected:
            case Glyph.ConstantPrivate:
            case Glyph.ConstantInternal:
                return(StandardGlyphGroup.GlyphGroupConstant);

            case Glyph.CSharpFile:
                return(StandardGlyphGroup.GlyphCSharpFile);

            case Glyph.CSharpProject:
                return(StandardGlyphGroup.GlyphCoolProject);

            case Glyph.DelegatePublic:
            case Glyph.DelegateProtected:
            case Glyph.DelegatePrivate:
            case Glyph.DelegateInternal:
                return(StandardGlyphGroup.GlyphGroupDelegate);

            case Glyph.EnumPublic:
            case Glyph.EnumProtected:
            case Glyph.EnumPrivate:
            case Glyph.EnumInternal:
                return(StandardGlyphGroup.GlyphGroupEnum);

            case Glyph.EnumMember:
                return(StandardGlyphGroup.GlyphGroupEnumMember);

            case Glyph.Error:
                return(StandardGlyphGroup.GlyphGroupError);

            case Glyph.ExtensionMethodPublic:
                return(StandardGlyphGroup.GlyphExtensionMethod);

            case Glyph.ExtensionMethodProtected:
                return(StandardGlyphGroup.GlyphExtensionMethodProtected);

            case Glyph.ExtensionMethodPrivate:
                return(StandardGlyphGroup.GlyphExtensionMethodPrivate);

            case Glyph.ExtensionMethodInternal:
                return(StandardGlyphGroup.GlyphExtensionMethodInternal);

            case Glyph.EventPublic:
            case Glyph.EventProtected:
            case Glyph.EventPrivate:
            case Glyph.EventInternal:
                return(StandardGlyphGroup.GlyphGroupEvent);

            case Glyph.FieldPublic:
            case Glyph.FieldProtected:
            case Glyph.FieldPrivate:
            case Glyph.FieldInternal:
                return(StandardGlyphGroup.GlyphGroupField);

            case Glyph.InterfacePublic:
            case Glyph.InterfaceProtected:
            case Glyph.InterfacePrivate:
            case Glyph.InterfaceInternal:
                return(StandardGlyphGroup.GlyphGroupInterface);

            case Glyph.Intrinsic:
                return(StandardGlyphGroup.GlyphGroupIntrinsic);

            case Glyph.Keyword:
                return(StandardGlyphGroup.GlyphKeyword);

            case Glyph.Label:
                return(StandardGlyphGroup.GlyphGroupIntrinsic);

            case Glyph.Local:
                return(StandardGlyphGroup.GlyphGroupVariable);

            case Glyph.Namespace:
                return(StandardGlyphGroup.GlyphGroupNamespace);

            case Glyph.MethodPublic:
            case Glyph.MethodProtected:
            case Glyph.MethodPrivate:
            case Glyph.MethodInternal:
                return(StandardGlyphGroup.GlyphGroupMethod);

            case Glyph.ModulePublic:
            case Glyph.ModuleProtected:
            case Glyph.ModulePrivate:
            case Glyph.ModuleInternal:
                return(StandardGlyphGroup.GlyphGroupModule);

            case Glyph.OpenFolder:
                return(StandardGlyphGroup.GlyphOpenFolder);

            case Glyph.Operator:
                return(StandardGlyphGroup.GlyphGroupOperator);

            case Glyph.Parameter:
                return(StandardGlyphGroup.GlyphGroupVariable);

            case Glyph.PropertyPublic:
            case Glyph.PropertyProtected:
            case Glyph.PropertyPrivate:
            case Glyph.PropertyInternal:
                return(StandardGlyphGroup.GlyphGroupProperty);

            case Glyph.RangeVariable:
                return(StandardGlyphGroup.GlyphGroupVariable);

            case Glyph.Reference:
                return(StandardGlyphGroup.GlyphReference);

            case Glyph.StructurePublic:
            case Glyph.StructureProtected:
            case Glyph.StructurePrivate:
            case Glyph.StructureInternal:
                return(StandardGlyphGroup.GlyphGroupStruct);

            case Glyph.TypeParameter:
                return(StandardGlyphGroup.GlyphGroupType);

            case Glyph.Snippet:
                return(StandardGlyphGroup.GlyphCSharpExpansion);

            case Glyph.CompletionWarning:
                return(StandardGlyphGroup.GlyphCompletionWarning);

            default:
                throw new ArgumentException("glyph");
            }
        }
Beispiel #35
0
        public static ImageMoniker GetImageMoniker(this Glyph glyph)
        {
            switch (glyph)
            {
            case Glyph.Assembly:
                return(KnownMonikers.Assembly);

            case Glyph.BasicFile:
                return(KnownMonikers.VBFileNode);

            case Glyph.BasicProject:
                return(KnownMonikers.VBProjectNode);

            case Glyph.ClassPublic:
                return(KnownMonikers.ClassPublic);

            case Glyph.ClassProtected:
                return(KnownMonikers.ClassProtected);

            case Glyph.ClassPrivate:
                return(KnownMonikers.ClassPrivate);

            case Glyph.ClassInternal:
                return(KnownMonikers.ClassInternal);

            case Glyph.CSharpFile:
                return(KnownMonikers.CSFileNode);

            case Glyph.CSharpProject:
                return(KnownMonikers.CSProjectNode);

            case Glyph.ConstantPublic:
                return(KnownMonikers.ConstantPublic);

            case Glyph.ConstantProtected:
                return(KnownMonikers.ConstantProtected);

            case Glyph.ConstantPrivate:
                return(KnownMonikers.ConstantPrivate);

            case Glyph.ConstantInternal:
                return(KnownMonikers.ConstantInternal);

            case Glyph.DelegatePublic:
                return(KnownMonikers.DelegatePublic);

            case Glyph.DelegateProtected:
                return(KnownMonikers.DelegateProtected);

            case Glyph.DelegatePrivate:
                return(KnownMonikers.DelegatePrivate);

            case Glyph.DelegateInternal:
                return(KnownMonikers.DelegateInternal);

            case Glyph.EnumPublic:
                return(KnownMonikers.EnumerationPublic);

            case Glyph.EnumProtected:
                return(KnownMonikers.EnumerationProtected);

            case Glyph.EnumPrivate:
                return(KnownMonikers.EnumerationPrivate);

            case Glyph.EnumInternal:
                return(KnownMonikers.EnumerationInternal);

            case Glyph.EnumMember:
                return(KnownMonikers.EnumerationItemPublic);

            case Glyph.Error:
                return(KnownMonikers.StatusError);

            case Glyph.EventPublic:
                return(KnownMonikers.EventPublic);

            case Glyph.EventProtected:
                return(KnownMonikers.EventProtected);

            case Glyph.EventPrivate:
                return(KnownMonikers.EventPrivate);

            case Glyph.EventInternal:
                return(KnownMonikers.EventInternal);

            // Extension methods have the same glyph regardless of accessibility.
            case Glyph.ExtensionMethodPublic:
            case Glyph.ExtensionMethodProtected:
            case Glyph.ExtensionMethodPrivate:
            case Glyph.ExtensionMethodInternal:
                return(KnownMonikers.ExtensionMethod);

            case Glyph.FieldPublic:
                return(KnownMonikers.FieldPublic);

            case Glyph.FieldProtected:
                return(KnownMonikers.FieldProtected);

            case Glyph.FieldPrivate:
                return(KnownMonikers.FieldPrivate);

            case Glyph.FieldInternal:
                return(KnownMonikers.FieldInternal);

            case Glyph.InterfacePublic:
                return(KnownMonikers.InterfacePublic);

            case Glyph.InterfaceProtected:
                return(KnownMonikers.InterfaceProtected);

            case Glyph.InterfacePrivate:
                return(KnownMonikers.InterfacePrivate);

            case Glyph.InterfaceInternal:
                return(KnownMonikers.InterfaceInternal);

            // TODO: Figure out the right thing to return here.
            case Glyph.Intrinsic:
                return(KnownMonikers.Type);

            case Glyph.Keyword:
                return(KnownMonikers.IntellisenseKeyword);

            case Glyph.Label:
                return(KnownMonikers.Label);

            case Glyph.Parameter:
            case Glyph.Local:
                return(KnownMonikers.LocalVariable);

            case Glyph.Namespace:
                return(KnownMonikers.Namespace);

            case Glyph.MethodPublic:
                return(KnownMonikers.MethodPublic);

            case Glyph.MethodProtected:
                return(KnownMonikers.MethodProtected);

            case Glyph.MethodPrivate:
                return(KnownMonikers.MethodPrivate);

            case Glyph.MethodInternal:
                return(KnownMonikers.MethodInternal);

            case Glyph.ModulePublic:
                return(KnownMonikers.ModulePublic);

            case Glyph.ModuleProtected:
                return(KnownMonikers.ModuleProtected);

            case Glyph.ModulePrivate:
                return(KnownMonikers.ModulePrivate);

            case Glyph.ModuleInternal:
                return(KnownMonikers.ModuleInternal);

            case Glyph.OpenFolder:
                return(KnownMonikers.OpenFolder);

            case Glyph.Operator:
                return(KnownMonikers.Operator);

            case Glyph.PropertyPublic:
                return(KnownMonikers.PropertyPublic);

            case Glyph.PropertyProtected:
                return(KnownMonikers.PropertyProtected);

            case Glyph.PropertyPrivate:
                return(KnownMonikers.PropertyPrivate);

            case Glyph.PropertyInternal:
                return(KnownMonikers.PropertyInternal);

            case Glyph.RangeVariable:
                return(KnownMonikers.FieldPublic);

            case Glyph.Reference:
                return(KnownMonikers.Reference);

            case Glyph.StructurePublic:
                return(KnownMonikers.ValueTypePublic);

            case Glyph.StructureProtected:
                return(KnownMonikers.ValueTypeProtected);

            case Glyph.StructurePrivate:
                return(KnownMonikers.ValueTypePrivate);

            case Glyph.StructureInternal:
                return(KnownMonikers.ValueTypeInternal);

            case Glyph.TypeParameter:
                return(KnownMonikers.Type);

            case Glyph.Snippet:
                return(KnownMonikers.Snippet);

            case Glyph.CompletionWarning:
                return(KnownMonikers.IntellisenseWarning);

            case Glyph.StatusInformation:
                return(KnownMonikers.StatusInformation);

            case Glyph.NuGet:
                return(KnownMonikers.NuGet);

            default:
                throw new ArgumentException("glyph");
            }
        }
Beispiel #36
0
 public static string GetEssence(Glyph g)
 {
     return(GetGlyphEssence(g.Number));
 }
Beispiel #37
0
 public static string GetAction(Glyph g)
 {
     return(GetGlyphAction(g.Number));
 }
Beispiel #38
0
 /// <summary>Gets the kerning between two glyphs.</summary>
 /// <param name="first">the first glyph</param>
 /// <param name="second">the second glyph</param>
 /// <returns>the kerning to be applied</returns>
 public abstract int GetKerning(Glyph first, Glyph second);
Beispiel #39
0
        /// <summary>Get glyph's bbox.</summary>
        /// <param name="unicode">a unicode symbol or FontSpecif code.</param>
        /// <returns>Gets bbox in normalized 1000 units.</returns>
        public virtual int[] GetCharBBox(int unicode)
        {
            Glyph glyph = GetGlyph(unicode);

            return(glyph != null?glyph.GetBbox() : null);
        }
Beispiel #40
0
        /// <summary>Get glyph's width.</summary>
        /// <param name="unicode">a unicode symbol or FontSpecif code.</param>
        /// <returns>Gets width in normalized 1000 units.</returns>
        public virtual int GetWidth(int unicode)
        {
            Glyph glyph = GetGlyph(unicode);

            return(glyph != null?glyph.GetWidth() : 0);
        }
Beispiel #41
0
 public override void OnDragLeave(Glyph g, EventArgs e)
 {
     base.OnDragLeave(g, e);
 }
        private static void AssertValidDefinitionProperties(LSP.VSInternalReferenceItem[] referenceItems, int definitionIndex, Glyph definitionGlyph)
        {
            var definition   = referenceItems[definitionIndex];
            var definitionId = definition.DefinitionId;

            Assert.NotNull(definition.DefinitionText);

            Assert.Equal(definitionGlyph.GetImageId(), definition.DefinitionIcon.ImageId);

            for (var i = 0; i < referenceItems.Length; i++)
            {
                if (i == definitionIndex)
                {
                    continue;
                }

                Assert.Null(referenceItems[i].DefinitionText);
                Assert.Equal(0, referenceItems[i].DefinitionIcon.ImageId.Id);
                Assert.Equal(definitionId, referenceItems[i].DefinitionId);
                Assert.NotEqual(definitionId, referenceItems[i].Id);
            }
        }
Beispiel #43
0
 public override void OnDragOver(Glyph g, System.Windows.Forms.DragEventArgs e)
 {
     base.OnDragOver(g, e);
 }
Beispiel #44
0
    void LoadGlyph()
    {
        glyphList = new List <Glyph>();

        // load font config file
        using (Stream stream = new MemoryStream(xmlFile.bytes))
        {
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.IgnoreComments   = true;
            settings.IgnoreWhitespace = true;

            using (XmlReader reader = XmlReader.Create(stream, settings))
            {
                reader.MoveToContent();

                reader.ReadStartElement("fontconfig");
                {
                    // typeface
                    if (reader.Name == "font")
                    {
                        lineHeight = int.Parse(reader.GetAttribute("height"));

                        // move to next
                        reader.Read();
                    }

                    // texture info
                    if (reader.Name == "texture")
                    {
                        textureWidth  = int.Parse(reader.GetAttribute("width"));
                        textureHeight = int.Parse(reader.GetAttribute("height"));

                        // move to next
                        reader.Read();
                    }

                    // texture info
                    reader.ReadToFollowing("size");
                    if (reader.Name == "size")
                    {
                        //glyphWidth = int.Parse(reader.GetAttribute("width"));
                        //glyphHeight = int.Parse(reader.GetAttribute("height"));

                        // move to next
                        reader.Read();
                    }

                    // images
                    reader.ReadToFollowing("images");
                    if (!reader.IsEmptyElement)
                    {
                        List <string> images = new List <string>();
                        reader.ReadStartElement("images");

                        if (reader.Name == "image")
                        {
                            do
                            {
                                string imagePath = reader.GetAttribute("path");
                                images.Add(imagePath);
                            }while (reader.ReadToNextSibling("image"));
                        }
                        reader.ReadEndElement();

                        if (images.Count > 0)
                        {
                            // only handle one texture
                            texturePath = images[0];
                        }
                        else
                        {
                            Debug.LogError("image path missing");
                            return;
                        }
                    }
                    else
                    {
                        reader.Read();
                    }

                    // glyph
                    if (!reader.IsEmptyElement)
                    {
                        reader.ReadStartElement("glyphs");
                        if (reader.Name == "glyph")
                        {
                            do
                            {
                                char character = char.Parse(reader.GetAttribute("char"));
                                int.Parse(reader.GetAttribute("page"));
                                int x = int.Parse(reader.GetAttribute("x"));
                                int y = int.Parse(reader.GetAttribute("y"));
                                int w = int.Parse(reader.GetAttribute("w"));
                                int h = int.Parse(reader.GetAttribute("h"));

                                int ix = int.Parse(reader.GetAttribute("ix"));
                                int iy = int.Parse(reader.GetAttribute("iy"));
                                int iw = int.Parse(reader.GetAttribute("iw"));
                                int ih = int.Parse(reader.GetAttribute("ih"));

                                Glyph glyph = new Glyph();
                                glyph.code          = character;
                                glyph.bound         = new Rect(x, y, w, h);
                                glyph.interiorBound = new Rect(ix, iy, iw, ih);
                                glyph.baseline      = int.Parse(reader.GetAttribute("baseline"));
                                glyph.spacingA      = int.Parse(reader.GetAttribute("spacingA"));
                                glyph.spacingB      = int.Parse(reader.GetAttribute("spacingB"));
                                glyph.spacingC      = int.Parse(reader.GetAttribute("spacingC"));

                                baseline = glyph.baseline;

                                glyphList.Add(glyph);
                            }while (reader.ReadToNextSibling("glyph"));
                        }
                        reader.ReadEndElement();
                    }
                    else
                    {
                        reader.Read();
                    }
                }
                reader.ReadEndElement();
            }
        }
    }
Beispiel #45
0
 public PreviewEngine(IThreadingContext threadingContext, string title, string helpString, string description, string topLevelItemName, Glyph topLevelGlyph, Solution newSolution, Solution oldSolution, IComponentModel componentModel, bool showCheckBoxes = true)
     : this(threadingContext, title, helpString, description, topLevelItemName, topLevelGlyph, newSolution, oldSolution, componentModel, null, showCheckBoxes)
 {
 }
Beispiel #46
0
        internal void InternalDrawGlyph(ref InternalDrawCommand parameters, ref Vector2 fontSize, ref Glyph glyph, float x, float y, float nextx, ref Vector2 auxiliaryScaling)
        {
            if (char.IsWhiteSpace((char)glyph.Character) || glyph.Subrect.Width == 0 || glyph.Subrect.Height == 0)
            {
                return;
            }

            var spriteEffects = parameters.SpriteEffects;

            var offset = new Vector2(x, y + GetBaseOffsetY(fontSize.Y) + glyph.Offset.Y);

            Vector2.Modulate(ref offset, ref AxisDirectionTable[(int)spriteEffects & 3], out offset);
            Vector2.Add(ref offset, ref parameters.Origin, out offset);
            offset.X = (float)Math.Round(offset.X);
            offset.Y = (float)Math.Round(offset.Y);

            if (spriteEffects != SpriteEffects.None)
            {
                // For mirrored characters, specify bottom and/or right instead of top left.
                var glyphRect = new Vector2(glyph.Subrect.Right - glyph.Subrect.Left, glyph.Subrect.Top - glyph.Subrect.Bottom);
                Vector2.Modulate(ref glyphRect, ref AxisIsMirroredTable[(int)spriteEffects & 3], out offset);
            }
            var        destination     = new RectangleF(parameters.Position.X, parameters.Position.Y, parameters.Scale.X, parameters.Scale.Y);
            RectangleF?sourceRectangle = glyph.Subrect;

            parameters.SpriteBatch.DrawSprite(Textures[glyph.BitmapIndex], ref destination, true, ref sourceRectangle, parameters.Color, parameters.Rotation, ref offset, spriteEffects, ImageOrientation.AsIs, parameters.Depth, Swizzle, true);
        }
Beispiel #47
0
 public static string GetPower(Glyph g)
 {
     return(GetGlyphPower(g.Number));
 }
Beispiel #48
0
        internal void InternalUIDrawGlyph(ref InternalUIDrawCommand parameters, ref Vector2 requestedFontSize, ref Glyph glyph, float x, float y, float nextx, ref Vector2 auxiliaryScaling)
        {
            if (char.IsWhiteSpace((char)glyph.Character))
            {
                return;
            }

            // Skip items with null size
            var elementSize = new Vector2(auxiliaryScaling.X * glyph.Subrect.Width / parameters.RealVirtualResolutionRatio.X,
                                          auxiliaryScaling.Y * glyph.Subrect.Height / parameters.RealVirtualResolutionRatio.Y);

            if (elementSize.Length() < MathUtil.ZeroTolerance)
            {
                return;
            }

            var xShift = x;
            var yShift = y + (GetBaseOffsetY(requestedFontSize.Y) + glyph.Offset.Y * auxiliaryScaling.Y);

            if (parameters.SnapText)
            {
                xShift = (float)Math.Round(xShift);
                yShift = (float)Math.Round(yShift);
            }
            var xScaledShift = xShift / parameters.RealVirtualResolutionRatio.X;
            var yScaledShift = yShift / parameters.RealVirtualResolutionRatio.Y;

            var worldMatrix = parameters.Matrix;

            worldMatrix.M41 += worldMatrix.M11 * xScaledShift + worldMatrix.M21 * yScaledShift;
            worldMatrix.M42 += worldMatrix.M12 * xScaledShift + worldMatrix.M22 * yScaledShift;
            worldMatrix.M43 += worldMatrix.M13 * xScaledShift + worldMatrix.M23 * yScaledShift;

            worldMatrix.M11 *= elementSize.X;
            worldMatrix.M12 *= elementSize.X;
            worldMatrix.M13 *= elementSize.X;
            worldMatrix.M21 *= elementSize.Y;
            worldMatrix.M22 *= elementSize.Y;
            worldMatrix.M23 *= elementSize.Y;

            RectangleF sourceRectangle = glyph.Subrect;

            parameters.Batch.DrawCharacter(Textures[glyph.BitmapIndex], ref worldMatrix, ref sourceRectangle, ref parameters.Color, parameters.DepthBias, Swizzle);
        }
Beispiel #49
0
        private void InitializeFontProperties()
        {
            // initialize sfnt tables
            OpenTypeParser.HeaderTable      head = fontParser.GetHeadTable();
            OpenTypeParser.HorizontalHeader hhea = fontParser.GetHheaTable();
            OpenTypeParser.WindowsMetrics   os_2 = fontParser.GetOs_2Table();
            OpenTypeParser.PostTable        post = fontParser.GetPostTable();
            isFontSpecific = fontParser.GetCmapTable().fontSpecific;
            kerning        = fontParser.ReadKerning(head.unitsPerEm);
            bBoxes         = fontParser.ReadBbox(head.unitsPerEm);
            // font names group
            fontNames = fontParser.GetFontNames();
            // font metrics group
            fontMetrics.SetUnitsPerEm(head.unitsPerEm);
            fontMetrics.UpdateBbox(head.xMin, head.yMin, head.xMax, head.yMax);
            fontMetrics.SetNumberOfGlyphs(fontParser.ReadNumGlyphs());
            fontMetrics.SetGlyphWidths(fontParser.GetGlyphWidthsByIndex());
            fontMetrics.SetTypoAscender(os_2.sTypoAscender);
            fontMetrics.SetTypoDescender(os_2.sTypoDescender);
            fontMetrics.SetCapHeight(os_2.sCapHeight);
            fontMetrics.SetXHeight(os_2.sxHeight);
            fontMetrics.SetItalicAngle(post.italicAngle);
            fontMetrics.SetAscender(hhea.Ascender);
            fontMetrics.SetDescender(hhea.Descender);
            fontMetrics.SetLineGap(hhea.LineGap);
            fontMetrics.SetWinAscender(os_2.usWinAscent);
            fontMetrics.SetWinDescender(os_2.usWinDescent);
            fontMetrics.SetAdvanceWidthMax(hhea.advanceWidthMax);
            fontMetrics.SetUnderlinePosition((post.underlinePosition - post.underlineThickness) / 2);
            fontMetrics.SetUnderlineThickness(post.underlineThickness);
            fontMetrics.SetStrikeoutPosition(os_2.yStrikeoutPosition);
            fontMetrics.SetStrikeoutSize(os_2.yStrikeoutSize);
            fontMetrics.SetSubscriptOffset(-os_2.ySubscriptYOffset);
            fontMetrics.SetSubscriptSize(os_2.ySubscriptYSize);
            fontMetrics.SetSuperscriptOffset(os_2.ySuperscriptYOffset);
            fontMetrics.SetSuperscriptSize(os_2.ySuperscriptYSize);
            fontMetrics.SetIsFixedPitch(post.isFixedPitch);
            // font identification group
            String[][] ttfVersion = fontNames.GetNames(5);
            if (ttfVersion != null)
            {
                fontIdentification.SetTtfVersion(ttfVersion[0][3]);
            }
            String[][] ttfUniqueId = fontNames.GetNames(3);
            if (ttfUniqueId != null)
            {
                fontIdentification.SetTtfVersion(ttfUniqueId[0][3]);
            }
            byte[] pdfPanose = new byte[12];
            pdfPanose[1] = (byte)(os_2.sFamilyClass);
            pdfPanose[0] = (byte)(os_2.sFamilyClass >> 8);
            Array.Copy(os_2.panose, 0, pdfPanose, 2, 10);
            fontIdentification.SetPanose(pdfPanose);
            IDictionary <int, int[]> cmap = GetActiveCmap();

            int[] glyphWidths = fontParser.GetGlyphWidthsByIndex();
            int   numOfGlyphs = fontMetrics.GetNumberOfGlyphs();

            unicodeToGlyph = new LinkedDictionary <int, Glyph>(cmap.Count);
            codeToGlyph    = new LinkedDictionary <int, Glyph>(numOfGlyphs);
            avgWidth       = 0;
            foreach (int charCode in cmap.Keys)
            {
                int index = cmap.Get(charCode)[0];
                if (index >= numOfGlyphs)
                {
                    ILog LOGGER = LogManager.GetLogger(typeof(iText.IO.Font.TrueTypeFont));
                    LOGGER.Warn(MessageFormatUtil.Format(iText.IO.LogMessageConstant.FONT_HAS_INVALID_GLYPH, GetFontNames().GetFontName
                                                             (), index));
                    continue;
                }
                Glyph glyph = new Glyph(index, glyphWidths[index], charCode, bBoxes != null ? bBoxes[index] : null);
                unicodeToGlyph.Put(charCode, glyph);
                // This is done on purpose to keep the mapping to glyphs with smaller unicode values, in contrast with
                // larger values which often represent different forms of other characters.
                if (!codeToGlyph.ContainsKey(index))
                {
                    codeToGlyph.Put(index, glyph);
                }
                avgWidth += glyph.GetWidth();
            }
            FixSpaceIssue();
            for (int index = 0; index < glyphWidths.Length; index++)
            {
                if (codeToGlyph.ContainsKey(index))
                {
                    continue;
                }
                Glyph glyph = new Glyph(index, glyphWidths[index], -1);
                codeToGlyph.Put(index, glyph);
                avgWidth += glyph.GetWidth();
            }
            if (codeToGlyph.Count != 0)
            {
                avgWidth /= codeToGlyph.Count;
            }
            ReadGdefTable();
            ReadGsubTable();
            ReadGposTable();
            isVertical = false;
        }
Beispiel #50
0
 public override int GetKerning(Glyph glyph1, Glyph glyph2)
 {
     return(0);
 }
Beispiel #51
0
 public static ImageSource GetImageSource(this Glyph glyph, IGlyphService glyphService)
 {
     return(glyphService.GetGlyph(glyph.GetStandardGlyphGroup(), glyph.GetStandardGlyphItem()));
 }
Beispiel #52
0
 public override void OnLoseCapture(Glyph g, EventArgs e)
 {
     base.OnLoseCapture(g, e);
 }
Beispiel #53
0
 /// <summary>
 /// draw specfic glyph with current settings, at specific position
 /// </summary>
 /// <param name="glyph"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 public void DrawGlyph(Glyph glyph, double x, double y)
 {
     //TODO...
 }
        public virtual void IsDigitPositiveTest()
        {
            Glyph glyph = new Glyph(0, 0, '8');

            NUnit.Framework.Assert.IsTrue(iText.IO.Util.TextUtil.IsLetterOrDigit(glyph));
        }
Beispiel #55
0
 public override bool OnMouseEnter(Glyph g)
 {
     return(base.OnMouseEnter(g));
 }
Beispiel #56
0
 public override void OnQueryContinueDrag(Glyph g, System.Windows.Forms.QueryContinueDragEventArgs e)
 {
     base.OnQueryContinueDrag(g, e);
 }
Beispiel #57
0
 public override void OnGiveFeedback(Glyph g, System.Windows.Forms.GiveFeedbackEventArgs e)
 {
     base.OnGiveFeedback(g, e);
 }
Beispiel #58
0
 public Result(Solution solutionWithProperty, string name, Glyph glyph)
 {
     this.Solution = solutionWithProperty;
     this.Name     = name;
     this.Glyph    = glyph;
 }
Beispiel #59
0
 public Result(Solution solutionWithProperty, string name, Glyph glyph, List <IFieldSymbol> failedFieldSymbols) :
     this(solutionWithProperty, name, glyph)
 {
     this.FailedFields = failedFieldSymbols.ToImmutableArrayOrEmpty();
 }
Beispiel #60
0
 public override bool OnMouseUp(Glyph g, MouseButtons button)
 {
     _designer.AddPanel(this, EventArgs.Empty);
     return(base.OnMouseUp(g, button));
 }