예제 #1
0
        internal WriterStyle(Style style)
        {
            Debug.Assert(style != null, "writer style is null");
            _alignment = (Alignment)style[Style.AlignmentKey, true];
            if (_alignment == Alignment.NotSet)
            {
                _alignment = Alignment.Left;
            }
            _wrapping = (Wrapping)style[Style.WrappingKey, true];
            if (_wrapping == Wrapping.NotSet)
            {
                _wrapping = Wrapping.Wrap;
            }

            _fontSize = (FontSize)style[Style.FontSizeKey, true];
            if (_fontSize == FontSize.NotSet)
            {
                _fontSize = FontSize.Normal;
            }
            _fontName  = (String)style[Style.FontNameKey, true];
            _fontColor = (Color)style[Style.ForeColorKey, true];

            _bold   = ((BooleanOption)style[Style.BoldKey, true] == BooleanOption.True);
            _italic = ((BooleanOption)style[Style.ItalicKey, true] == BooleanOption.True);

            _format = true;
            _layout = true;
        }
예제 #2
0
        public void SetWrapping(Wrapping wrapMode)
        {
            GL.BindTexture(TextureTarget.Texture2D, Handle);
            wrapping = wrapMode;
            int wrap;

            if (wrapping == Wrapping.Repeat)
            {
                wrap = (int)TextureWrapMode.Repeat;
            }
            else if (wrapping == Wrapping.Clamp)
            {
                wrap = (int)TextureWrapMode.Clamp;
            }
            else if (wrapping == Wrapping.Mirror)
            {
                wrap = (int)TextureWrapMode.MirroredRepeat;
            }
            else
            {
                wrap = (int)TextureWrapMode.Repeat;
            }
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, wrap);
            GL.BindTexture(TextureTarget.Texture2D, 0);
        }
예제 #3
0
    void Awake()
    {
        //Core grapple
        _grappleState   = GrappleState.Ready;
        _grappleSuccess = false;

        _grappleTimer = ThrowTime;

        //Wrapping
        _wrap = Wrapping.Wrap;

        _radii      = new List <float>();
        pivotPoints = new List <Vector3>();

        //Indicator + Sprite
        Indicator                 = Instantiate(Indicator, transform.position, transform.rotation);
        indicatorRenderer         = Indicator.GetComponentInChildren <SpriteRenderer>();
        indicatorRenderer.enabled = false;

        grappleSprite       = new GameObject("GrappleSprite");
        grappleSpriteRender = grappleSprite.AddComponent <SpriteRenderer>();
        grappleSpriteRender.sortingLayerName = "UI";
        grappleSpriteRender.sprite           = GrappleSprite;
        grappleSpriteRender.enabled          = false;

        _lineRender = gameObject.AddComponent <LineRenderer>();
        _lineRender.sortingOrder = 1;
        _lineRender.startWidth   = 0.2f;
        _lineRender.endWidth     = 0.2f;
        _lineRender.enabled      = false;

        _lineRender.material   = new Material(Shader.Find("Sprites/Default"));
        _lineRender.startColor = RopeColor;
        _lineRender.endColor   = RopeColor;
    }
예제 #4
0
    void Awake()
    {
        _grappleState   = GrappleState.Ready;
        _grappleSuccess = false;

        _swingTime = ThrowTime;

        _wrap = Wrapping.Wrap;

        _pivotPoints = new List <Vector3>();
        _radii       = new List <float>();

        Indicator         = Instantiate(Indicator, transform.position, transform.rotation);
        IndicatorRenderer = Indicator.GetComponent <SpriteRenderer>();

        grappleSprite               = new GameObject("GrappleSprite");
        grappleSpriteRender         = grappleSprite.AddComponent <SpriteRenderer>();
        grappleSpriteRender.sprite  = GrappleSprite;
        grappleSpriteRender.enabled = false;

        _lineRender            = gameObject.AddComponent <LineRenderer>();
        _lineRender.startColor = Color.white;
        _lineRender.endColor   = Color.green;
        _lineRender.startWidth = 0.1f;
        _lineRender.endWidth   = 0.1f;
        _lineRender.enabled    = false;
    }
        // Overriden to always write the "align" or "wrap" attributes when
        // they are changing, even if they are set to defaults.

        /// <include file='doc\UpWmlMobileTextWriter.uex' path='docs/doc[@for="UpWmlMobileTextWriter.OpenParagraph"]/*' />
        protected override void OpenParagraph(WmlLayout layout, bool writeAlignment, bool writeWrapping)
        {
            base.OpenParagraph(layout,
                               writeAlignment || layout.Align != _lastAlignment,
                               writeWrapping || layout.Wrap != _lastWrapping);
            _lastAlignment = layout.Align;
            _lastWrapping  = layout.Wrap;
        }
        public override void Render(HtmlMobileTextWriter writer)
        {
            String additionalStyle;

            Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];
            Wrapping  wrapping  = (Wrapping)Style[Style.WrappingKey, true];
            bool      wrap      = (wrapping == Wrapping.Wrap || wrapping == Wrapping.NotSet);
            String    width     = DesignerAdapterUtil.GetWidth(Control);

            ((DesignerTextWriter)writer).EnterZeroFontSizeTag();
            writer.EnterLayout(Style);
            writer.WriteBeginTag("div");
            if (!wrap)
            {
                byte templateStatus;
                int  maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus);
                if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
                {
                    width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px";
                }
                additionalStyle = "overflow-x:hidden;width:" + width + ";";
            }
            else
            {
                additionalStyle = "word-wrap:break-word;width:" + width + ";";
            }

            ((DesignerTextWriter)writer).WriteStyleAttribute(Style, additionalStyle);
            if (alignment != Alignment.NotSet)
            {
                writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment));
            }
            writer.Write(">");

            writer.WriteText(Control.HeaderText, true);

            writer.WriteFullBeginTag("ul");
            for (int i = 1; i <= 2; i++)
            {
                writer.WriteFullBeginTag("li");
                writer.Write(SR.GetString(SR.ValidationSummary_ErrorMessage, i.ToString(CultureInfo.InvariantCulture)));
                writer.WriteEndTag("li");
            }
            writer.WriteEndTag("ul");

            writer.WriteBeginTag("a");
            writer.WriteAttribute("href", "NavigationUrl");
            writer.Write(">");
            writer.WriteText(String.IsNullOrEmpty(Control.BackLabel) ? GetDefaultLabel(BackLabel) : Control.BackLabel, true);
            writer.WriteEndTag("a");

            writer.WriteEndTag("div");
            writer.ExitLayout(Style);
            ((DesignerTextWriter)writer).ExitZeroFontSizeTag();
        }
예제 #7
0
        internal WriterStyle()
        {
            _wrapping  = Wrapping.Wrap;
            _alignment = Alignment.Left;
            _fontName  = String.Empty;
            _fontColor = Color.Empty;
            _fontSize  = FontSize.Normal;
            _bold      = false;
            _italic    = false;

            _format = true;
            _layout = true;
        }
        private void BuildStyleClassNoWrap(StringBuilder classBuilder)
        {
            if ((_filter & StyleFilter.Wrapping) == 0)
            {
                return;
            }
            Wrapping styleWrapping = (Wrapping)_controlStyle [Style.WrappingKey, true /* inherit */];

            if (styleWrapping == Wrapping.NoWrap)
            {
                classBuilder.Append("white-space: nowrap;\r\n");
            }
        }
예제 #9
0
        private static void WrappingTest()
        {
            Console.WriteLine($"Wrapping Functions");
            Console.WriteLine();
            Console.WriteLine($"    x    wrapped");
            Console.WriteLine($"===================================================================================");

            for (double x = -5.0; x <= 5.0; x += 0.5)
            {
                double mapping1 = Wrapping.Wrap(x, -1, 1);

                Console.WriteLine($"{x,5:N1} {mapping1,9:N1}");
            }

            Console.WriteLine($"===================================================================================");
        }
        private void BeginNextCard()
        {
            if (AnalyzeMode)
            {
                // Add a softkey on the current card, to go to the new card.

                String nextCardId = "card" + (_currentCardIndex + 1).ToString(CultureInfo.InvariantCulture);

                UpHyperlinkSoftkey softkey = new UpHyperlinkSoftkey();
                softkey.TargetUrl = "#" + nextCardId;
                softkey.EncodeUrl = false;
                softkey.Label     = "OK";
                SetPrimarySoftkey(softkey);

                CurrentCard.AnchorCount = _currentCardAnchorCount;

                UpCard card = AllocateNewCard();
                card.Id = nextCardId;
                _currentCardIndex++;
            }
            else
            {
                RenderCardClosing(_currentCardIndex);
                CloseParagraph();
                WriteEndTag("card");
                WriteLine();

                _currentCardIndex++;
                _lastAlignment = Alignment.Left;
                _lastWrapping  = Wrapping.NoWrap;

                WriteBeginTag("card");
                WriteAttribute("id", CurrentCard.Id);
                String formTitle = CurrentForm.Title;
                if (formTitle != null && formTitle.Length > 0)
                {
                    WriteTextEncodedAttribute("title", formTitle);
                }
                WriteLine(">");
                RenderCardOpening(_currentCardIndex);
            }

            _currentCardAnchorCount = 0;
            _currentCardPostBacks   = 0;
            _currentCardSubmits     = 0;
        }
        public override void Render(HtmlMobileTextWriter writer)
        {
            Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];
            Wrapping  wrapping  = (Wrapping)Style[Style.WrappingKey, true];
            bool      wrap      = (wrapping == Wrapping.Wrap || wrapping == Wrapping.NotSet);
            String    width     = DesignerAdapterUtil.GetWidth(Control);

            ((DesignerTextWriter)writer).EnterZeroFontSizeTag();
            writer.WriteBeginTag("div");

            if (!wrap)
            {
                byte templateStatus;
                int  maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus);

                if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
                {
                    width = maxWidth.ToString() + "px";
                }
                writer.WriteAttribute("style", "overflow-x:hidden;width:" + width);
            }
            else
            {
                writer.WriteAttribute("style", "word-wrap:break-word;width:" + width);
            }

            if (alignment != Alignment.NotSet)
            {
                writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment));
            }
            writer.Write(">");

            if (Control.Text.Trim().Length > 0)
            {
                ((DesignerTextWriter)writer).WriteCssStyleText(Style, null, Control.Text, true);
            }
            else
            {
                ((DesignerTextWriter)writer).WriteCssStyleText(Style, null, Control.ErrorMessage, true);
            }

            writer.WriteEndTag("div");
            ((DesignerTextWriter)writer).ExitZeroFontSizeTag();
        }
예제 #12
0
        public int DeleteWrappingWP(Wrapping w)
        {
            var query = (from x in db.wp_terms
                         where x.term_id.Equals(w.WrappingId)
                         select x).First();

            var query2 = (from x in db.wp_term_taxonomy
                          where x.term_id.Equals(w.WrappingId)
                          select x).First();

            var query3 = (from x in db.wp_term_relationships
                          where x.term_taxonomy_id.Equals(query2.term_taxonomy_id)
                          select x).First();

            db.wp_terms.Remove(query);
            db.wp_term_taxonomy.Remove(query2);
            db.wp_term_relationships.Remove(query3);

            return(db.SaveChanges());
        }
        public override void Render(HtmlMobileTextWriter writer)
        {
            Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];
            Wrapping  wrapping  = (Wrapping)Style[Style.WrappingKey, true];
            bool      wrap      = (wrapping == Wrapping.Wrap || wrapping == Wrapping.NotSet);
            String    width     = DesignerAdapterUtil.GetWidth(Control);

            ((DesignerTextWriter)writer).EnterZeroFontSizeTag();
            writer.WriteBeginTag("div");
            if (!wrap)
            {
                byte templateStatus;
                int  maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus);
                if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
                {
                    width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px";
                }
                writer.WriteAttribute("style", "overflow-x:hidden;width:" + width);
            }
            else
            {
                writer.WriteAttribute("style", "word-wrap:break-word;width:" + width);
            }

            if (alignment != Alignment.NotSet)
            {
                writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment));
            }
            writer.Write(">");

            MSHTMLHostUtil.ApplyStyle(null, null, null);
            String filteredText     = FilterTags(Control.Text.Trim());
            int    uniqueLineHeight = MSHTMLHostUtil.GetHtmlFragmentHeight("a");
            int    requiredHeight   = MSHTMLHostUtil.GetHtmlFragmentHeight(filteredText);
            int    requiredWidth    = MSHTMLHostUtil.GetHtmlFragmentWidth(filteredText);

            ((DesignerTextWriter)writer).WriteCssStyleText(Style, null, (requiredHeight > uniqueLineHeight || requiredWidth > 1) ? filteredText : "&nbsp;", false);
            writer.WriteEndTag("div");
            ((DesignerTextWriter)writer).ExitZeroFontSizeTag();
        }
예제 #14
0
        internal void WriteDesignerStyleAttributes(MobileControl control,
                                                   Style style)
        {
            Alignment alignment = (Alignment)style[Style.AlignmentKey, true];
            Wrapping  wrapping  = (Wrapping)style[Style.WrappingKey, true];
            Color     backColor = (Color)style[Style.BackColorKey, true];

            bool align = (alignment != Alignment.NotSet);
            bool wrap  = (wrapping == Wrapping.Wrap || wrapping == Wrapping.NotSet);

            String width = DesignerAdapterUtil.GetWidth(control);

            byte templateStatus;
            int  maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(control, out templateStatus);

            if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
            {
                width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px";
            }

            if (!wrap)
            {
                Write(" style=\"overflow-x:hidden;width:" + width);
            }
            else
            {
                Write(" style=\"word-wrap:break-word;overflow-x:hidden;width:" + width);
            }

            if (backColor != Color.Empty)
            {
                Write(";background-color:" + ColorTranslator.ToHtml(backColor));
            }

            if (align)
            {
                Write(";text-align:" + Enum.GetName(typeof(Alignment), alignment));
            }
        }
예제 #15
0
        public Texture2D(string path, Filter filterMode = Filter.Linear, Wrapping wrapMode = Wrapping.Repeat, bool generateMipMaps = true) : base(path)
        {
            pixels = (Image <Rgba32>)Image.Load(path);

            var         tempPixels = pixels.GetPixelSpan();
            List <byte> bytePixels = new List <byte>();

            foreach (Rgba32 c in tempPixels)
            {
                bytePixels.Add(c.R);
                bytePixels.Add(c.G);
                bytePixels.Add(c.B);
                bytePixels.Add(c.A);
            }
            GL.BindTexture(TextureTarget.Texture2D, Handle);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, pixels.Width, pixels.Height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, bytePixels.ToArray());

            var metaData = LoadMetaData();

            SetFilter(metaData.Count >= 1 ? (Filter)Convert.ToInt32(metaData[0].value) : filterMode, generateMipMaps);

            SetWrapping(metaData.Count >= 2 ? (Wrapping)Convert.ToInt32(metaData[1].value) : wrapMode);
        }
        private void BeginNextCard()
        {
            if (AnalyzeMode)
            {
                // Add a softkey on the current card, to go to the new card.

                String nextCardId = "card" + (_currentCardIndex + 1).ToString(CultureInfo.InvariantCulture);

                UpHyperlinkSoftkey softkey = new UpHyperlinkSoftkey();
                softkey.TargetUrl = "#" + nextCardId;
                softkey.EncodeUrl = false;
                softkey.Label = "OK";
                SetPrimarySoftkey(softkey);

                CurrentCard.AnchorCount = _currentCardAnchorCount;

                UpCard card = AllocateNewCard();
                card.Id = nextCardId;
                _currentCardIndex++;
            }
            else
            {
                RenderCardClosing(_currentCardIndex);
                CloseParagraph();
                WriteEndTag("card");
                WriteLine();
    
                _currentCardIndex++;
                _lastAlignment = Alignment.Left;
                _lastWrapping = Wrapping.NoWrap;
    
                WriteBeginTag("card");
                WriteAttribute("id", CurrentCard.Id);
                String formTitle = CurrentForm.Title;
                if (formTitle != null && formTitle.Length > 0)
                {
                    WriteTextEncodedAttribute("title", formTitle);
                }
                WriteLine(">");
                RenderCardOpening(_currentCardIndex);
            }

            _currentCardAnchorCount = 0;
            _currentCardPostBacks = 0;
            _currentCardSubmits = 0;
        }
        // Overriden to always write the "align" or "wrap" attributes when
        // they are changing, even if they are set to defaults.

        /// <include file='doc\UpWmlMobileTextWriter.uex' path='docs/doc[@for="UpWmlMobileTextWriter.OpenParagraph"]/*' />
        protected override void OpenParagraph(WmlLayout layout, bool writeAlignment, bool writeWrapping)
        {
            base.OpenParagraph(layout,
                               writeAlignment || layout.Align != _lastAlignment,
                               writeWrapping  || layout.Wrap != _lastWrapping);
            _lastAlignment = layout.Align;
            _lastWrapping = layout.Wrap;
        }
예제 #18
0
    //Execution of Grapple ability
    public void Activate(PlayerController controller)
    {
        //TODO functionise indicator updates
        #region Update Indicator
        Vector2 mousedir = controller.PlayerToMouseDir();
        float   angle    = Mathf.Atan2(mousedir.y, mousedir.x) * Mathf.Rad2Deg;

        Indicator.transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
        Indicator.transform.position = controller.transform.position;
        #endregion

        //Switch on core state
        switch (_grappleState)
        {
            #region Ready State
        case GrappleState.Ready:

            //Raycast in direction of mouse position from player, to grapple distance
            _rayCastGrapple = Physics2D.Raycast(controller.transform.position, controller.PlayerToMouseDir(), maxGrappleDistance, LayerMask.GetMask("Default"));

            if (_rayCastGrapple)
            {
                //Reveal indicator sprite at cast hit
                grappleSpriteRender.enabled      = true;
                grappleSprite.transform.position = _rayCastGrapple.point;
            }
            else
            {
                //Hide indicator sprite
                grappleSpriteRender.enabled = false;
            }

            //On input
            if (InputController.Instance.Ability.Down)
            {
                indicatorRenderer.enabled = false;

                if (_rayCastGrapple)
                {
                    //set initial grappling point and radius
                    initPivot = _rayCastGrapple.point;
                    curPivot  = initPivot;
                    _radius   = Vector3.Distance(controller.transform.position, initPivot);

                    _grappleSuccess = true;

                    //Grapple cannot be a success on death blocks
                    if (_rayCastGrapple.transform.CompareTag("Respawn"))
                    {
                        _grappleSuccess = false;
                    }
                }
                else
                {
                    //Set dummy point and radius for grapple anim
                    _radius         = maxGrappleDistance;
                    initPivot       = controller.PlayerToMouseDir() * maxGrappleDistance;
                    initPivot      += controller.transform.position;
                    _grappleSuccess = false;
                }

                //Set swing direction
                if (initPivot.x >= controller.transform.position.x)
                {
                    _swingDir = 1f;
                }
                else
                {
                    _swingDir = -1f;
                }

                //Init grapple sprite movmement during Firing
                grappleSprite.transform.position = controller.transform.position;
                grappleSpriteRender.enabled      = true;
                _grappSpriteMove = (initPivot - controller.transform.position).normalized * _radius / ThrowTime;

                //Init line render for grapple indicator
                _lineRender.enabled       = true;
                _lineRender.positionCount = 2;
                _lineRender.SetPosition(0, grappleSprite.transform.position);
                _lineRender.SetPosition(1, controller.transform.position);

                //Switch state
                _grappleState = GrappleState.Firing;
            }
            break;

            #endregion
            #region Firing State
        case GrappleState.Firing:


            if (_grappleTimer > 0)
            {
                _grappleTimer -= Time.deltaTime;

                //Move sprite along direction
                grappleSprite.transform.position += _grappSpriteMove * Time.deltaTime;

                //Update line render to follow grapple sprite and player pos
                _lineRender.SetPosition(0, grappleSprite.transform.position);
                _lineRender.SetPosition(1, controller.transform.position);
            }
            else
            {
                //If player is grounded at end of firing, do not swing
                if (controller.grounded)
                {
                    _grappleSuccess = false;
                }

                if (_grappleSuccess)
                {
                    //Clear line render
                    _lineRender.positionCount = 0;

                    //If player is above grapple point, wrapping state Floats; otherwise wrapping state wraps
                    _wrap = Wrapping.Wrap;
                    if (initPivot.y <= controller.transform.position.y)
                    {
                        _wrap = Wrapping.Float;
                        //Special case where float will exit into wrap
                        _specialFloatExit = true;
                        //reverse swing direction to swing correct direction when wrap state kicks in
                        _swingDir *= -1;
                    }

                    _grappleTimer = GrappleCooldown;

                    //Set Line Points
                    pivotPoints.Add(initPivot);
                    pivotPoints.Add(controller.transform.position);

                    SetLinePos();

                    _radius = Vector3.Distance(controller.transform.position, initPivot);
                    _radii.Add(_radius);

                    //Indicators
                    _lineRender.enabled         = true;
                    grappleSpriteRender.enabled = true;

                    //State
                    _grappleState = GrappleState.Connected;
                }
                else
                {
                    ResetGrapple();
                }
            }
            break;

            #endregion
            #region Connected State
        case GrappleState.Connected:

            //Always wrap and unwrap, swing by ?



            //Switch on swinging states
            switch (_wrap)
            {
                #region Wrap
            case Wrapping.Wrap:

                //Move the player
                controller.SetVelocity(Swing(controller) * SwingSpeed);

                //Wrap around obstructing obstacles
                RaycastHit2D pivotHit = Physics2D.Linecast(controller.transform.position, curPivot, LayerMask.GetMask("Default"));
                if (pivotHit)
                {
                    if (new Vector3(pivotHit.point.x, pivotHit.point.y, 0f) != curPivot)
                    {
                        curPivot = pivotHit.point;
                        _radius  = Vector3.Distance(controller.transform.position, curPivot);
                        _radii.Add(_radius);
                        pivotPoints.Insert(pivotPoints.Count - 1, pivotHit.point);
                        SetLinePos();
                    }
                }

                //always exits to float when player goes above latest wrap point
                if (controller.transform.position.y > curPivot.y)
                {
                    _wrap = Wrapping.Float;
                }
                break;

                #endregion
                #region Unwrap
            case Wrapping.UnWrap:

                //Move the player
                controller.SetVelocity(Swing(controller) * SwingSpeed);

                //_pivotPoints.Count is adjusted by -2 to ignore: initial grapple point and player position

                //If we have extra pivot points
                if (pivotPoints.Count > 2)
                {
                    //direction between last and second last
                    Vector3 aPivot = pivotPoints[pivotPoints.Count - 2];
                    Vector3 bPivot = pivotPoints[pivotPoints.Count - 3];

                    Vector3 pivDirection = (aPivot - bPivot).normalized;
                    Vector3 plaDirection = (controller.transform.position - aPivot).normalized;
                    //2D cross product
                    float cross = pivDirection.x * plaDirection.y - pivDirection.y * plaDirection.x;

                    if ((cross > 0 && _swingDir > 0) || (cross < 0 && _swingDir < 0))
                    {
                        //drop point
                        pivotPoints.RemoveAt(pivotPoints.Count - 2);
                        curPivot = pivotPoints[pivotPoints.Count - 2];
                        _radii.RemoveAt(_radii.Count - 1);
                        _radius = _radii[_radii.Count - 1];

                        SetLinePos();
                    }
                }

                //Based on swing direction, enter wrap state when passing the pivot point
                if (_swingDir < 0)
                {
                    if (controller.transform.position.x < pivotPoints[0].x)
                    {
                        _wrap = Wrapping.Wrap;
                    }
                }
                else
                {
                    if (controller.transform.position.x > pivotPoints[0].x)
                    {
                        _wrap = Wrapping.Wrap;
                    }
                }

                break;

                #endregion
                #region Float
            case Wrapping.Float:

                //Clamp player x movement while attached in float
                float wallmax = curPivot.x + _radius;
                float wallmin = curPivot.x - _radius;

                //overwrite player movement to clamp
                Vector2 move = controller.velocity * Time.deltaTime;
                if (controller.transform.position.x + move.x < wallmin || controller.transform.position.x + move.x > wallmax)
                {
                    controller.SetHorizontalVelocity(0);
                }

                //Passing over top pivot cuts line
                if ((_swingDir > 0 && controller.transform.position.x < pivotPoints[0].x) || (_swingDir <0 && controller.transform.position.x> pivotPoints[0].x))
                {
                    _lineRender.enabled         = false;
                    grappleSpriteRender.enabled = false;
                    _grappleState = GrappleState.Cooldown;
                }

                //Exits to UnWrap except for special case
                if (controller.transform.position.y < curPivot.y)
                {
                    _swingDir *= -1;
                    _wrap      = Wrapping.UnWrap;

                    if (_specialFloatExit)
                    {
                        _wrap             = Wrapping.Wrap;
                        _specialFloatExit = false;
                    }
                }
                break;
                #endregion
            }


            //Update player linerender point
            _lineRender.SetPosition(pivotPoints.Count - 1, controller.transform.position);
            //_lineRender.SetPosition(_pivotPoints.Count, controller.transform.position);

            //Cancel grapple swing
            //
            if (controller.grounded || InputController.Instance.Jump.Down || InputController.Instance.Ability.Down || controller.sidecollide || controller.ceiling)
            {
                _lineRender.enabled         = false;
                grappleSpriteRender.enabled = false;
                _grappleState = GrappleState.Cooldown;
            }

            break;

            #endregion
            #region Cooldown State
        case GrappleState.Cooldown:
            if (_grappleTimer > 0)
            {
                _grappleTimer -= Time.deltaTime;
            }
            else
            {
                ResetGrapple();
            }
            break;
            #endregion
        }
    }
        internal WriterStyle()
        {
            _wrapping = Wrapping.Wrap;
            _alignment = Alignment.Left;
            _fontName = String.Empty;
            _fontColor = Color.Empty;
            _fontSize = FontSize.Normal;
            _bold = false;
            _italic = false;

            _format = true;
            _layout = true;
        }
예제 #20
0
 public override bool AllowsTokenCreates()
 {
     return(Wrapping.allowsTokenCreates());
 }
예제 #21
0
        public override void Render(HtmlMobileTextWriter writer)
        {
            // Invalid text writers are not supported in this Adapter.
            if (!(writer is DesignerTextWriter))
            {
                return;
            }

            Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];
            byte      templateStatus;
            int       maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus);
            String    width    = DesignerAdapterUtil.GetWidth(Control);

            if (Control.ImageUrl.Length == 0)
            {
                if (Control.Format == CommandFormat.Button)
                {
                    if (maxWidth == 0 && templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_NONEDIT)
                    {
                        maxWidth = DesignerAdapterUtil.CONTROL_MAX_WIDTH_IN_TEMPLATE;
                    }

                    if (maxWidth == 0 && DesignerAdapterUtil.InMobileUserControl(Control))
                    {
                        maxWidth = Constants.ControlMaxsizeAtToplevel;
                    }

                    if (maxWidth == 0)
                    {
                        // Render will be called a second time for which maxWidth != 0
                        return;
                    }

                    String additionalStyle = null;
                    String controlText     = Control.Text;
                    String commandCaption;
                    int    requiredWidth = 0;

                    DesignerTextWriter twTmp;
                    twTmp = new DesignerTextWriter();
                    twTmp.WriteBeginTag("input");
                    twTmp.WriteStyleAttribute(Style, null);
                    twTmp.WriteAttribute("type", "submit");
                    twTmp.Write(" value=\"");
                    twTmp.WriteText(controlText, true);
                    twTmp.Write("\"/>");
                    String htmlFragment = twTmp.ToString();

                    MSHTMLHostUtil.ApplyStyle(String.Empty, String.Empty, null);
                    requiredWidth = MSHTMLHostUtil.GetHtmlFragmentWidth(htmlFragment);

                    ((DesignerTextWriter)writer).EnterZeroFontSizeTag();
                    writer.WriteBeginTag("div");
                    if (requiredWidth + SAFETY_MARGIN > maxWidth)
                    {
                        if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
                        {
                            int tmpRequiredWidth, allowedLength;
                            int captionLength = controlText.Length;
                            twTmp = new DesignerTextWriter();
                            twTmp.WriteBeginTag("input");
                            twTmp.WriteStyleAttribute(Style, null);
                            twTmp.WriteAttribute("type", "submit");
                            twTmp.WriteAttribute("value", "{0}");
                            twTmp.Write("/>");
                            htmlFragment = twTmp.ToString();
                            // At least 10 characters can fit into the caption of the command
                            for (allowedLength = (captionLength < 10 ? captionLength : 10); allowedLength <= captionLength; allowedLength++)
                            {
                                tmpRequiredWidth = MSHTMLHostUtil.GetHtmlFragmentWidth(String.Format(CultureInfo.CurrentCulture, htmlFragment, HttpUtility.HtmlEncode(controlText.Substring(0, allowedLength))));
                                if (tmpRequiredWidth + SAFETY_MARGIN > maxWidth)
                                {
                                    break;
                                }
                            }
                            commandCaption = controlText.Substring(0, allowedLength - 1);
                        }
                        else
                        {
                            commandCaption = controlText;
                        }
                    }
                    else
                    {
                        writer.WriteAttribute("style", "width:" + width);
                        commandCaption = controlText;
                    }

                    if (alignment != Alignment.NotSet)
                    {
                        writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment));
                    }
                    writer.Write(">");

                    writer.EnterLayout(Style);

                    writer.WriteBeginTag("input");
                    if (requiredWidth + SAFETY_MARGIN > maxWidth)
                    {
                        additionalStyle = String.Format(CultureInfo.CurrentCulture, "width:{0};", width);
                    }
                    ((DesignerTextWriter)writer).WriteStyleAttribute(Style, additionalStyle);
                    writer.WriteAttribute("type", "submit");

                    writer.Write(" value=\"");
                    writer.WriteText(commandCaption, true);
                    writer.Write("\"/>");

                    writer.ExitLayout(Style);
                }
                else
                {
                    Wrapping wrapping = (Wrapping)Style[Style.WrappingKey, true];
                    bool     wrap     = (wrapping == Wrapping.Wrap || wrapping == Wrapping.NotSet);

                    ((DesignerTextWriter)writer).EnterZeroFontSizeTag();
                    writer.WriteBeginTag("div");

                    if (!wrap)
                    {
                        if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
                        {
                            width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px";
                        }
                        writer.WriteAttribute("style", "overflow-x:hidden;width:" + width);
                    }
                    else
                    {
                        writer.WriteAttribute("style", "word-wrap:break-word;width:" + width);
                    }

                    if (alignment != Alignment.NotSet)
                    {
                        writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment));
                    }
                    writer.Write(">");

                    writer.WriteBeginTag("a");
                    writer.WriteAttribute("href", "NavigationUrl");
                    writer.Write(">");
                    ((DesignerTextWriter)writer).WriteCssStyleText(Style, null, Control.Text, true);
                    writer.WriteEndTag("a");
                }
                writer.WriteEndTag("div");
                ((DesignerTextWriter)writer).ExitZeroFontSizeTag();
            }
            else
            {
                if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT)
                {
                    width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px";
                }

                writer.WriteBeginTag("div");
                if (alignment == Alignment.Center)
                {
                    writer.WriteAttribute("align", "center");
                }
                writer.WriteAttribute("style", "overflow-x:hidden;width:" + width);
                writer.Write(">");

                writer.WriteBeginTag("img");
                ((DesignerTextWriter)writer).WriteStyleAttribute(Style);
                writer.WriteAttribute("src", Control.ImageUrl, true);

                // center alignment not part of HTML for images.
                if (alignment == Alignment.Right ||
                    alignment == Alignment.Left)
                {
                    writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment));
                }

                writer.WriteAttribute("border", "0");
                writer.Write(">");
                writer.WriteEndTag("div");
            }
        }
예제 #22
0
 public override bool AllowsSchemaWrites()
 {
     return(Original.allowsSchemaWrites() && Wrapping.allowsSchemaWrites());
 }
 internal DivStyleTag(int level) : base(level)
 {
     _wrapping = Wrapping.Wrap;
     _alignment = Alignment.Left;
     _alignWritten = false;
 }
예제 #24
0
 internal DivStyleTag(int level) : base(level)
 {
     _wrapping     = Wrapping.Wrap;
     _alignment    = Alignment.Left;
     _alignWritten = false;
 }
예제 #25
0
 public override string Name()
 {
     return(Original.name() + " overridden by " + Wrapping.name());
 }
예제 #26
0
 public override bool AllowsSchemaWrites()
 {
     return(Wrapping.allowsSchemaWrites());
 }
예제 #27
0
 public override bool AllowsPropertyReads(int propertyKey)
 {
     return(Original.allowsPropertyReads(propertyKey) && Wrapping.allowsPropertyReads(propertyKey));
 }
 bool DoWrap(Wrapping wrapping, AstNode wrapNode, int argumentCount)
 {
     return wrapping == Wrapping.WrapAlways ||
         options.WrapLineLength > 0 && argumentCount > 1 && wrapping == Wrapping.WrapIfTooLong && wrapNode.StartLocation.Column >= options.WrapLineLength;
 }
예제 #29
0
 public override string Name()
 {
     return(Original.name() + " restricted to " + Wrapping.name());
 }
        /// <include file='doc\HtmlSelectionListAdapter.uex' path='docs/doc[@for="HtmlSelectionListAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            MobileListItemCollection items      = Control.Items;
            ListSelectType           selectType = Control.SelectType;

            if (items.Count == 0 &&
                selectType != ListSelectType.ListBox &&
                selectType != ListSelectType.MultiSelectListBox)
            {
                return;
            }

            int    selectedIndex = Control.SelectedIndex;
            String renderName;

            if (Device.RequiresAttributeColonSubstitution)
            {
                renderName = Control.UniqueID.Replace(':', ',');
            }
            else
            {
                renderName = Control.UniqueID;
            }

            switch (selectType)
            {
            case ListSelectType.DropDown:
            case ListSelectType.ListBox:
            case ListSelectType.MultiSelectListBox:

                if (items.Count == 0 && !Device.CanRenderEmptySelects)
                {
                    break;
                }

                writer.EnterLayout(Style);
                writer.WriteBeginTag("select");

                if (selectType == ListSelectType.MultiSelectListBox)
                {
                    writer.Write(" multiple");
                }

                if (selectType == ListSelectType.ListBox || selectType == ListSelectType.MultiSelectListBox)
                {
                    writer.WriteAttribute("size", Control.Rows.ToString(CultureInfo.InvariantCulture));
                }

                writer.WriteAttribute("name", renderName);
                writer.Write(">");

                for (int itemIndex = 0; itemIndex < items.Count; itemIndex++)
                {
                    MobileListItem item = items[itemIndex];
                    writer.WriteBeginTag("option");
                    WriteItemValueAttribute(writer, itemIndex, item.Value);
                    if (item.Selected && (Control.IsMultiSelect || itemIndex == selectedIndex))
                    {
                        writer.Write(" selected>");
                    }
                    else
                    {
                        writer.Write(">");
                    }
                    writer.WriteEncodedText(item.Text);
                    writer.WriteLine("");
                }
                writer.Write("</select>");

                if (Device.HidesRightAlignedMultiselectScrollbars &&
                    selectType == ListSelectType.MultiSelectListBox)
                {
                    // nested if for perf
                    if ((Alignment)Style[Style.AlignmentKey, true] == Alignment.Right)
                    {
                        writer.Write("&nbsp;&nbsp;&nbsp;&nbsp;");
                    }
                }
                writer.WriteLine("");

                if (!Page.DesignMode)
                {
                    writer.ExitLayout(Style, Control.BreakAfter);
                }
                else
                {
                    writer.ExitLayout(Style, false);
                }
                break;

            case ListSelectType.Radio:
            case ListSelectType.CheckBox:

                String selectTypeString =
                    (selectType == ListSelectType.Radio) ?
                    "radio" :
                    "checkbox";
                Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];
                if (!Device.Tables || alignment == Alignment.Left || alignment == Alignment.NotSet)
                {
                    writer.EnterStyle(Style);
                    bool breakAfter = false;
                    for (int itemIndex = 0; itemIndex < items.Count; itemIndex++)
                    {
                        if (breakAfter)
                        {
                            writer.WriteBreak();
                        }
                        MobileListItem item = items[itemIndex];

                        writer.WriteBeginTag("input");
                        writer.WriteAttribute("type", selectTypeString);
                        writer.WriteAttribute("name", renderName);
                        WriteItemValueAttribute(writer, itemIndex, item.Value);
                        if (item.Selected &&
                            (Control.IsMultiSelect || itemIndex == selectedIndex) &&
                            Device.SupportsUncheck)
                        {
                            writer.Write(" checked>");
                        }
                        else
                        {
                            writer.Write(">");
                        }
                        writer.WriteEncodedText(item.Text);
                        breakAfter = true;
                    }
                    writer.ExitStyle(Style, Control.BreakAfter);
                }
                else     // Device supports tables and alignment is non default.
                {
                    Wrapping wrapping = (Wrapping)Style[Style.WrappingKey, true];
                    bool     nowrap   = (wrapping == Wrapping.NoWrap);

                    writer.EnterLayout(Style);
                    writer.WriteFullBeginTag("table");
                    writer.BeginStyleContext();
                    for (int itemIndex = 0; itemIndex < items.Count; itemIndex++)
                    {
                        MobileListItem item = items[itemIndex];
                        writer.WriteFullBeginTag("tr");
                        writer.WriteBeginTag("td");
                        if (nowrap)
                        {
                            writer.WriteAttribute("nowrap", "true");
                        }
                        writer.Write(">");

                        writer.WriteBeginTag("input");
                        writer.WriteAttribute("type", selectTypeString);
                        writer.WriteAttribute("name", renderName);
                        WriteItemValueAttribute(writer, itemIndex, item.Value);
                        if (item.Selected &&
                            (Control.IsMultiSelect || itemIndex == selectedIndex) &&
                            Device.SupportsUncheck)
                        {
                            writer.Write(" checked>");
                        }
                        else
                        {
                            writer.Write(">");
                        }

                        writer.MarkStyleContext();
                        writer.EnterFormat(Style);
                        writer.WriteEncodedText(item.Text);
                        writer.ExitFormat(Style);
                        writer.UnMarkStyleContext();
                        writer.WriteEndTag("td");
                        writer.WriteEndTag("tr");
                    }
                    writer.WriteEndTag("table");
                    writer.EndStyleContext();
                    writer.ExitFormat(Style, Control.BreakAfter);
                }
                break;
            }
        }
        internal WriterStyle(Style style)
        {
            Debug.Assert(style != null, "writer style is null");
            _alignment = (Alignment)         style[Style.AlignmentKey, true];
            if(_alignment == Alignment.NotSet)
            {
                _alignment = Alignment.Left;
            }
            _wrapping = (Wrapping)           style[Style.WrappingKey, true];
            if(_wrapping == Wrapping.NotSet)
            {
                _wrapping = Wrapping.Wrap;
            }

            _fontSize  = (FontSize)         style[Style.FontSizeKey , true];
            if(_fontSize == FontSize.NotSet)
            {
                _fontSize = FontSize.Normal;
            }
            _fontName  = (String)           style[Style.FontNameKey , true];
            _fontColor = (Color)            style[Style.ForeColorKey, true]; 

            _bold = ((BooleanOption)        style[Style.BoldKey, true] == BooleanOption.True);
            _italic = ((BooleanOption)      style[Style.ItalicKey, true] == BooleanOption.True);

            _format = true;
            _layout = true;

        }
예제 #32
0
 bool DoWrap(Wrapping wrapping, AstNode wrapNode, int argumentCount)
 {
     return(wrapping == Wrapping.WrapAlways ||
            options.WrapLineLength > 0 && argumentCount > 1 && wrapping == Wrapping.WrapIfTooLong && wrapNode.StartLocation.Column >= options.WrapLineLength);
 }
예제 #33
0
 public override bool AllowsReads()
 {
     return(Wrapping.allowsReads());
 }
예제 #34
0
        /// <include file='doc\HtmlListAdapter.uex' path='docs/doc[@for="HtmlListAdapter.RenderList"]/*' />
        protected virtual void RenderList(HtmlMobileTextWriter writer)
        {
            MobileListItemCollection items = Control.Items;
            Wrapping wrap = Style.Wrapping; // used for tables, no decoration case.

            if (items.Count == 0)
            {
                return;
            }

            int pageStart = Control.FirstVisibleItemIndex;
            int pageSize  = Control.VisibleItemCount;

            // Determine what markup to use.

            String         listSuffix, itemPrefix, itemSuffix;
            ListDecoration decoration  = Control.Decoration;
            bool           insideStyle = true;

            // We know that for table tag, outer style doesn't carry over
            // into inside tags so style state needs to be reset.
            // For other cases, we enter the style here once and exit at the
            // end once.
            if (decoration != ListDecoration.None || !Device.Tables)
            {
                writer.EnterStyle(Style);
                insideStyle = false;
            }

            switch (decoration)
            {
            case ListDecoration.Bulleted:
                writer.WriteLine("<ul>");
                listSuffix = "</ul>";
                itemPrefix = "<li>";
                itemSuffix = "</li>";

                if (!Device.RendersBreaksAfterHtmlLists)
                {
                    listSuffix += "<br>";
                }
                break;

            case ListDecoration.Numbered:
                if (pageStart == 0)
                {
                    writer.WriteLine("<ol>");
                }
                else
                {
                    writer.Write("<ol start=\"");
                    writer.Write(pageStart + 1);
                    writer.WriteLine("\">");
                }
                listSuffix = "</ol>";
                itemPrefix = "<li>";
                itemSuffix = "</li>";

                if (!Device.RendersBreaksAfterHtmlLists)
                {
                    listSuffix += "<br>";
                }
                break;

            default:
                if (Device.Tables)
                {
                    listSuffix     = "</table>";
                    Style.Wrapping = Wrapping.NotSet;
                    writer.EnterLayout(Style);
                    writer.WriteLine("<table>");
                    if (wrap == Wrapping.NoWrap)
                    {
                        itemPrefix = "<tr nowrap><td>";
                    }
                    else
                    {
                        itemPrefix = "<tr><td>";
                    }
                    itemSuffix = "</td></tr>";
                }
                else
                {
                    listSuffix = String.Empty;
                    itemPrefix = String.Empty;
                    itemSuffix = "<br>";
                }
                break;
            }

            bool hasCmdHandler = Control.HasItemCommandHandler;

            for (int i = 0; i < pageSize; i++)
            {
                MobileListItem item = items[pageStart + i];
                writer.Write(itemPrefix);

                if (insideStyle)
                {
                    writer.BeginStyleContext();
                    writer.EnterFormat(Style);
                }

                if (Control.ItemsAsLinks)
                {
                    RenderBeginLink(writer, item.Value);
                }
                else if (hasCmdHandler)
                {
                    writer.WriteBeginTag("a");
                    RenderPostBackEventAsAttribute(writer, "href", item.Index.ToString(CultureInfo.InvariantCulture));
                    writer.Write(">");
                }
                writer.WriteEncodedText(item.Text);

                if (hasCmdHandler || Control.ItemsAsLinks)
                {
                    RenderEndLink(writer);
                }

                if (insideStyle)
                {
                    writer.ExitFormat(Style);
                    writer.EndStyleContext();
                }
                writer.WriteLine(itemSuffix);
            }

            if (listSuffix == null || listSuffix.Length > 0)
            {
                writer.WriteLine(listSuffix);
            }

            if (decoration != ListDecoration.None || !Device.Tables)
            {
                writer.ExitStyle(Style);
            }
            else
            {
                writer.ExitLayout(Style);
                Style.Wrapping = wrap;
            }
        }
예제 #35
0
 public override bool AllowsReads()
 {
     return(Original.allowsReads() && Wrapping.allowsReads());
 }
 /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlLayout.WmlLayout1"]/*' />
 public WmlLayout(Alignment alignment, Wrapping wrapping)
 {
     Align = alignment;
     Wrap = wrapping;
 }
예제 #37
0
 public override bool AllowsTokenCreates()
 {
     return(Original.allowsTokenCreates() && Wrapping.allowsTokenCreates());
 }