Exemplo n.º 1
0
        private bool CheckAssociatedControl(Component c, Glyph childGlyph, GlyphCollection glyphs)
        {
            bool flag = false;
            ToolStripDropDownItem dropDownItem = c as ToolStripDropDownItem;

            if (dropDownItem != null)
            {
                flag = this.CheckDropDownBounds(dropDownItem, childGlyph, glyphs);
            }
            if (flag)
            {
                return(flag);
            }
            Control associatedControl = this.GetAssociatedControl(c);

            if (((associatedControl == null) || (associatedControl == this.toolStripContainer)) || System.Design.UnsafeNativeMethods.IsChild(new HandleRef(this.toolStripContainer, this.toolStripContainer.Handle), new HandleRef(associatedControl, associatedControl.Handle)))
            {
                return(flag);
            }
            Rectangle bounds = childGlyph.Bounds;
            Rectangle rect   = base.BehaviorService.ControlRectInAdornerWindow(associatedControl);

            if ((c == this.designerHost.RootComponent) || !bounds.IntersectsWith(rect))
            {
                glyphs.Insert(0, childGlyph);
            }
            return(true);
        }
Exemplo n.º 2
0
 public void GetGlyphs(ref GlyphCollection glyphs, System.Windows.Forms.Design.Behavior.Behavior standardBehavior)
 {
     if (this.ImmediateParent != null)
     {
         Rectangle glyphBounds = this.GetGlyphBounds();
         ToolStripDesignerUtils.GetAdjustedBounds(this.ToolStripItem, ref glyphBounds);
         BehaviorService service = (BehaviorService)this.GetService(typeof(BehaviorService));
         if (service.ControlRectInAdornerWindow((Control)this.ImmediateParent).Contains(glyphBounds.Left, glyphBounds.Top))
         {
             if (this.ToolStripItem.IsOnDropDown)
             {
                 ToolStrip currentParent = this.ToolStripItem.GetCurrentParent();
                 if (currentParent == null)
                 {
                     currentParent = this.ToolStripItem.Owner;
                 }
                 if ((currentParent != null) && currentParent.Visible)
                 {
                     glyphs.Add(new MiniLockedBorderGlyph(glyphBounds, SelectionBorderGlyphType.Top, standardBehavior, true));
                     glyphs.Add(new MiniLockedBorderGlyph(glyphBounds, SelectionBorderGlyphType.Bottom, standardBehavior, true));
                     glyphs.Add(new MiniLockedBorderGlyph(glyphBounds, SelectionBorderGlyphType.Left, standardBehavior, true));
                     glyphs.Add(new MiniLockedBorderGlyph(glyphBounds, SelectionBorderGlyphType.Right, standardBehavior, true));
                 }
             }
             else
             {
                 glyphs.Add(new MiniLockedBorderGlyph(glyphBounds, SelectionBorderGlyphType.Top, standardBehavior, true));
                 glyphs.Add(new MiniLockedBorderGlyph(glyphBounds, SelectionBorderGlyphType.Bottom, standardBehavior, true));
                 glyphs.Add(new MiniLockedBorderGlyph(glyphBounds, SelectionBorderGlyphType.Left, standardBehavior, true));
                 glyphs.Add(new MiniLockedBorderGlyph(glyphBounds, SelectionBorderGlyphType.Right, standardBehavior, true));
             }
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// get glyhs of the designer
        /// </summary>
        /// <param name="selectionType"></param>
        /// <returns></returns>
        public override GlyphCollection GetGlyphs(GlyphSelectionType selectionType)
        {
            GlyphCollection glyphs = new GlyphCollection();

            // when the split container is not readonly, add the glyphs
            if (!this.spc.IsReadOnly)
            {
                Point     location            = base.BehaviorService.MapAdornerWindowPoint(this.spc.Handle, this.spc.DisplayRectangle.Location);
                Rectangle clientAreaRectangle = new Rectangle(location, this.spc.DisplayRectangle.Size);
                for (int i = 0; i < spc.Panels.Count - 1; i++)
                {
                    Control            item       = spc.GetChildByIndex(i);
                    PropertyDescriptor descriptor = TypeDescriptor.GetProperties(item.Controls[0])["Locked"];
                    bool isLocked = (descriptor != null) ? ((bool)descriptor.GetValue(item.Controls[0])) : false;
                    if (!isLocked && item.Visible) // show glyphs when form inside panel is not locked
                    {
                        Behavior b = new SplitterResizeBehavior(spc, base.Component.Site, item);

                        if (spc.Orientation == Orientation.Horizontal)
                        {
                            glyphs.Add(GetVerticalResizeGlyph(clientAreaRectangle, item.Bounds.Bottom, b));
                        }
                        else
                        {
                            glyphs.Add(GetHorizontalResizeGlyph(clientAreaRectangle, item.Bounds.Right, b));
                        }
                    }
                }
            }
            return(glyphs);
        }
Exemplo n.º 4
0
        void GetQuad(FontGlyph glyph, FontGlyph prevGlyph, GlyphCollection collection, float spacing, ref float x, ref float y, FontGlyphSquad *q)
        {
            if (prevGlyph != null)
            {
                float adv = 0;
                if (UseKernings && glyph.Font == prevGlyph.Font)
                {
                    adv = prevGlyph.Font.GetGlyphKernAdvance(prevGlyph.Index, glyph.Index) * glyph.Font.Scale;
                }

                x += (int)(adv + spacing + 0.5f);
            }

            float rx = 0;
            float ry = 0;

            rx    = x + glyph.XOffset;
            ry    = y + glyph.YOffset;
            q->X0 = rx;
            q->Y0 = ry;
            q->X1 = rx + glyph.Bounds.Width;
            q->Y1 = ry + glyph.Bounds.Height;
            q->S0 = glyph.Bounds.X * _itw;
            q->T0 = glyph.Bounds.Y * _ith;
            q->S1 = glyph.Bounds.Right * _itw;
            q->T1 = glyph.Bounds.Bottom * _ith;

            x += (int)(glyph.XAdvance / 10.0f + 0.5f);
        }
Exemplo n.º 5
0
        public static void overlayText(TextMatchEnumerator enumerator, string dsTag)
        {
            foreach (TextMatch match in enumerator)
            {
                GlyphCollection glyphs     = match.Glyphs;
                Glyph           firstGlyph = glyphs[0];
                Glyph           lastGlyph  = glyphs[glyphs.Count - 1];

                MultilineTextShape textShape = new MultilineTextShape();
                TranslateTransform translate = new TranslateTransform(firstGlyph.BottomLeft.X, firstGlyph.BottomLeft.Y);
                textShape.Transform = translate;

                textShape.Width  = lastGlyph.TopRight.X - firstGlyph.BottomLeft.X;
                textShape.Height = lastGlyph.TopRight.Y - firstGlyph.BottomLeft.Y;
                translate.Y     += textShape.Height;
                textShape.HorizontalAlignment = HorizontalAlignment.Center;
                textShape.Opacity             = 200;

                Fragment fragment = new Fragment(dsTag, 12);
                fragment.TextColor = TallComponents.PDF.Colors.RgbColor.Blue;
                textShape.Fragments.Add(fragment);

                match.Page.Overlay.Add(textShape);
            }
        }
Exemplo n.º 6
0
        FontGlyph GetGlyph(GraphicsDevice graphicsDevice, GlyphCollection glyphs, int codepoint)
        {
            var result = GetGlyphInternal(graphicsDevice, glyphs, codepoint);

            if (result == null && DefaultCharacter != null)
            {
                result = GetGlyphInternal(graphicsDevice, glyphs, DefaultCharacter.Value);
            }

            return(result);
        }
Exemplo n.º 7
0
        //protected override bool GetHitTest(Point pt)
        //{
        //    TreeView tree = this.Control as TreeView;
        //    if(tree.ClientRectangle.Contains(tree.PointToClient(pt)))
        //    {
        //        return true;
        //    }
        //    return false;
        //}
        //protected override void WndProc(ref Message m)
        //{
        //    if (m.Msg == (int)WinApi.Messages.WM_VSCROLL)
        //    {
        //        JwDialog.AlertInfo($"MESSAGe;{m.Msg} {m.WParam} {m.LParam}");
        //    }
        //    base.WndProc(ref m);
        //}
        public override GlyphCollection GetGlyphs(GlyphSelectionType selectionType)
        {
            GlyphCollection glyphs = base.GetGlyphs(selectionType);

            if (SelectionService != null)
            {
                if (SelectionService.PrimarySelection == this.Control)
                {
                    glyphs.Add(new EventGlyph(this.BehaviorService, this.Control));
                }
            }
            return(glyphs);
        }
Exemplo n.º 8
0
        GlyphCollection GetGlyphsCollection(int size)
        {
            GlyphCollection result;

            if (_glyphs.TryGetValue(size, out result))
            {
                return(result);
            }

            result        = new GlyphCollection();
            _glyphs[size] = result;
            return(result);
        }
Exemplo n.º 9
0
        public string GetGlyphCollection ( GlyphCollection glyphs )
        {
            switch (glyphs)
            {
                case GlyphCollection.NEHE:
                    return GLYPH_NEHE;
                case GlyphCollection.Ascii:
                    return GLYPH_ASCII;
                default:
                    return string.Empty;

            }
        }
Exemplo n.º 10
0
        static string GenerateFontName (string fontFileName, int size, GlyphCollection type, bool useDistanceField)
        {
            var tempName = new StringBuilder(fontFileName);

            tempName.Append("_");
            tempName.Append(type.ToString());
            tempName.Append("_");
            if (useDistanceField)
                tempName.Append("_df");
            tempName.Append("_");
            tempName.Append(size);

            return tempName.ToString();
        }
Exemplo n.º 11
0
        public string GetGlyphCollection(GlyphCollection glyphs)
        {
            switch (glyphs)
            {
            case GlyphCollection.NEHE:
                return(GLYPH_NEHE);

            case GlyphCollection.Ascii:
                return(GLYPH_ASCII);

            default:
                return(string.Empty);
            }
        }
Exemplo n.º 12
0
        //<summary>
        //get glyhs of the designer
        //</summary>
        //<param name="selectionType"></param>
        //<returns></returns>
        public override GlyphCollection GetGlyphs(GlyphSelectionType selectionType)
        {
            GlyphCollection    glyphs     = base.GetGlyphs(selectionType);
            PropertyDescriptor descriptor = TypeDescriptor.GetProperties(base.Component)["Locked"];
            bool isLocked = (descriptor != null) ? ((bool)descriptor.GetValue(base.Component)) : false;

            if (selectionType != GlyphSelectionType.NotSelected && !isLocked && !tableControl.IsDragging) //selectionType == GlyphSelectionType.SelectedPrimary
            {
                Point     location            = base.BehaviorService.MapAdornerWindowPoint(this.tableControl.Handle, this.tableControl.DisplayRectangle.Location);
                Rectangle clientAreaRectangle = new Rectangle(location, this.tableControl.DisplayRectangle.Size);
                glyphs.Add(GetVerticalResizeGlyph(clientAreaRectangle, tableControl.TitleHeight + tableControl.RowHeight, RowHeightResizeBehavior));
                glyphs.Add(GetVerticalResizeGlyph(clientAreaRectangle, tableControl.TitleHeight, TitleHeightResizeBehavior));
            }
            return(glyphs);
        }
Exemplo n.º 13
0
        public virtual void SetCurrentGlyphCollection(GlyphCollection glyphs, string customGlyphs)
        {
            switch (glyphs)
            {
            case GlyphCollection.NEHE:
            case GlyphCollection.Ascii:
                this.customGlyphs.Clear();
                break;

            default:
                this.customGlyphs.AddRange(customGlyphs.ToCharArray());
                break;
            }
            usedGlyphs = glyphs;
        }
Exemplo n.º 14
0
        public virtual void SetCurrentGlyphCollection (GlyphCollection glyphs, string customGlyphs)
        {

            switch (glyphs)
            {
                case GlyphCollection.NEHE:
                case GlyphCollection.Ascii:
                    this.customGlyphs.Clear();
                    break;
                default:
                    this.customGlyphs.AddRange(customGlyphs.ToCharArray());
                    break;

            }
            usedGlyphs = glyphs;
        }
Exemplo n.º 15
0
        static string GenerateFontName(string fontFileName, int size, GlyphCollection type, bool useDistanceField)
        {
            var tempName = new StringBuilder(fontFileName);

            tempName.Append("_");
            tempName.Append(type.ToString());
            tempName.Append("_");
            if (useDistanceField)
            {
                tempName.Append("_df");
            }
            tempName.Append("_");
            tempName.Append(size);

            return(tempName.ToString());
        }
        internal GlyphCollection GetGlyphs(ToolStrip parent, GlyphCollection glyphs, System.Windows.Forms.Design.Behavior.Behavior standardBehavior)
        {
            if (this.b == null)
            {
                this.b = (BehaviorService)parent.Site.GetService(typeof(BehaviorService));
            }
            Point     pos    = this.b.ControlToAdornerWindow(base.Parent);
            Rectangle bounds = this.Bounds;

            bounds.Offset(pos);
            bounds.Inflate(-2, -2);
            glyphs.Add(new MiniLockedBorderGlyph(bounds, SelectionBorderGlyphType.Top, standardBehavior, true));
            glyphs.Add(new MiniLockedBorderGlyph(bounds, SelectionBorderGlyphType.Bottom, standardBehavior, true));
            glyphs.Add(new MiniLockedBorderGlyph(bounds, SelectionBorderGlyphType.Left, standardBehavior, true));
            glyphs.Add(new MiniLockedBorderGlyph(bounds, SelectionBorderGlyphType.Right, standardBehavior, true));
            return(glyphs);
        }
Exemplo n.º 17
0
        FontGlyph GetGlyphInternal(GraphicsDevice graphicsDevice, GlyphCollection glyphs, int codepoint)
        {
            var glyph = GetGlyphWithoutBitmap(glyphs, codepoint);

            if (glyph == null)
            {
                return(null);
            }

            if (graphicsDevice == null || glyph.Atlas != null)
            {
                return(glyph);
            }

            var currentAtlas = CurrentAtlas;
            int gx = 0, gy = 0;
            var gw = glyph.Bounds.Width;
            var gh = glyph.Bounds.Height;

            if (!currentAtlas.AddRect(gw, gh, ref gx, ref gy))
            {
                CurrentAtlasFull?.Invoke(this, EventArgs.Empty);

                // This code will force creation of new atlas
                _currentAtlas = null;
                currentAtlas  = CurrentAtlas;

                // Try to add again
                if (!currentAtlas.AddRect(gw, gh, ref gx, ref gy))
                {
                    throw new Exception(string.Format("Could not add rect to the newly created atlas. gw={0}, gh={1}", gw, gh));
                }
            }

            glyph.Bounds.X = gx;
            glyph.Bounds.Y = gy;

            currentAtlas.RenderGlyph(graphicsDevice, glyph, BlurAmount, StrokeAmount);

            glyph.Atlas = currentAtlas;

            return(glyph);
        }
Exemplo n.º 18
0
        FontGlyph GetGlyphWithoutBitmap(GlyphCollection collection, int codepoint)
        {
            FontGlyph glyph = null;

            if (collection.Glyphs.TryGetValue(codepoint, out glyph))
            {
                return(glyph);
            }

            Font font;
            var  g = GetCodepointIndex(codepoint, out font);

            if (g == 0)
            {
                collection.Glyphs[codepoint] = null;
                return(null);
            }

            int advance, lsb, x0, y0, x1, y1;

            font.BuildGlyphBitmap(g, FontSize, font.Scale, &advance, &lsb, &x0, &y0, &x1, &y1);

            var pad    = Math.Max(FontGlyph.PadFromBlur(BlurAmount), FontGlyph.PadFromBlur(StrokeAmount));
            var gw     = x1 - x0 + pad * 2;
            var gh     = y1 - y0 + pad * 2;
            var offset = FontGlyph.PadFromBlur(BlurAmount);

            glyph = new FontGlyph {
                Font      = font,
                Codepoint = codepoint,
                Size      = FontSize,
                Index     = g,
                Bounds    = new Rectangle(0, 0, gw, gh),
                XAdvance  = (int)(font.Scale * advance * 10.0f),
                XOffset   = x0 - offset,
                YOffset   = y0 - offset
            };

            collection.Glyphs[codepoint] = glyph;

            return(glyph);
        }
Exemplo n.º 19
0
        private void PreDraw(StringBuilder str, out GlyphCollection glyphs, out float ascent, out float lineHeight)
        {
            glyphs = GetGlyphsCollection(FontSize);

            // Determine ascent and lineHeight from first character
            ascent     = 0;
            lineHeight = 0;
            for (int i = 0; i < str.Length; i += StringBuilderIsSurrogatePair(str, i) ? 2 : 1)
            {
                var codepoint = StringBuilderConvertToUtf32(str, i);

                var glyph = GetGlyph(null, glyphs, codepoint);
                if (glyph == null)
                {
                    continue;
                }

                ascent     = glyph.Font.Ascent;
                lineHeight = glyph.Font.LineHeight + LineSpacing;
                break;
            }
        }
        private void AddSelectionGlyphs(SelectionManager selMgr, ISelectionService selectionService)
        {
            ICollection     selectedComponents = selectionService.GetSelectedComponents();
            GlyphCollection glyphs             = new GlyphCollection();

            foreach (object obj2 in selectedComponents)
            {
                ToolStripItem component = obj2 as ToolStripItem;
                if (component != null)
                {
                    ToolStripItemDesigner designer = (ToolStripItemDesigner)this.host.GetDesigner(component);
                    if (designer != null)
                    {
                        designer.GetGlyphs(ref glyphs, new ResizeBehavior(component.Site));
                    }
                }
            }
            if (glyphs.Count > 0)
            {
                selMgr.SelectionGlyphAdorner.Glyphs.AddRange(glyphs);
            }
        }
Exemplo n.º 21
0
        public override GlyphCollection GetGlyphs(GlyphSelectionType selectionType)
        {
            GlyphCollection glyphs = base.GetGlyphs(selectionType);

            if (spc.Orientation == Orientation.Horizontal)
            {
                Point                location             = base.BehaviorService.MapAdornerWindowPoint(this.spc.Handle, this.spc.DisplayRectangle.Location);
                Rectangle            clientAreaRectangle  = new Rectangle(location, this.spc.DisplayRectangle.Size);
                int                  thinkness            = 2;
                IOFormSplitContainer iOFormSplitContainer = spc as IOFormSplitContainer;

                if (!iOFormSplitContainer.IsReadOnly) // Show glyphs only when control is not readonly
                {
                    // add glyph to change width of the container
                    Behavior    widthResizeBehavior = new IOFormWidthResizeBehavior(spc as IOFormSplitContainer, base.Component.Site);
                    Rectangle   WEGlyphRect         = new Rectangle(clientAreaRectangle.Left + clientAreaRectangle.Width - thinkness / 2, clientAreaRectangle.Top, thinkness, clientAreaRectangle.Height);
                    ResizeGlyph WEGlyph             = new ResizeGlyph(WEGlyphRect, Cursors.SizeWE, widthResizeBehavior);
                    glyphs.Add(WEGlyph);
                }

                // Add the glyph to change the height of last form when it is visible
                if (spc.Panels.Count > 0 && spc.Panels.Last().Visible)
                {
                    PropertyDescriptor descriptor = TypeDescriptor.GetProperties(spc.Panels.Last().Controls[0])["Locked"];
                    bool isLocked = descriptor != null? (bool)descriptor.GetValue(spc.Panels.Last().Controls[0]) : false;

                    if (!isLocked) // Show glyphs when panel is not locked
                    {
                        SplitterResizeBehavior heightResizeBehavior = new SplitterResizeBehavior(iOFormSplitContainer, base.Component.Site, spc.Panels.Last());
                        Rectangle   NSGlyphRect = new Rectangle(clientAreaRectangle.Left, clientAreaRectangle.Bottom - thinkness, clientAreaRectangle.Width, thinkness);
                        ResizeGlyph NSGlyph     = new ResizeGlyph(NSGlyphRect, Cursors.SizeNS, heightResizeBehavior);
                        glyphs.Add(NSGlyph);
                    }
                }
            }

            return(glyphs);
        }
Exemplo n.º 22
0
        private static void CheckRasterFonts(string fontsDirectory = "./fonts", string rasterDirectory = "./cache/fonts")
        {
            DirectoryInfo cacheDir = new DirectoryInfo(rasterDirectory.Replace('/', Path.DirectorySeparatorChar));

            if (!cacheDir.Exists)
            {
                cacheDir.Create();
            }

            DirectoryInfo fontsDir = new DirectoryInfo(fontsDirectory.Replace('/', Path.DirectorySeparatorChar));

            if (!fontsDir.Exists)
            {
                fontsDir.Create();
                throw new FileNotFoundException(string.Format("The fonts directory doesnt exists ({0}). No font files installed on the application.", fontsDirectory));
            }

            FileInfo[] files     = fontsDir.GetFiles();
            long       fontCount = 0;

            if (files != null)
            {
                foreach (FileInfo font in files)
                {
                    if (string.Equals(font.Extension, ".otf", StringComparison.OrdinalIgnoreCase) || string.Equals(font.Extension, ".ttf", StringComparison.OrdinalIgnoreCase))
                    {
                        Log.WriteLine("Loading font file %@...", LogLevel.Message, font.Name);
                        FontLoader.LoadFromFile(font.FullName);
                        fontCount++;
                    }
                }
            }

            if (files == null || files.Length < 1 || fontCount < 1)
            {
                throw new FileNotFoundException(string.Format("No OTF font files found on the fonts directory ({0}). No font files installed on the application.", fontsDirectory));
            }

            Log.WriteLine("Loaded %@ fonts into the application.", LogLevel.Message, FontLoader.LoadedFonts.Length.ToString("N0"));

            GdiFontRasterizer rasterizer = new GdiFontRasterizer(true, true, true);

            foreach (FontFamily family in FontLoader.LoadedFonts)
            {
                FileInfo targetFile         = FontAtlas.GetAtlasFileFromName(cacheDir.FullName, family.Name);
                FileInfo targetFileMetadata = FontAtlas.GetAtlasMetadataFileFromName(cacheDir.FullName, family.Name);

                if (!targetFile.Exists)
                {
                    // Build font
                    Log.WriteLine("Font '%@' is missing from cache. Rasterizing it...", LogLevel.Message, family.Name);

                    rasterizer.SelectedFont = new Font(family, 18.0f);
                    GlyphCollection rasterizedFont = rasterizer.Raster();

                    if (rasterizedFont.Count < 1)
                    {
                        Log.WriteLine("Failed to process font file %@. No glyphs found inside the font file.", LogLevel.Error, family.Name);
                        continue;;
                    }

                    Atlas fontAtlas = AtlasBuilder.BuildAtlas(rasterizedFont, AtlasLayoutMode.Indexed);
                    fontAtlas.ToFile(targetFile.FullName, targetFileMetadata.FullName, ImageFormat.Bmp);
                }
            }
        }
	public void AddRange(GlyphCollection value) {}
	public GlyphCollection(GlyphCollection value) {}
Exemplo n.º 25
0
 public CCFont()
 {
     usedGlyphs   = GlyphCollection.Ascii;
     customGlyphs = new List <char>();
 }
Exemplo n.º 26
0
        private bool CheckDropDownBounds(ToolStripDropDownItem dropDownItem, Glyph childGlyph, GlyphCollection glyphs)
        {
            if (dropDownItem == null)
            {
                return(false);
            }
            Rectangle bounds = childGlyph.Bounds;
            Rectangle rect   = base.BehaviorService.ControlRectInAdornerWindow(dropDownItem.DropDown);

            if (!bounds.IntersectsWith(rect))
            {
                glyphs.Insert(0, childGlyph);
            }
            return(true);
        }
Exemplo n.º 27
0
 public void AddRange(GlyphCollection value)
 {
 }
Exemplo n.º 28
0
 public GlyphCollection(GlyphCollection value)
 {
 }
Exemplo n.º 29
0
 public CCFont()
 {     
     usedGlyphs = GlyphCollection.Ascii;
     customGlyphs = new List<char>();
 }