public RendererHelperTests()
        {
            var label = new Label();
            var text  = Guid.NewGuid().ToString();

            _helper = new RendererHelper(label, text, "iOS", false);
        }
示例#2
0
        private void ProcessText()
        {
            if (Control == null || Element == null)
            {
                return;
            }

            // Gets the complete HTML string
            var isRtl      = Device.FlowDirection == Xamarin.Forms.FlowDirection.RightToLeft;
            var styledHtml = new RendererHelper(Element, Element.Text, Device.RuntimePlatform, isRtl).ToString();

            if (styledHtml == null)
            {
                return;
            }

            Control.Text = styledHtml;

            // Adds the HtmlTextBehavior because UWP's TextBlock
            // does not natively support HTML content
            var behavior = new HtmlTextBehavior((HtmlLabel)Element);
            BehaviorCollection behaviors = Interaction.GetBehaviors(Control);

            behaviors.Clear();
            behaviors.Add(behavior);
        }
示例#3
0
        /// <summary>
        /// Method to perform actual rendering
        /// </summary>
        /// <param name="map">The map</param>
        /// <param name="polygon">The polygon to render</param>
        /// <param name="g">The graphics object to use</param>
        protected override void OnRenderInternal(Map map, IPolygon polygon, IGraphics g)
        {
            // convert points
            var pts = /*LimitValues(*/ polygon.TransformToImage(map) /*)*/;

            // clip
            if (UseClipping)
            {
                pts = RendererHelper.ClipPolygon(pts, map.Size.Width, map.Size.Height);
            }

            // fill the polygon
            if (Fill != null)
            {
                g.FillPolygon(Fill, pts);
            }

            // outline the polygon
            if (Outline != null)
            {
                Outline.Render(map, polygon.ExteriorRing, g);
                foreach (var ls in polygon.InteriorRings)
                {
                    Outline.Render(map, ls, g);
                }
            }
        }
示例#4
0
        protected override void ProcessText()
        {
            if (string.IsNullOrWhiteSpace(Element?.Text))
            {
                Control.Text = string.Empty;
                return;
            }

            Control.Font = FontExtensions.ToUIFont(Element);
            if (!Element.TextColor.IsDefault)
            {
                Control.TextColor = Element.TextColor.ToUIColor();
            }

            var linkColor = Element.LinkColor;

            if (!linkColor.IsDefault)
            {
                Control.TintColor = linkColor.ToUIColor();
            }
            var isRtl      = Device.FlowDirection == FlowDirection.RightToLeft;
            var styledHtml = new RendererHelper(Element, Element.Text, Device.RuntimePlatform, isRtl).ToString();

            SetText(styledHtml);
            SetNeedsDisplay();
        }
示例#5
0
        private void ProcessText()
        {
            if (Control == null || Element == null)
            {
                return;
            }

            Xamarin.Forms.Color linkColor = ((HtmlLabel)Element).LinkColor;
            if (!linkColor.IsDefault)
            {
                Control.SetLinkTextColor(linkColor.ToAndroid());
            }

            Control.SetIncludeFontPadding(false);
            var isRtl      = Device.FlowDirection == FlowDirection.RightToLeft;
            var styledHtml = new RendererHelper(Element, Control.Text, Device.RuntimePlatform, isRtl).ToString();

            /*
             * Android's TextView doesn't support lists.
             * List tags must be replaces with custom tags,
             * that it will be renderer by a custom tag handler.
             */
            styledHtml = styledHtml
                         ?.ReplaceTag(_tagUlRegex, ListTagHandler.TagUl)
                         ?.ReplaceTag(_tagOlRegex, ListTagHandler.TagOl)
                         ?.ReplaceTag(_tagLiRegex, ListTagHandler.TagLi);

            if (styledHtml != null)
            {
                SetText(Control, styledHtml);
            }
        }
示例#6
0
 protected override bool NavigateToUrl(NSUrl url)
 {
     if (url == null)
     {
         throw new ArgumentNullException(nameof(url));
     }
     // Try to handle uri, if it can't be handled, fall back to IOS his own handler.
     return(!RendererHelper.HandleUriClick(Element, url.AbsoluteString));
 }
示例#7
0
        /// <summary>
        /// Initializes the graphics engine, the renderer, a plain shader program, vertex buffer and the viewport for a given handle.
        /// </summary>
        void InitializeSurface(IntPtr handle)
        {
            System.Diagnostics.Debug.WriteLine("Initialize Engine..");
            // initialize graphics and a renderer using a window handle
            graphics = Engine.initializeGraphics(RenderingAPI.OpenGL);
            renderer = graphics.CreateRenderer(handle);
            renderer.UseSRGBFramebuffer();

            // Create shader program by using shader sources
            ShaderSource[] sources =
            {
                new ShaderSource(ShaderType.VertexShader, Properties.Resources.VertexShader),
                new ShaderSource(ShaderType.PixelShader,  Properties.Resources.FragmentShader)
            };
            shaderProgram = RendererHelper.createShaderProgram(graphics, sources).Value;

            // create shader program manually by creating shaders
            using (IShader vertexShader = graphics.CreateShader(ShaderType.VertexShader, Properties.Resources.VertexShaderColored).Value,
                   pixelShader = graphics.CreateShader(ShaderType.PixelShader, Properties.Resources.FragmentShaderColoredUniform).Value)
            {
                shaderProgramColored = graphics.CreateShaderProgram(new IShader[] { vertexShader, pixelShader }).Value;
            }

            // create textured shader
            ShaderSource[] sourcesTexture =
            {
                new ShaderSource(ShaderType.VertexShader, Properties.Resources.VertexShaderTex),
                new ShaderSource(ShaderType.PixelShader,  Properties.Resources.FragmentShaderTex)
            };
            shaderProgramTextured = RendererHelper.createShaderProgram(graphics, sourcesTexture).Value;

            // Diffuse textures mostly srgb, normals mostly normal rgb
            // create texture
            var settings = new TextureSettings2D(TextureTargetFormat.SRGB8, TextureOriginalFormat.BGR, TextureWrapMode.MirroredRepeat,
                                                 TextureWrapMode.MirroredRepeat, TextureMinifyingFilter.Linear, TextureMagnifyingFilter.Linear, Maybe <Color <float> > .Nothing);

            brickTexture = graphics.CreateTexture2D(settings, @"Resources\BrickGroutless0095_2_XL.jpg").Value;
            mossTexture  = graphics.CreateTexture2D(settings, @"Resources\Moss0177_1_XL.jpg").Value;
            sampler1     = shaderProgramTextured.GetUniform <int>("tex");
            sampler2     = shaderProgramTextured.GetUniform <int>("tex2");

            // use uniform values for shaders
            multiplicator = shaderProgramColored.GetUniform <float>("multiplicator");
            uniformValue  = 0.0f;
            shaderProgramColored.SetUniform(multiplicator, uniformValue);

            CreateVertexBuffer1();

            CreateVertexBuffer2();

            CreateVertexBuffer3();

            renderer.ClearColor(new Color <float>(0.2f, 0.1f, 0.2f, 0.1f));
            renderer.Viewport(new Vec2 <short>(0, 0), new Size <short>((short)Width, (short)Height));
        }
        public GridViewCellContainer(Context context, FastGridCell fastGridCell, global::Android.Views.View parent, Size initialCellSize) : base(context)
        {
            using (var h = new Handler(Looper.MainLooper)) {
                h.Post(() => {
                    _viewCell = fastGridCell;
                    fastGridCell.PrepareCell(initialCellSize);
//					_viewCell.View.BackgroundColor = Xamarin.Forms.Color.Green;
                    var renderer = RendererHelper.GetOrCreateRenderer(fastGridCell.View);
                    _nativeView  = renderer.ViewGroup;
//					SetBackgroundColor (Android.Graphics.Color.Yellow);
                    AddView(_nativeView);
                });
            }
        }
        public static void HandleLinkTap(this UILabel control, HtmlLabel element)
        {
            void TapHandler(UITapGestureRecognizer tap)
            {
                var detectedUrl = DetectTappedUrl(tap, (UILabel)tap.View);

                RendererHelper.HandleUriClick(element, detectedUrl);
            }

            var tapGesture = new UITapGestureRecognizer(TapHandler);

            control.AddGestureRecognizer(tapGesture);
            control.UserInteractionEnabled = true;
        }
示例#10
0
 /// <inheritdoc />
 protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnElementPropertyChanged(sender, e);
     if (e != null && RendererHelper.RequireProcess(e.PropertyName))
     {
         try
         {
             ProcessText();
         }
         catch (System.Exception ex)
         {
             System.Diagnostics.Debug.WriteLine(@"            ERROR: ", ex.Message);
         }
     }
 }
示例#11
0
        void CreateVertexBuffer3()
        {
            var vertexAttribute = RendererHelper.attributeVertexPositionColor <float, float>();

            VertexPositionColor <float, float>[] vertices =
            {
                new VertexPositionColor <float, float>(new Vec3 <float>(0.0f,  -0.5f, 0.0f), new Color <float>(1.0f, 0.0f, 0.0f, 1.0f)),
                new VertexPositionColor <float, float>(new Vec3 <float>(-0.5f,  0.5f, 0.0f), new Color <float>(0.0f, 1.0f, 0.0f, 1.0f)),
                new VertexPositionColor <float, float>(new Vec3 <float>(0.0f,   0.5f, 0.0f), new Color <float>(0.0f, 0.0f, 1.0f, 1.0f))
            };

            int[] indices =
            {
                0, 1, 2
            };

            vb3 = graphics.CreateVertexBufferIndexed(vertices, indices, BufferUsage.StaticDraw, vertexAttribute.Value);
        }
示例#12
0
        /// <summary>
        /// Creates a indexed vertex buffer by using a vec3 array
        /// </summary>
        void CreateVertexBuffer2()
        {
            // Either create the attribute manually or use the built-in function
            //var vertexAttribute = new VertexAttribute(3, DataType.Single, 3 * sizeof(float), 0);
            var vertexAttribute = RendererHelper.attributeVertexPositionTexture <float, float>();

            /// When you have only positions you can either use the pos array directly or use the vertices array
            Vec3 <float>[] pos =
            {
                new Vec3 <float>(0.0f, -0.5f, 0.0f),
                new Vec3 <float>(0.5f, -0.5f, 0.0f),
                new Vec3 <float>(0.5f,  0.5f, 0.0f),
                new Vec3 <float>(0.0f,  0.5f, 0.0f)
            };

            Vec2 <float>[] tex =
            {
                new Vec2 <float>(0.0f, 1.0f),
                new Vec2 <float>(1.0f, 1.0f),
                new Vec2 <float>(1.0f, 0.0f),
                new Vec2 <float>(0.0f, 0.0f)
            };

            VertexPosTex <float, float>[] vertices =
            {
                new VertexPosTex <float, float>(pos[0], tex[0]),
                new VertexPosTex <float, float>(pos[1], tex[1]),
                new VertexPosTex <float, float>(pos[2], tex[2]),
                new VertexPosTex <float, float>(pos[3], tex[3])
            };

            uint[] indices =
            {
                0, 1, 2,
                0, 2, 3
            };

            // create vertex buffer object with vertex data, an attribute and indices
            vb2 = graphics.CreateVertexBufferIndexed(vertices, indices, BufferUsage.StaticDraw, vertexAttribute.Value);
        }
示例#13
0
        private void ProcessText()
        {
            if (Control == null || Element == null)
            {
                return;
            }

            Color linkColor = ((HtmlLabel)Element).LinkColor;

            if (!linkColor.IsDefault)
            {
                Control.TintColor = linkColor.ToUIColor();
            }

            var isRtl      = Device.FlowDirection == FlowDirection.RightToLeft;
            var styledHtml = new RendererHelper(Element, Control.Text, Device.RuntimePlatform, isRtl).ToString();

            if (styledHtml != null)
            {
                SetText(Control, styledHtml);
                SetNeedsDisplay();
            }
        }
示例#14
0
        /// <summary>
        /// Method that does the actual rendering of individual features.
        /// </summary>
        /// <param name="map">The map</param>
        /// <param name="lineString">The linestring</param>
        /// <param name="graphics">The graphics object</param>
        protected override void OnRenderInternal(Map map, ILineString lineString, IGraphics graphics)
        {
            var pts = /*LimitValues(*/ RendererHelper.OffsetRight(lineString.TransformToImage(map), Offset) /*)*/;

            graphics.DrawLines(Line, pts);
        }
        private void InitializeCommands()
        {
            GenerateCardsCommand = new RelayCommand <GameInfo>((x) =>
            {
                if (x == null || AmountOfCards == null || AmountOfQuestionsPerCard == null)
                {
                    DialogManager.ShowDialog(new AlertDialog()
                    {
                        AlertLevel = AlertLevel.Error,
                        Title      = Properties.Resources.GENERIC_Error,
                        Message    = Properties.Resources.GENERIC_FillNecessaryFields
                    });

                    return;
                }

                BingoGame game;

                try
                {
                    game = BingoGame.LoadGame(x.Language, x.Subject, x.Topic);
                }
                catch (Exception e)
                {
                    DialogManager.ShowDialog(new AlertDialog()
                    {
                        AlertLevel = AlertLevel.Error,
                        Title      = Properties.Resources.GENERIC_Error,
                        Message    = Properties.Resources.GENERATE_CARDS_ErrorLoadingGame,
                        Exception  = e,
                        ShowCopyToClipboardButton = true,
                    });

                    return;
                }

                AutoResetEvent autoReset      = new AutoResetEvent(false);
                IEnumerable <BingoCard> cards = null;

                SaveFileDialog saveDialog = new SaveFileDialog()
                {
                    Filter = "PDF (*.pdf)|*.pdf",
                };

                PdfDocument pdf = new PdfDocument();
                pdf.Info.Author = "VirtualBingo";
                pdf.Info.Title  = game.Topic;

                Thread thread = new Thread(() =>
                {
                    cards = game.DistributeQuestions(AmountOfCards.Value, AmountOfQuestionsPerCard.Value);

                    string tempImagePath = Path.GetTempFileName();

                    foreach (var card in cards)
                    {
                        PdfPage page = pdf.AddPage();

                        page.Orientation = PdfSharp.PageOrientation.Landscape;
                        page.Size        = PdfSharp.PageSize.A4;

                        CardDisplayer displayer = new CardDisplayer()
                        {
                            Card = card
                        };

                        RendererHelper.SaveImageOfRender(RendererHelper.Render(displayer, new Size(842, 595)), tempImagePath);

                        using (FileStream stream = File.Open(tempImagePath, FileMode.Open, FileAccess.Read, FileShare.Delete))
                        {
                            using (XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsUnit.Millimeter))
                            {
                                using (XImage xImage = XImage.FromStream(stream))
                                {
                                    gfx.DrawImage(xImage, 15, 15, 267, 180);
                                }
                            }
                        }
                    }
                });

                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();

                if (saveDialog.ShowDialog() == true)
                {
                    thread.Join();

                    pdf.Save(saveDialog.FileName);

                    DialogManager.ShowDialog(new AlertDialog()
                    {
                        Title   = Properties.Resources.GENERIC_Success,
                        Message = Properties.Resources.GENERATE_CARDS_SuccessGenerating
                    });
                }
            });
        }
示例#16
0
        /// <summary>
        ///     Draws the panelspecific data.
        /// </summary>
        /// <param name="g"></param>
        protected override void Draw(BufferedGraphics g)
        {
            try
            {
                if (!GInformation.Gameinfo.IsIngame)
                {
                    return;
                }

                var iValidPlayerCount = GInformation.Gameinfo.ValidPlayerCount;

                if (iValidPlayerCount == 0)
                {
                    return;
                }

                Opacity = PSettings.PreferenceAll.OverlayResources.Opacity;
                var iSingleHeight = Height / iValidPlayerCount;
                var fNewFontSize  = (float)((29.0 / 100) * iSingleHeight);
                var fInternalFont = new Font(PSettings.PreferenceAll.OverlayResources.FontName, fNewFontSize,
                                             FontStyle.Bold);
                var fInternalFontNormal = new Font(fInternalFont.Name, fNewFontSize, FontStyle.Regular);

                if (!BChangingPosition)
                {
                    Height = PSettings.PreferenceAll.OverlayResources.Height * iValidPlayerCount;
                    Width  = PSettings.PreferenceAll.OverlayResources.Width;
                }

                var iCounter = 0;


                for (var i = 0; i < GInformation.Player.Count; i++)
                {
                    var clPlayercolor = GInformation.Player[i].Color;

                    #region Teamcolor

                    RendererHelper.TeamColor(GInformation.Player, i,
                                             GInformation.Gameinfo.IsTeamcolor, ref clPlayercolor);

                    #endregion

                    #region Escape sequences

                    if (PSettings.PreferenceAll.OverlayResources.RemoveAi)
                    {
                        if (GInformation.Player[i].Type.Equals(PlayerType.Ai))
                        {
                            continue;
                        }
                    }

                    if (PSettings.PreferenceAll.OverlayResources.RemoveNeutral)
                    {
                        if (GInformation.Player[i].Type.Equals(PlayerType.Neutral))
                        {
                            continue;
                        }
                    }

                    if (PSettings.PreferenceAll.OverlayResources.RemoveAllie)
                    {
                        if (Player.LocalPlayer.Index == 16)
                        {
                            //Do nothing
                        }

                        else
                        {
                            if (GInformation.Player[i].Team ==
                                Player.LocalPlayer.Team &&
                                GInformation.Player[i].Index != Player.LocalPlayer.Index)
                            {
                                continue;
                            }
                        }
                    }

                    if (PSettings.PreferenceAll.OverlayResources.RemoveLocalplayer)
                    {
                        if (Player.LocalPlayer == GInformation.Player[i])
                        {
                            continue;
                        }
                    }


                    if (GInformation.Player[i].Name.StartsWith("\0") || GInformation.Player[i].NameLength <= 0)
                    {
                        continue;
                    }

                    if (GInformation.Player[i].Type.Equals(PlayerType.Hostile))
                    {
                        continue;
                    }

                    if (GInformation.Player[i].Type.Equals(PlayerType.Observer))
                    {
                        continue;
                    }

                    if (GInformation.Player[i].Type.Equals(PlayerType.Referee))
                    {
                        continue;
                    }

                    if (CheckIfGameheart(GInformation.Player[i]))
                    {
                        continue;
                    }

                    #endregion

                    #region SetValidImages (Race)

                    if (GInformation.Player[i].PlayerRace.Equals(PlayerRace.Terran))
                    {
                        _imgMinerals = Resources.Mineral_Terran;
                        _imgGas      = Resources.Gas_Terran;
                        _imgSupply   = Resources.Supply_Terran;
                        _imgWorker   = Resources.T_SCV;
                    }

                    else if (GInformation.Player[i].PlayerRace.Equals(PlayerRace.Protoss))
                    {
                        _imgMinerals = Resources.Mineral_Protoss;
                        _imgGas      = Resources.Gas_Protoss;
                        _imgSupply   = Resources.Supply_Protoss;
                        _imgWorker   = Resources.P_Probe;
                    }

                    else
                    {
                        _imgMinerals = Resources.Mineral_Zerg;
                        _imgGas      = Resources.Gas_Zerg;
                        _imgSupply   = Resources.Supply_Zerg;
                        _imgWorker   = Resources.Z_Drone;
                    }

                    #endregion

                    #region Draw Bounds and Background

                    if (PSettings.PreferenceAll.OverlayResources.DrawBackground)
                    {
                        /* Background */
                        g.Graphics.FillRectangle(Brushes.Gray, 1, 1 + (iSingleHeight * iCounter), Width - 2,
                                                 iSingleHeight - 2);

                        /* Border */
                        g.Graphics.DrawRectangle(new Pen(new SolidBrush(clPlayercolor), 2), 1,
                                                 1 + (iSingleHeight * iCounter),
                                                 Width - 2, iSingleHeight - 2);
                    }

                    #endregion

                    #region Content Drawing

                    #region Name

                    var strName = (GInformation.Player[i].ClanTag.StartsWith("\0") ||
                                   PSettings.PreferenceAll.OverlayResources.RemoveClanTag)
                        ? GInformation.Player[i].Name
                        : "[" + GInformation.Player[i].ClanTag + "] " + GInformation.Player[i].Name;

                    g.Graphics.DrawString(strName, fInternalFont,
                                          new SolidBrush(clPlayercolor),
                                          Brushes.Black, (float)((1.67 / 100) * Width),
                                          (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                                          1f, 1f, true);

                    #endregion

                    #region Team

                    g.Graphics.DrawString("#" + GInformation.Player[i].Team, fInternalFontNormal,
                                          Brushes.White,
                                          Brushes.Black, (float)((29.67 / 100) * Width),
                                          (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                                          1f, 1f, true);

                    #endregion

                    #region Minerals

                    /* Icon */
                    g.Graphics.DrawImage(_imgMinerals, (float)((37.0 / 100) * Width),
                                         (float)((14.0 / 100) * iSingleHeight) + (Height / iValidPlayerCount) * iCounter,
                                         (float)((70.0 / 100) * iSingleHeight), (float)((70.0 / 100) * iSingleHeight), Brushes.Black, 1f, 1f,
                                         false);

                    g.Graphics.DrawString(
                        GInformation.Player[i].Minerals.ToString(CultureInfo.InvariantCulture),
                        fInternalFontNormal,
                        Brushes.White,
                        Brushes.Black, (float)((43.67 / 100) * Width),
                        (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                        1f, 1f, true);

                    #endregion

                    #region Gas

                    /* Icon */
                    g.Graphics.DrawImage(_imgGas, (float)((57.0 / 100) * Width),
                                         (float)((14.0 / 100) * iSingleHeight) + (Height / iValidPlayerCount) * iCounter,
                                         (float)((70.0 / 100) * iSingleHeight), (float)((70.0 / 100) * iSingleHeight), Brushes.Black, 1f, 1f,
                                         false);

                    g.Graphics.DrawString(
                        GInformation.Player[i].Gas.ToString(CultureInfo.InvariantCulture),
                        fInternalFontNormal,
                        Brushes.White,
                        Brushes.Black, (float)((63.67 / 100) * Width),
                        (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                        1f, 1f, true);

                    #endregion

                    #region Supply

                    /* Icon */
                    g.Graphics.DrawImage(_imgSupply, (float)((75.0 / 100) * Width),
                                         (float)((14.0 / 100) * iSingleHeight) + (Height / iValidPlayerCount) * iCounter,
                                         (float)((70.0 / 100) * iSingleHeight), (float)((70.0 / 100) * iSingleHeight), Brushes.Black, 1f, 1f,
                                         false);

                    g.Graphics.DrawString(
                        GInformation.Player[i].SupplyMin.ToString(CultureInfo.InvariantCulture) + "/" +
                        GInformation.Player[i].SupplyMax,
                        fInternalFontNormal,
                        Brushes.White,
                        Brushes.Black, (float)((81.67 / 100) * Width),
                        (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                        1f, 1f, true);

                    #endregion

                    #endregion

                    iCounter++;
                }
            }

            catch (Exception ex)
            {
                Messages.LogFile("Over all", ex);
            }
        }
示例#17
0
 public override void OnClick(Android.Views.View widget)
 {
     RendererHelper.HandleUriClick(_label, _span.URL);
 }
示例#18
0
        private BaseLabel CreateLabel(IFeature fdr, IGeometry feature, string text, float rotation, int priority, LabelStyle style, Map map, IGraphics g, GetLocationMethod _getLocationMethod)
        {
            if (feature == null)
            {
                return(null);
            }

            BaseLabel lbl = null;

            SizeF size = RendererHelper.SizeOfString(g, text, style.Font);

            if (feature is ILineal)
            {
                var line = feature as ILineString;
                if (line != null)
                {
                    if (style.IsTextOnPath == false)
                    {
                        if (size.Width < 0.95 * line.Length / map.PixelWidth || style.IgnoreLength)
                        {
                            var positiveLineString = PositiveLineString(line, false);
                            var lineStringPath     = LineStringToPath(positiveLineString, map /*, false*/);
                            var rect = lineStringPath.GetBounds();

                            if (style.CollisionDetection && !style.CollisionBuffer.IsEmpty)
                            {
                                var cbx = style.CollisionBuffer.Width;
                                var cby = style.CollisionBuffer.Height;
                                rect.Inflate(2 * cbx, 2 * cby);
                                rect.Offset(-cbx, -cby);
                            }
                            var labelBox = new LabelBox(rect);

                            lbl = new PathLabel(text, lineStringPath, 0, priority, labelBox, style);
                        }
                    }
                    else
                    {
                        //get centriod
                        PointF position2 = map.WorldToImage(feature.EnvelopeInternal.Centre);
                        lbl = new Label(text, position2, rotation, priority, style);
                        if (size.Width < 0.95 * line.Length / map.PixelWidth || !style.IgnoreLength)
                        {
                            CalculateLabelAroundOnLineString(line, ref lbl, map, g, size);
                        }
                    }
                }
                return(lbl);
            }

            var worldPosition = _getLocationMethod == null
                ? feature.EnvelopeInternal.Centre
                : _getLocationMethod(fdr);

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

            var position = Transform.WorldtoMap(worldPosition, map);

            var location = new PointF(
                position.X - size.Width * (short)style.HorizontalAlignment * 0.5f,
                position.Y - size.Height * (short)(2 - (int)style.VerticalAlignment) * 0.5f);

            if (location.X - size.Width > map.Size.Width || location.X + size.Width < 0 ||
                location.Y - size.Height > map.Size.Height || location.Y + size.Height < 0)
            {
                return(null);
            }

            if (!style.CollisionDetection)
            {
                lbl = new Label(text, location, rotation, priority, null, style)
                {
                    LabelPoint = position
                }
            }
            ;
            else
            {
                //Collision detection is enabled so we need to measure the size of the string
                lbl = new Label(text, location, rotation, priority,
                                new LabelBox(location.X - size.Width * 0.5f - style.CollisionBuffer.Width,
                                             location.Y + size.Height * 0.5f + style.CollisionBuffer.Height,
                                             size.Width + 2f * style.CollisionBuffer.Width,
                                             size.Height + style.CollisionBuffer.Height * 2f), style)
                {
                    LabelPoint = position
                };
            }

            /*
             * if (feature is LineString)
             * {
             *  var line = feature as LineString;
             *
             *  //Only label feature if it is long enough, or it is definately wanted
             *  if (line.Length / map.PixelSize > size.Width || style.IgnoreLength)
             *  {
             *      CalculateLabelOnLinestring(line, ref lbl, map);
             *  }
             *  else
             *      return null;
             * }
             */
            return(lbl);
        }
示例#19
0
        /// <summary>
        ///     Draws the panelspecific data.
        /// </summary>
        /// <param name="g"></param>
        protected override void Draw(BufferedGraphics g)
        {
            try
            {
                if (GInformation.Unit == null ||
                    GInformation.Unit.Count <= 0)
                {
                    return;
                }

                if (GInformation.Player == null)
                {
                    return;
                }

                if (!GInformation.Gameinfo.IsIngame)
                {
                    g.Graphics.Clear(Color.White);
                    g.Graphics.Clear(BackColor);
                    return;
                }

                Opacity = PSettings.PreferenceAll.OverlayMaphack.Opacity;

                if (!BChangingPosition)
                {
                    Height = PSettings.PreferenceAll.OverlayMaphack.Height;
                    Width  = PSettings.PreferenceAll.OverlayMaphack.Width;
                }

                var tmpMap = GInformation.Map;

                #region Introduction

                #region Variables

                float fScale;
                float fX;
                float fY;
                float fHypotenuse;

                #endregion

                #region Get minimap Bounds

                var fa = Height / (float)Width;
                var fb = ((float)tmpMap.PlayableHeight / tmpMap.PlayableWidth);

                if (fa >= fb)
                {
                    fScale = (float)Width / tmpMap.PlayableWidth;
                    fX     = 0;
                    fY     = (Height - fScale * tmpMap.PlayableHeight) / 2;
                }
                else
                {
                    fScale = (float)Height / tmpMap.PlayableHeight;
                    fY     = 0;
                    fX     = (Width - fScale * tmpMap.PlayableWidth) / 2;
                }

                #endregion

                #region Calculate Hypotenuse

                fHypotenuse = (float)Math.Sqrt((Math.Pow(ClientSize.Width, 2) + Math.Pow(ClientSize.Height, 2)));

                #endregion

                #region Draw Bounds

                if (!PSettings.PreferenceAll.OverlayMaphack.RemoveVisionArea)
                {
                    /* Draw Rectangle */
                    g.Graphics.DrawRectangle(Constants.PBound, 0, 0, Width - Constants.PBound.Width,
                                             Height - Constants.PBound.Width);

                    /* Draw Playable Area */
                    g.Graphics.DrawRectangle(Constants.PArea, fX, fY, Width - fX * 2 - Constants.PArea.Width,
                                             Height - fY * 2 - Constants.PArea.Width);
                }

                #endregion

                #endregion

                #region Actual Drawing

                #region Draw Unit- destination

                if (!PSettings.PreferenceAll.OverlayMaphack.RemoveDestinationLine)
                {
                    for (var i = 0; i < GInformation.Unit.Count; i++)
                    {
                        var clDestination = PSettings.PreferenceAll.OverlayMaphack.DestinationLine;

                        var tmpUnit = GInformation.Unit[i];

                        #region Escape Sequences

                        /* Ai */
                        if (PSettings.PreferenceAll.OverlayMaphack.RemoveAi)
                        {
                            if (
                                GInformation.Player[tmpUnit.Owner].Type.Equals(
                                    PlayerType.Ai))
                            {
                                continue;
                            }
                        }

                        /* Allie */
                        if (PSettings.PreferenceAll.OverlayMaphack.RemoveAllie)
                        {
                            if (Player.LocalPlayer != null)
                            {
                                if (GInformation.Player[tmpUnit.Owner].Team ==
                                    Player.LocalPlayer.Team &&
                                    GInformation.Player[tmpUnit.Owner] != Player.LocalPlayer)
                                {
                                    continue;
                                }
                            }
                        }

                        /* Localplayer Units */
                        if (PSettings.PreferenceAll.OverlayMaphack.RemoveLocalplayer)
                        {
                            if (tmpUnit.Owner == Player.LocalPlayer.Index)
                            {
                                continue;
                            }
                        }

                        /* Neutral Units */
                        if (PSettings.PreferenceAll.OverlayMaphack.RemoveNeutral)
                        {
                            if (
                                GInformation.Player[tmpUnit.Owner].Type.Equals(
                                    PlayerType.Neutral))
                            {
                                continue;
                            }
                        }

                        /* Dead Units */
                        if ((tmpUnit.TargetFilter & (ulong)TargetFilterFlag.Dead) > 0)
                        {
                            continue;
                        }


                        /* Moving- state */
                        if (tmpUnit.Movestate.Equals(0))
                        {
                            continue;
                        }

                        #endregion

                        #region Scalling (Unitposition + UnitDestination)

                        var iUnitPosX = (tmpUnit.PositionX - tmpMap.Left) * fScale + fX;
                        var iUnitPosY = (tmpMap.Top - tmpUnit.PositionY) * fScale + fY;

                        var iUnitDestPosX = (tmpUnit.DestinationPositionX - tmpMap.Left) * fScale +
                                            fX;
                        var iUnitDestPosY = (tmpMap.Top - tmpUnit.DestinationPositionY) * fScale +
                                            fY;

                        if (float.IsNaN(iUnitPosX) ||
                            float.IsNaN(iUnitPosY) ||
                            float.IsNaN(iUnitDestPosX) ||
                            float.IsNaN(iUnitDestPosY))
                        {
                            continue;
                        }

                        #endregion

                        g.Graphics.CompositingQuality = CompositingQuality.HighQuality;
                        g.Graphics.PixelOffsetMode    = PixelOffsetMode.HighQuality;
                        g.Graphics.SmoothingMode      = SmoothingMode.HighQuality;

                        /* Draws the Line */
                        if (tmpUnit.DestinationPositionX > 10 &&
                            tmpUnit.DestinationPositionY > 10)
                        {
                            g.Graphics.DrawLine(new Pen(new SolidBrush(clDestination)), iUnitPosX, iUnitPosY,
                                                iUnitDestPosX,
                                                iUnitDestPosY);
                        }

                        g.Graphics.CompositingQuality = CompositingQuality.HighSpeed;
                        g.Graphics.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
                        g.Graphics.SmoothingMode      = SmoothingMode.HighSpeed;
                    }
                }

                #endregion

                #region Draw Creeptumors

                for (var i = 0; i < GInformation.Unit.Count; i++)
                {
                    var tmpUnit = GInformation.Unit[i];

                    #region Exceptions

                    /* Ai */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveAi)
                    {
                        if (GInformation.Player[tmpUnit.Owner].Type.Equals(PlayerType.Ai))
                        {
                            continue; //clUnitBoundBorder = Color.Transparent;
                        }
                    }

                    /* Allie */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveAllie)
                    {
                        if (Player.LocalPlayer != null)
                        {
                            if (GInformation.Player[tmpUnit.Owner].Team ==
                                Player.LocalPlayer.Team &&
                                GInformation.Player[tmpUnit.Owner] != Player.LocalPlayer)
                            {
                                continue; //clUnitBoundBorder = Color.Transparent;
                            }
                        }
                    }

                    /* Localplayer Units */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveLocalplayer)
                    {
                        if (tmpUnit.Owner == Player.LocalPlayer.Index)
                        {
                            continue; //clUnitBoundBorder = Color.Transparent;
                        }
                    }

                    /* Neutral Units */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveNeutral)
                    {
                        if (GInformation.Player[tmpUnit.Owner].Type.Equals(PlayerType.Neutral))
                        {
                            continue; //clUnitBoundBorder = Color.Transparent;
                        }
                    }

                    /* Dead Units */
                    if ((tmpUnit.TargetFilter & (ulong)TargetFilterFlag.Dead) > 0)
                    {
                        continue;
                    }

                    #endregion

                    #region Actual Drawing

                    if (tmpUnit.Id == UnitId.ZbCreeptumor ||
                        tmpUnit.Id == UnitId.ZbCreepTumorBuilding ||
                        tmpUnit.Id == UnitId.ZbCreepTumorMissle ||
                        tmpUnit.Id == UnitId.ZbCreeptumorBurrowed)
                    {
                        #region Scalling (Unitposition)

                        var iUnitPosX = (tmpUnit.PositionX - tmpMap.Left) * fScale + fX;
                        var iUnitPosY = (tmpMap.Top - tmpUnit.PositionY) * fScale + fY;

                        if (float.IsNaN(iUnitPosX) ||
                            float.IsNaN(iUnitPosY))
                        {
                            continue;
                        }

                        #endregion

                        var fRadius          = 4f;
                        var fLocalHypotenuse = 32.25218f;   //Hypotenuse of size 8

                        var fLocalUnitScale = fHypotenuse / fLocalHypotenuse;
                        var fSize           = (float)Math.Sqrt((Math.Pow(fLocalUnitScale, 2) - Math.Pow((fRadius * 2), 2)));
                        fSize /= 2;

                        g.Graphics.DrawLine(Constants.PBlack2, iUnitPosX - fSize, iUnitPosY - fSize,
                                            iUnitPosX + fSize, iUnitPosY + fSize);
                        g.Graphics.DrawLine(Constants.PBlack2, iUnitPosX + fSize, iUnitPosY - fSize,
                                            iUnitPosX - fSize, iUnitPosY + fSize);
                    }

                    #endregion
                }

                #endregion

                #region Draw Unit (Border/ outer Rectangle)

                for (var i = 0; i < GInformation.Unit.Count; i++)
                {
                    var tmpUnit     = GInformation.Unit[i];
                    var clUnitBound = Color.Black;

                    if (tmpUnit.Owner >= (GInformation.Player.Count))
                    {
                        continue;
                    }

                    #region Escape Sequences

                    /* Ai */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveAi)
                    {
                        if (GInformation.Player[tmpUnit.Owner].Type.Equals(PlayerType.Ai))
                        {
                            continue;
                        }
                    }

                    /* Allie */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveAllie)
                    {
                        if (Player.LocalPlayer != null)
                        {
                            if (GInformation.Player[tmpUnit.Owner].Team ==
                                Player.LocalPlayer.Team &&
                                GInformation.Player[tmpUnit.Owner] != Player.LocalPlayer)
                            {
                                continue;
                            }
                        }
                    }

                    /* Localplayer Units */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveLocalplayer)
                    {
                        if (tmpUnit.Owner == Player.LocalPlayer.Index)
                        {
                            continue;
                        }
                    }

                    /* Neutral Units */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveNeutral)
                    {
                        if (GInformation.Player[tmpUnit.Owner].Type.Equals(PlayerType.Neutral))
                        {
                            continue;
                        }
                    }


                    /* Dead Units */
                    if ((tmpUnit.TargetFilter & (ulong)TargetFilterFlag.Dead) > 0)
                    {
                        continue;
                    }

                    /* Creep tumor */
                    if (tmpUnit.Id ==
                        UnitId.ZbCreeptumorBurrowed)
                    {
                        continue;
                    }

                    #endregion

                    #region Scalling (Unitposition)

                    var iUnitPosX = (tmpUnit.PositionX - tmpMap.Left) * fScale + fX;
                    var iUnitPosY = (tmpMap.Top - tmpUnit.PositionY) * fScale + fY;

                    if (float.IsNaN(iUnitPosX) ||
                        float.IsNaN(iUnitPosY))
                    {
                        continue;
                    }

                    #endregion

                    var fUnitSize        = tmpUnit.Size;
                    var size             = 2.0f;
                    var fLocalHypotenuse = 129.0087f;

                    if (fUnitSize >= 0.5)
                    {
                        size             = 3;
                        fLocalHypotenuse = 86.00581f;
                    }

                    if (fUnitSize >= 0.875)
                    {
                        size             = 4;
                        fLocalHypotenuse = 64.50436f;
                    }

                    if (fUnitSize >= 1.5)
                    {
                        size             = 6;
                        fLocalHypotenuse = 43.00291f;
                    }

                    if (fUnitSize >= 2.0)
                    {
                        size             = 8;
                        fLocalHypotenuse = 32.25218f;
                    }

                    if (fUnitSize >= 2.5)
                    {
                        size             = 10;
                        fLocalHypotenuse = 25.8017f;
                    }

                    var fLocalUnitScale = fHypotenuse / fLocalHypotenuse;
                    size = (float)Math.Sqrt((Math.Pow(fLocalUnitScale, 2) - Math.Pow(size, 2)));


                    size += 0.5f;

                    #region Actual drawing

                    g.Graphics.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
                    g.Graphics.SmoothingMode      = SmoothingMode.HighSpeed;
                    g.Graphics.CompositingQuality = CompositingQuality.HighSpeed;

                    if (tmpUnit.IsCloaked &&
                        tmpUnit.Id != UnitId.ZbCreeptumorBurrowed)
                    {
                        g.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Gray)), iUnitPosX - size / 2,
                                                 iUnitPosY - size / 2, size, size);

                        g.Graphics.DrawRectangle(new Pen(new SolidBrush(clUnitBound)), iUnitPosX - size / 2 - 0.5f,
                                                 iUnitPosY - size / 2 - 0.5f, size + 1, size + 1);
                    }

                    else
                    {
                        g.Graphics.DrawRectangle(new Pen(new SolidBrush(clUnitBound)), iUnitPosX - size / 2,
                                                 iUnitPosY - size / 2, size, size);
                    }

                    g.Graphics.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
                    g.Graphics.SmoothingMode      = SmoothingMode.HighSpeed;
                    g.Graphics.CompositingQuality = CompositingQuality.HighSpeed;

                    #endregion
                }

                #endregion

                #region Draw Unit (Inner Rectangle)

                for (var i = 0; i < GInformation.Unit.Count; i++)
                {
                    var tmpUnit = GInformation.Unit[i];
                    //Color clUnit = LUnit[i].Owner > LPlayer.Count ? Color.Transparent : LPlayer[LUnit[i].Owner].Color;

                    if (tmpUnit.Owner >= GInformation.Player.Count)
                    {
                        continue;
                    }


                    var clUnit = GInformation.Player[tmpUnit.Owner].Color;

                    #region Teamcolor

                    RendererHelper.TeamColor(GInformation.Player, GInformation.Unit, i,
                                             GInformation.Gameinfo.IsTeamcolor, ref clUnit);

                    #endregion

                    #region Scalling (Unitposition)

                    var iUnitPosX = (tmpUnit.PositionX - tmpMap.Left) * fScale + fX;
                    var iUnitPosY = (tmpMap.Top - tmpUnit.PositionY) * fScale + fY;


                    if (float.IsNaN(iUnitPosX) ||
                        float.IsNaN(iUnitPosY))
                    {
                        continue;
                    }

                    #endregion

                    #region Escape Sequences

                    /* Ai */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveAi)
                    {
                        if (GInformation.Player[tmpUnit.Owner].Type.Equals(PlayerType.Ai))
                        {
                            continue;
                        }
                    }

                    /* Allie */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveAllie)
                    {
                        if (Player.LocalPlayer != null)
                        {
                            if (GInformation.Player[tmpUnit.Owner].Team ==
                                Player.LocalPlayer.Team &&
                                GInformation.Player[tmpUnit.Owner] != Player.LocalPlayer)
                            {
                                continue;
                            }
                        }
                    }

                    /* Localplayer Units */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveLocalplayer)
                    {
                        if (tmpUnit.Owner == Player.LocalPlayer.Index)
                        {
                            continue;
                        }
                    }

                    /* Neutral Units */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveNeutral)
                    {
                        if (GInformation.Player[tmpUnit.Owner].Type.Equals(PlayerType.Neutral))
                        {
                            continue;
                        }
                    }


                    /* Dead Units */
                    if ((tmpUnit.TargetFilter & (ulong)TargetFilterFlag.Dead) > 0)
                    {
                        continue;
                    }

                    /* Creep tumor */
                    if (tmpUnit.Id ==
                        UnitId.ZbCreeptumorBurrowed)
                    {
                        continue;
                    }

                    #endregion

                    var fUnitSize        = tmpUnit.Size;
                    var size             = 2.0f;
                    var fLocalHypotenuse = 129.0087f;

                    if (fUnitSize >= 0.5)
                    {
                        size             = 3;
                        fLocalHypotenuse = 86.00581f;
                    }

                    if (fUnitSize >= 0.875)
                    {
                        size             = 4;
                        fLocalHypotenuse = 64.50436f;
                    }

                    if (fUnitSize >= 1.5)
                    {
                        size             = 6;
                        fLocalHypotenuse = 43.00291f;
                    }

                    if (fUnitSize >= 2.0)
                    {
                        size             = 8;
                        fLocalHypotenuse = 32.25218f;
                    }

                    if (fUnitSize >= 2.5)
                    {
                        size             = 10;
                        fLocalHypotenuse = 25.8017f;
                    }

                    var fLocalUnitScale = fHypotenuse / fLocalHypotenuse;
                    size = (float)Math.Sqrt((Math.Pow(fLocalUnitScale, 2) - Math.Pow(size, 2)));


                    size -= 0.5f;


                    g.Graphics.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
                    g.Graphics.SmoothingMode      = SmoothingMode.HighSpeed;
                    g.Graphics.CompositingQuality = CompositingQuality.HighSpeed;

                    /* Draw the Unit (Actual Unit) */
                    g.Graphics.FillRectangle(new SolidBrush(clUnit), iUnitPosX - size / 2, iUnitPosY - size / 2, size, size);

                    g.Graphics.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
                    g.Graphics.SmoothingMode      = SmoothingMode.HighSpeed;
                    g.Graphics.CompositingQuality = CompositingQuality.HighSpeed;
                }

                #endregion

                #region Draw Border of special Units

                for (var i = 0; i < GInformation.Unit.Count; i++)
                {
                    var tmpUnit           = GInformation.Unit[i];
                    var clUnitBoundBorder = Color.Black;

                    if (tmpUnit.Owner >= (GInformation.Player.Count))
                    {
                        continue;
                    }

                    #region Scalling (Unitposition)

                    var iUnitPosX = (tmpUnit.PositionX - tmpMap.Left) * fScale + fX;
                    var iUnitPosY = (tmpMap.Top - tmpUnit.PositionY) * fScale + fY;


                    if (float.IsNaN(iUnitPosX) ||
                        float.IsNaN(iUnitPosY))
                    {
                        continue;
                    }

                    var fUnitSize        = tmpUnit.Size;
                    var size             = 2.0f;
                    var fLocalHypotenuse = 129.0087f;

                    if (fUnitSize >= 0.5)
                    {
                        size             = 3;
                        fLocalHypotenuse = 86.00581f;
                    }

                    if (fUnitSize >= 0.875)
                    {
                        size             = 4;
                        fLocalHypotenuse = 64.50436f;
                    }

                    if (fUnitSize >= 1.5)
                    {
                        size             = 6;
                        fLocalHypotenuse = 43.00291f;
                    }

                    if (fUnitSize >= 2.0)
                    {
                        size             = 8;
                        fLocalHypotenuse = 32.25218f;
                    }

                    if (fUnitSize >= 2.5)
                    {
                        size             = 10;
                        fLocalHypotenuse = 25.8017f;
                    }

                    var fLocalUnitScale = fHypotenuse / fLocalHypotenuse;
                    size = (float)Math.Sqrt((Math.Pow(fLocalUnitScale, 2) - Math.Pow(size, 2)));


                    size += 0.5f;


                    #endregion

                    #region Escape Sequences

                    /* Ai */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveAi)
                    {
                        if (GInformation.Player[tmpUnit.Owner].Type.Equals(PlayerType.Ai))
                        {
                            continue; //clUnitBoundBorder = Color.Transparent;
                        }
                    }

                    /* Allie */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveAllie)
                    {
                        if (Player.LocalPlayer != null)
                        {
                            if (GInformation.Player[tmpUnit.Owner].Team ==
                                Player.LocalPlayer.Team &&
                                GInformation.Player[tmpUnit.Owner] != Player.LocalPlayer)
                            {
                                continue; //clUnitBoundBorder = Color.Transparent;
                            }
                        }
                    }

                    /* Localplayer Units */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveLocalplayer)
                    {
                        if (tmpUnit.Owner == Player.LocalPlayer.Index)
                        {
                            continue;
                        }
                    }

                    /* Neutral Units */
                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveNeutral)
                    {
                        if (GInformation.Player[tmpUnit.Owner].Type.Equals(PlayerType.Neutral))
                        {
                            continue; //clUnitBoundBorder = Color.Transparent;
                        }
                    }


                    /* Dead Units */
                    if ((tmpUnit.TargetFilter & (ulong)TargetFilterFlag.Dead) > 0)
                    {
                        continue;
                    }

                    #endregion

                    #region Border special Units

                    #region Self created Units

                    if (PSettings.PreferenceAll.OverlayMaphack.UnitIds != null ||
                        PSettings.PreferenceAll.OverlayMaphack.UnitColors != null)
                    {
                        for (var j = 0; j < PSettings.PreferenceAll.OverlayMaphack.UnitIds.Count; j++)
                        {
                            var tmpSettingsId = PSettings.PreferenceAll.OverlayMaphack.UnitIds[j];
                            var bExpression   = false;

                            if (tmpSettingsId == UnitId.ZuChangeling)
                            {
                                if (tmpUnit.Id == UnitId.ZuChangeling ||
                                    tmpUnit.Id == UnitId.ZuChangelingMarine ||
                                    tmpUnit.Id == UnitId.ZuChangelingMarineShield ||
                                    tmpUnit.Id == UnitId.ZuChangelingSpeedling ||
                                    tmpUnit.Id == UnitId.ZuChangelingZealot ||
                                    tmpUnit.Id == UnitId.ZuChangelingZergling)
                                {
                                    bExpression = true;
                                }
                            }

                            else
                            {
                                bExpression = tmpUnit.Id == PSettings.PreferenceAll.OverlayMaphack.UnitIds[j]
                                    ? true
                                    : false;
                            }

                            if (bExpression)
                            {
                                if (PSettings.PreferenceAll.OverlayMaphack.UnitColors[j] != Color.Transparent)
                                {
                                    var clUnit = PSettings.PreferenceAll.OverlayMaphack.UnitColors[j];
                                    if (!tmpUnit.IsAlive)
                                    {
                                        continue;
                                    }

                                    if (PSettings.PreferenceAll.OverlayMaphack.RemoveLocalplayer)
                                    {
                                        if (tmpUnit.Owner ==
                                            Player.LocalPlayer.Index)
                                        {
                                            continue;
                                        }
                                    }

                                    g.Graphics.DrawRectangle(
                                        new Pen(new SolidBrush(clUnit), 1.5f),
                                        (iUnitPosX - size / 2), (iUnitPosY - size / 2), size, size);

                                    g.Graphics.DrawRectangle(new Pen(new SolidBrush(clUnitBoundBorder)),
                                                             iUnitPosX - ((size / 2) + 0.75f),
                                                             iUnitPosY - ((size / 2) + 0.75f), size + 1.75f, size + 1.75f);
                                }
                            }
                        }
                    }

                    #endregion

                    #region CreepTumors

                    //if (_hMainHandler.GInformation.Unit[i].CustomStruct.Id == (int) PredefinedTypes.UnitId.ZbCreeptumor)
                    //{
                    //    g.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Gray), 1.5f),
                    //                             (iUnitPosX - size/2), (iUnitPosY - size/2), size, size);

                    //    g.Graphics.DrawRectangle(new Pen(new SolidBrush(clUnitBoundBorder)),
                    //                             iUnitPosX - ((size/2) + 0.75f),
                    //                             iUnitPosY - ((size/2) + 0.75f), size + 1.75f, size + 1.75f);
                    //}


                    //if (_hMainHandler.GInformation.Unit[i].CustomStruct.Id == (int)PredefinedTypes.UnitId.ZbCreeptumor ||
                    //    _hMainHandler.GInformation.Unit[i].CustomStruct.Id == (int)PredefinedTypes.UnitId.ZbCreepTumorBuilding ||
                    //    _hMainHandler.GInformation.Unit[i].CustomStruct.Id == (int)PredefinedTypes.UnitId.ZbCreepTumorMissle ||
                    //    _hMainHandler.GInformation.Unit[i].CustomStruct.Id == (int)PredefinedTypes.UnitId.ZbCreeptumorBurrowed)
                    //{
                    //    const Int32 iRadius = 4;

                    //    g.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                    //    g.Graphics.SmoothingMode = SmoothingMode.HighQuality;

                    //    g.Graphics.DrawLine(Constants.PBlack1, iUnitPosX - iRadius, iUnitPosY - iRadius, iUnitPosX + iRadius, iUnitPosY + iRadius);
                    //    g.Graphics.DrawLine(Constants.PBlack1, iUnitPosX + iRadius, iUnitPosY - iRadius, iUnitPosX - iRadius, iUnitPosY + iRadius);

                    //    g.Graphics.SmoothingMode = SmoothingMode.HighSpeed;
                    //    g.Graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;

                    //}

                    #endregion

                    #region Unitgroup I - Defensive Buildings

                    if (PSettings.PreferenceAll.OverlayMaphack.ColorDefensiveStructures)
                    {
                        if (tmpUnit.Id == UnitId.TbTurret ||
                            tmpUnit.Id == UnitId.TbBunker ||
                            tmpUnit.Id == UnitId.TbPlanetary ||
                            tmpUnit.Id == UnitId.ZbSpineCrawler ||
                            tmpUnit.Id == UnitId.ZbSpineCrawlerUnrooted ||
                            tmpUnit.Id == UnitId.ZbSporeCrawler ||
                            tmpUnit.Id == UnitId.ZbSporeCrawlerUnrooted ||
                            tmpUnit.Id == UnitId.PbCannon)
                        {
                            var clUnitBound = Color.Yellow;


                            if ((tmpUnit.TargetFilter & (ulong)TargetFilterFlag.Dead) > 0)
                            {
                                continue;
                            }


                            if (PSettings.PreferenceAll.OverlayMaphack.RemoveLocalplayer)
                            {
                                if (tmpUnit.Owner == Player.LocalPlayer.Index)
                                {
                                    continue;
                                }
                            }

                            g.Graphics.DrawRectangle(new Pen(new SolidBrush(clUnitBound), 1.5f),
                                                     (iUnitPosX - size / 2), (iUnitPosY - size / 2), size, size);

                            g.Graphics.DrawRectangle(new Pen(new SolidBrush(clUnitBoundBorder)),
                                                     iUnitPosX - ((size / 2) + 0.75f),
                                                     iUnitPosY - ((size / 2) + 0.75f), size + 1.75f, size + 1.75f);
                        }
                    }

                    #endregion

                    #region Hallucinations - make a triangle

                    #endregion

                    var ptPoints = new PointF[3];
                    var fRadius  = size * 2;

                    if (tmpUnit.IsHallucination)
                    {
                        ptPoints[0] = new PointF(iUnitPosX + (size / 2), iUnitPosY - fRadius - 1);
                        ptPoints[1] = new PointF(iUnitPosX - fRadius, iUnitPosY + fRadius);
                        ptPoints[2] = new PointF(iUnitPosX + fRadius + 1, iUnitPosY + fRadius);
                    }

                    g.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                    g.Graphics.SmoothingMode   = SmoothingMode.HighQuality;

                    g.Graphics.DrawPolygon(new Pen(Brushes.Orange, 1), ptPoints);

                    g.Graphics.SmoothingMode   = SmoothingMode.HighSpeed;
                    g.Graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;

                    #endregion
                }

                #endregion

                #region Draw Player camera

                if (!PSettings.PreferenceAll.OverlayMaphack.RemoveCamera)
                {
                    for (var i = 0; i < GInformation.Player.Count; i++)
                    {
                        var clPlayercolor = GInformation.Player[i].Color;

                        #region Teamcolor

                        if (GInformation.Gameinfo.IsTeamcolor)
                        {
                            if (Player.LocalPlayer != null)
                            {
                                if (GInformation.Player[i] == Player.LocalPlayer)
                                {
                                    clPlayercolor = Color.Green;
                                }

                                else if (GInformation.Player[i].Team ==
                                         Player.LocalPlayer.Team &&
                                         GInformation.Player[i] != Player.LocalPlayer)
                                {
                                    clPlayercolor = Color.Yellow;
                                }

                                else
                                {
                                    clPlayercolor = Color.Red;
                                }
                            }
                        }

                        #endregion

                        #region Escape Sequences

                        /* Ai - Works */
                        if (PSettings.PreferenceAll.OverlayMaphack.RemoveAi)
                        {
                            if (GInformation.Player[i].Type.Equals(PlayerType.Ai))
                            {
                                continue;
                            }
                        }

                        /* Localplayer - Works */
                        if (PSettings.PreferenceAll.OverlayMaphack.RemoveLocalplayer)
                        {
                            if (GInformation.Player[i] == Player.LocalPlayer)
                            {
                                continue;
                            }
                        }

                        /* Allie */
                        if (PSettings.PreferenceAll.OverlayMaphack.RemoveAllie)
                        {
                            if (Player.LocalPlayer != null)
                            {
                                if (GInformation.Player[i].Team ==
                                    Player.LocalPlayer.Team &&
                                    GInformation.Player[i] != Player.LocalPlayer)
                                {
                                    continue;
                                }
                            }
                        }

                        /* Neutral */
                        if (PSettings.PreferenceAll.OverlayMaphack.RemoveNeutral)
                        {
                            if (GInformation.Player[i].Type.Equals(PlayerType.Neutral))
                            {
                                continue;
                            }
                        }

                        if (GInformation.Player[i].Type.Equals(PlayerType.Hostile))
                        {
                            continue;
                        }

                        if (GInformation.Player[i].Type.Equals(PlayerType.Observer))
                        {
                            continue;
                        }

                        if (GInformation.Player[i].Type.Equals(PlayerType.Referee))
                        {
                            continue;
                        }

                        if (float.IsInfinity(fScale))
                        {
                            continue;
                        }

                        if (CheckIfGameheart(GInformation.Player[i]))
                        {
                            continue;
                        }

                        #endregion

                        #region Drawing

                        //The actrual position of the Cameras
                        var fPlayerX = (GInformation.Player[i].CameraPositionX - tmpMap.Left) * fScale + fX;
                        var fPlayerY = (tmpMap.Top - GInformation.Player[i].CameraPositionY) * fScale + fY;


                        if (fPlayerX <= 0 || fPlayerX >= Width ||
                            fPlayerY <= 0 || fPlayerY >= Height)
                        {
                            continue;
                        }

                        var size             = 48f;
                        var upper            = 35f;
                        var lower            = 10f;
                        var fLocalHypotenuse = 5.3755f;
                        var fUpperHypotenuse = 7.3718f;
                        var fLowerHypotenuse = 25.8016f;
                        var fLocalSizeScale  = fHypotenuse / fLocalHypotenuse;
                        var fLocalUpperScale = fHypotenuse / fUpperHypotenuse;
                        var fLocalLowerScale = fHypotenuse / fLowerHypotenuse;
                        size = (float)Math.Sqrt((Math.Pow(fLocalSizeScale, 2) - Math.Pow(size, 2)));
                        var upperRadius = (float)Math.Sqrt((Math.Pow(fLocalUpperScale, 2) - Math.Pow(upper, 2)));
                        var lowerRadius = (float)Math.Sqrt((Math.Pow(fLocalLowerScale, 2) - Math.Pow(lower, 2)));
                        var radius      = size / 2;



                        var ptPoints = new PointF[4];
                        ptPoints[0] = new PointF(fPlayerX - upperRadius, fPlayerY - radius);
                        ptPoints[1] = new PointF(fPlayerX + upperRadius, fPlayerY - radius);
                        ptPoints[2] = new PointF(fPlayerX + radius, fPlayerY + lowerRadius);
                        ptPoints[3] = new PointF(fPlayerX - radius, fPlayerY + lowerRadius);


                        g.Graphics.DrawPolygon(new Pen(new SolidBrush(clPlayercolor), 2), ptPoints);

                        #endregion
                    }
                }

                #endregion

                #endregion
            }

            catch (Exception ex)
            {
                Messages.LogFile("Over all", ex);
            }
        }
        private static void ParseText(XElement element, InlineCollection inlines, HtmlLabel label)
        {
            if (element == null)
            {
                return;
            }

            InlineCollection currentInlines = inlines;
            var elementName = element.Name.ToString().ToUpperInvariant();

            switch (elementName)
            {
            case _elementA:
                var        link         = new Hyperlink();
                XAttribute href         = element.Attribute("href");
                var        unescapedUri = Uri.UnescapeDataString(href?.Value);
                if (href != null)
                {
                    try
                    {
                        link.NavigateUri = new Uri(unescapedUri);
                    }
                    catch (FormatException) { /* href is not valid */ }
                }
                link.Click += (sender, e) =>
                {
                    sender.NavigateUri = null;
                    RendererHelper.HandleUriClick(label, unescapedUri);
                };
                if (!label.LinkColor.IsDefault)
                {
                    link.Foreground = label.LinkColor.ToBrush();
                }
                if (!label.UnderlineText)
                {
                    link.UnderlineStyle = UnderlineStyle.None;
                }
                inlines.Add(link);
                currentInlines = link.Inlines;
                break;

            case _elementB:
            case _elementStrong:
                var bold = new Bold();
                inlines.Add(bold);
                currentInlines = bold.Inlines;
                break;

            case _elementI:
            case _elementEm:
                var italic = new Italic();
                inlines.Add(italic);
                currentInlines = italic.Inlines;
                break;

            case _elementU:
                var underline = new Underline();
                inlines.Add(underline);
                currentInlines = underline.Inlines;
                break;

            case _elementBr:
                inlines.Add(new LineBreak());
                break;

            case _elementP:
                // Add two line breaks, one for the current text and the second for the gap.
                if (AddLineBreakIfNeeded(inlines))
                {
                    inlines.Add(new LineBreak());
                }

                var paragraphSpan = new Span();
                inlines.Add(paragraphSpan);
                currentInlines = paragraphSpan.Inlines;
                break;

            case _elementLi:
                inlines.Add(new LineBreak());
                inlines.Add(new Run {
                    Text = " • "
                });
                break;

            case _elementUl:
            case _elementDiv:
                _ = AddLineBreakIfNeeded(inlines);
                var divSpan = new Span();
                inlines.Add(divSpan);
                currentInlines = divSpan.Inlines;
                break;
            }
            foreach (XNode node in element.Nodes())
            {
                if (node is XText textElement)
                {
                    currentInlines.Add(new Run {
                        Text = textElement.Value
                    });
                }
                else
                {
                    ParseText(node as XElement, currentInlines, label);
                }
            }

            // Add newlines for paragraph tags
            if (elementName == "ElementP")
            {
                currentInlines.Add(new LineBreak());
            }
        }
示例#21
0
 public void SetRenderer(Renderer renderer)
 {
     mRendererHelper = (renderer != null ? new RendererHelper(this, renderer) : null);
     base.SetRenderer(mRendererHelper);
 }
示例#22
0
        /// <summary>
        ///     Draws the panelspecific data.
        /// </summary>
        /// <param name="g"></param>
        protected override void Draw(BufferedGraphics g)
        {
            try
            {
                if (!GInformation.Gameinfo.IsIngame)
                {
                    return;
                }

                var iValidPlayerCount = GInformation.Gameinfo.ValidPlayerCount;

                if (iValidPlayerCount == 0)
                {
                    return;
                }

                Opacity = PSettings.PreferenceAll.OverlayApm.Opacity;
                var iSingleHeight       = Height / iValidPlayerCount;
                var fNewFontSize        = (float)((29.0 / 100) * iSingleHeight);
                var fInternalFont       = new Font(PSettings.PreferenceAll.OverlayApm.FontName, fNewFontSize, FontStyle.Bold);
                var fInternalFontNormal = new Font(fInternalFont.Name, fNewFontSize, FontStyle.Regular);

                if (!BChangingPosition)
                {
                    Height = PSettings.PreferenceAll.OverlayApm.Height * iValidPlayerCount;
                    Width  = PSettings.PreferenceAll.OverlayApm.Width;
                }

                var iCounter = 0;
                for (var i = 0; i < GInformation.Player.Count; i++)
                {
                    var clPlayercolor = GInformation.Player[i].Color;

                    #region Teamcolor

                    RendererHelper.TeamColor(GInformation.Player, i,
                                             GInformation.Gameinfo.IsTeamcolor, ref clPlayercolor);

                    #endregion

                    #region Escape sequences

                    if (GInformation.Player[i].Name.StartsWith("\0") || GInformation.Player[i].NameLength <= 0)
                    {
                        continue;
                    }

                    if (GInformation.Player[i].Type.Equals(PlayerType.Hostile))
                    {
                        continue;
                    }

                    if (GInformation.Player[i].Type.Equals(PlayerType.Observer))
                    {
                        continue;
                    }

                    if (GInformation.Player[i].Type.Equals(PlayerType.Referee))
                    {
                        continue;
                    }

                    if (CheckIfGameheart(GInformation.Player[i]))
                    {
                        continue;
                    }


                    if (PSettings.PreferenceAll.OverlayApm.RemoveAi)
                    {
                        if (GInformation.Player[i].Type.Equals(PlayerType.Ai))
                        {
                            continue;
                        }
                    }

                    if (PSettings.PreferenceAll.OverlayApm.RemoveNeutral)
                    {
                        if (GInformation.Player[i].Type.Equals(PlayerType.Neutral))
                        {
                            continue;
                        }
                    }

                    if (PSettings.PreferenceAll.OverlayApm.RemoveAllie)
                    {
                        if (Player.LocalPlayer.Index == 16)
                        {
                            //Do nothing
                        }

                        else
                        {
                            if (GInformation.Player[i].Team ==
                                Player.LocalPlayer.Team &&
                                GInformation.Player[i].Index != Player.LocalPlayer.Index)
                            {
                                continue;
                            }
                        }
                    }

                    if (PSettings.PreferenceAll.OverlayApm.RemoveLocalplayer)
                    {
                        if (Player.LocalPlayer == GInformation.Player[i])
                        {
                            continue;
                        }
                    }

                    #endregion

                    #region Draw Bounds and Background

                    if (PSettings.PreferenceAll.OverlayApm.DrawBackground)
                    {
                        /* Background */
                        g.Graphics.FillRectangle(Brushes.Gray, 1, 1 + (iSingleHeight * iCounter), Width - 2,
                                                 iSingleHeight - 2);

                        /* Border */
                        g.Graphics.DrawRectangle(new Pen(new SolidBrush(clPlayercolor), 2), 1,
                                                 1 + (iSingleHeight * iCounter),
                                                 Width - 2, iSingleHeight - 2);
                    }

                    #endregion

                    #region Content Drawing

                    #region Name

                    var strName = (GInformation.Player[i].ClanTag.StartsWith("\0") ||
                                   PSettings.PreferenceAll.OverlayApm.RemoveClanTag)
                        ? GInformation.Player[i].Name
                        : "[" + GInformation.Player[i].ClanTag + "] " + GInformation.Player[i].Name;

                    g.Graphics.DrawString(
                        strName,
                        fInternalFont,
                        new SolidBrush(clPlayercolor),
                        Brushes.Black, (float)((1.67 / 100) * Width),
                        (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                        1f, 1f, true);

                    #endregion

                    #region Team

                    g.Graphics.DrawString(
                        "#" + GInformation.Player[i].Team, fInternalFontNormal,
                        Brushes.White,
                        Brushes.Black, (float)((29.67 / 100) * Width),
                        (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                        1f, 1f, true);

                    #endregion

                    #region Apm

                    g.Graphics.DrawString(
                        "APM: " + GInformation.Player[i].ApmAverage +
                        " [" + GInformation.Player[i].Apm + "]", fInternalFontNormal,
                        Brushes.White,
                        Brushes.Black, (float)((37.0 / 100) * Width),
                        (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                        1f, 1f, true);

                    #endregion

                    #region Epm

                    g.Graphics.DrawString(
                        "EPM: " + GInformation.Player[i].EpmAverage +
                        " [" + GInformation.Player[i].Epm + "]", fInternalFontNormal,
                        Brushes.White,
                        Brushes.Black, (float)((63.67 / 100) * Width),
                        (float)((24.0 / 100) * iSingleHeight) + iSingleHeight * iCounter,
                        1f, 1f, true);

                    #endregion

                    #endregion

                    iCounter++;
                }
            }

            catch (Exception ex)
            {
                Logger.Emit(ex);
            }
        }
示例#23
0
 protected override bool NavigateToUrl(NSUrl url)
 {
     // Try to handle uri, if it can't be handled, fall back to IOS his own handler.
     return(!RendererHelper.HandleUriClick(Element, url.AbsoluteString));
 }