Inheritance: MonoSingleton
Exemplo n.º 1
0
        //----------------------------------------------------------------------
        public Button( Screen _screen, ButtonStyle _style, string _strText = "", Texture2D _iconTex = null, Anchor _anchor = Anchor.Center, string _strTooltipText="", object _tag=null )
            : base(_screen)
        {
            Style = _style;

            mPadding    = new Box(5, 0);
            mMargin     = new Box(0);

            mLabel          = new Label( _screen );

            mIcon           = new Image( _screen );
            mIcon.Texture   = _iconTex;
            mIcon.Padding   = new Box( Style.VerticalPadding, 0, Style.VerticalPadding, Style.HorizontalPadding );

            Text            = _strText;
            TextColor       = Screen.Style.DefaultTextColor;

            Anchor          = _anchor;

            mPressedAnim    = new SmoothValue( 1f, 0f, 0.2f );
            mPressedAnim.SetTime( mPressedAnim.Duration );

            mTooltip        = new Tooltip( Screen, "" );

            TooltipText     = _strTooltipText;
            Tag             = _tag;

            UpdateContentSize();
        }
Exemplo n.º 2
0
 public static Point ToAbsolute(Anchor anchor, Point point, Rectangle rect)
 {
     switch (anchor)
     {
         case Anchor.TopLeft:
             point.Offset(rect.Left, rect.Top);
             break;
         case Anchor.TopCenter:
             point.Offset(rect.Left + (rect.Width / 2), rect.Top);
             break;
         case Anchor.TopRight:
             point.Offset(rect.Right, rect.Top);
             break;
         case Anchor.MiddleLeft:
             point.Offset(rect.Left, rect.Top + (rect.Height / 2));
             break;
         case Anchor.MiddleCenter:
             point.Offset(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2));
             break;
         case Anchor.MiddleRight:
             point.Offset(rect.Right, rect.Top + (rect.Height / 2));
             break;
         case Anchor.BottomLeft:
             point.Offset(rect.Left, rect.Bottom);
             break;
         case Anchor.BottomCenter:
             point.Offset(rect.Left + (rect.Width / 2), rect.Bottom);
             break;
         case Anchor.BottomRight:
             point.Offset(rect.Right, rect.Bottom);
             break;
     }
     return point;
 }
Exemplo n.º 3
0
 protected void MakeBooleanAt( Anchor horAnchor, Anchor verAnchor, Font font, bool initValue,
     int width, int height, int x, int y)
 {
     WidgetConstructors.MakeBooleanAt( game, widgets, ref widgetIndex,
                                      horAnchor, verAnchor, font, initValue,
                                      width, height, x, y, null );
 }
Exemplo n.º 4
0
        public ModelDisplayWidget(SpriteBatch spriteBatch, string bg, int p_3, int p_4, int p_5, int p_6, Anchor anchor_2)
            : base(spriteBatch, bg, p_3, p_4, p_5, p_6, anchor_2)
        {
            camera = new Camera();

            BoundingSphere sphere = new BoundingSphere();
            float scale;
            /*Debug.WriteLine("Hey" + (
                (body.Left - (SettingsManager.GetInstance().ResolutionX/2.0f))
                / SettingsManager.GetInstance().ResolutionX));*/
            //translationAndScale = Matrix.Multiply(Matrix.CreateTranslation(translation), Matrix.CreateScale(new Vector3(0.5f,0.5f,0.5f)));

            //BoundingSphere will give us the size of the model, so we can scale accordingly
            foreach (ModelMesh mesh in myModel.Meshes)
            {
                if (sphere.Radius == 0)
                    sphere = mesh.BoundingSphere;
                else
                    sphere = BoundingSphere.
                             CreateMerged(sphere, mesh.BoundingSphere);
            }
            Debug.WriteLine(sphere.Radius);
            scale = 2.0f / sphere.Radius;
            translationAndScale = Matrix.Multiply(Matrix.CreateTranslation(translation), Matrix.CreateScale(new Vector3(scale, scale, scale)));
        }
Exemplo n.º 5
0
 protected void MakeButtonAt( string text, int width, int height, Font font, Anchor horAnchor,
     Anchor verAnchor, int x, int y)
 {
     WidgetConstructors.MakeButtonAt( game, widgets, ref widgetIndex,
                                     text, width, height, font, horAnchor,
                                     verAnchor, x, y, null );
 }
Exemplo n.º 6
0
	// ************************************************************************
	public static Vector2 GetScreenPointFromAnchor(Anchor anchor)
	{
		switch (anchor)
		{

		case Anchor.TOP_LEFT :
			return new Vector2 ( 0.0f,				Screen.height );
		case Anchor.TOP :
			return new Vector2 ( Screen.width / 2,	Screen.height );
		case Anchor.TOP_RIGHT :
			return new Vector2 ( Screen.width,		Screen.height );

		case Anchor.LEFT :
			return new Vector2 ( 0.0f,				Screen.height / 2 );
		case Anchor.CENTER :
			return new Vector2 ( Screen.width / 2,	Screen.height / 2 );
		case Anchor.RIGHT :
			return new Vector2 ( Screen.width,		Screen.height / 2 );

		case Anchor.BOTTOM_LEFT :
			return new Vector2 ( 0.0f,				0 );
		case Anchor.BOTTOM :
			return new Vector2 ( Screen.width / 2,	0 );
		case Anchor.BOTTOM_RIGHT :
			return new Vector2 ( Screen.width,		0 );

		default :

			return Vector2.zero;
		}
	}
Exemplo n.º 7
0
        /// <summary>
        /// Creates a new widget with desired background texture.
        /// </summary>
        public Widget(SpriteBatch spriteBatch, String background, int offsetX, int parentX, int offsetY, int parentY, Anchor anchor)
            : this(spriteBatch)
        {
            this.background = AssetManager.GetInstance().getAsset<Texture2D>(background);

            BuildBody(this.background.Width, this.background.Height, offsetX, parentX, offsetY, parentY, anchor);
        }
 public Sprite(Texture2D texture, Vector2 position, Anchor anchor)
 {
     this.mTexture = texture;
     switch (anchor)
     {
         case Anchor.TOPLEFT:
             this.mCenter.X = position.X + texture.Width / 2;
             this.mCenter.Y = position.Y + texture.Height / 2;
             break;
         case Anchor.TOPRIGHT:
             this.mCenter.X = position.X - texture.Width / 2;
             this.mCenter.Y = position.Y + texture.Height / 2;
             break;
         case Anchor.CENTER:
             this.mCenter = position;
             break;
         case Anchor.BOTTOMLEFT:
             this.mCenter.X = position.X + texture.Width / 2;
             this.mCenter.Y = position.Y - texture.Height / 2;
             break;
         case Anchor.BOTTOMRIGHT:
             this.mCenter.X = position.X - texture.Width / 2;
             this.mCenter.Y = position.Y - texture.Height / 2;
             break;
     }
     this.mPosition.X = mCenter.X - mTexture.Width / 2;
     this.mPosition.Y = mCenter.Y - mTexture.Height / 2;
 }
Exemplo n.º 9
0
        public MultiOptionSelector(AssetManager assets, string themeName, Vector2 position, Anchor anchor, List<Option> options, MultiOptionArrangement arrangement, Cursor cursor, int initialValue)
            : base(themeName, position, initialValue)
        {
            //process arrangement
            if (arrangement == MultiOptionArrangement.ListX)
                arrangement = new MultiOptionArrangement(options.Count, 1);
            if (arrangement == MultiOptionArrangement.ListY)
                arrangement = new MultiOptionArrangement(1, options.Count);
            this.arrangement = arrangement;

            TextDictionary assetDictionary = new TextDictionary(assets.GetText("selector"));
            //load themes
            string cursorTheme = assetDictionary.LookupString(themeName, "cursorTheme");
            string optionTheme = assetDictionary.LookupString(themeName, "optionTheme");
            Anchor justify = Anchor.Center;
            bool justifySuccess = assetDictionary.CheckPropertyExists(themeName, "justify");
            if (justifySuccess)
            {
                string justifyString = assetDictionary.LookupString(themeName, "justify");
                if (justifyString == "Left")
                    justify = Anchor.CenterLeft;
                else if (justifyString == "Right")
                    justify = Anchor.CenterRight;
            }
            //position components
            cursor.Initialize(options, assets, cursorTheme);
            Vector2 individualSize = Vector2.Zero;
            for (int i = 0; i < options.Count; i++)
            {
                options[i].Initialize(assets, optionTheme);
                if (options[i].Dimensions.X > individualSize.X)
                    individualSize.X = options[i].Dimensions.X;
                if (options[i].Dimensions.Y > individualSize.Y)
                    individualSize.Y = options[i].Dimensions.Y;
            }
            for (int i = 0; i < options.Count; i++)
                options[i].Position = (individualSize + cursor.Spacing * Vector2.One) * arrangement.GetPosition(i);
            Vector2 overallSize = new Vector2(arrangement.Columns * (individualSize.X + cursor.Spacing) - cursor.Spacing, arrangement.Rows * (individualSize.Y + cursor.Spacing) - cursor.Spacing);
            for (int i = 0; i < options.Count; i++)
            {
                Vector2 p = options[i].Position;
                if (justify == Anchor.TopCenter || justify == Anchor.Center || justify == Anchor.BottomCenter)
                    p.X += (individualSize.X - options[i].Dimensions.X) / 2;
                else if (justify == Anchor.TopRight || justify == Anchor.CenterRight || justify == Anchor.BottomRight)
                    p.X += individualSize.X - options[i].Dimensions.X;
                if (justify == Anchor.CenterLeft || justify == Anchor.Center || justify == Anchor.CenterRight)
                    p.Y += (individualSize.Y - options[i].Dimensions.Y) / 2;
                else if (justify == Anchor.BottomLeft || justify == Anchor.BottomCenter || justify == Anchor.BottomRight)
                    p.Y += individualSize.Y - options[i].Dimensions.Y;
                options[i].Position = p;
            }
            this.Position -= GraphicsHelper.ComputeAnchorOrigin(anchor, overallSize / GraphicsConstants.VIEWPORT_DIMENSIONS);
            this.options = options;
            this.cursor = cursor;
            //initialize position
            Vector2 initialPosition = arrangement.GetPosition(IntValue);
            x = (int)initialPosition.X;
            y = (int)initialPosition.Y;
            cursor.Update(IntValue);
        }
        public AnimatedSprite(Animation animation, Vector2 position, Anchor anchor)
        {
            this.animation = animation;
            int width = animation.FrameWidth;
            int height = animation.FrameHeight;

            switch (anchor)
            {
                case Anchor.TOPLEFT:
                    this.mCenter.X = position.X + width / 2;
                    this.mCenter.Y = position.Y + height / 2;
                    break;
                case Anchor.TOPRIGHT:
                    this.mCenter.X = position.X - width / 2;
                    this.mCenter.Y = position.Y + height / 2;
                    break;
                case Anchor.CENTER:
                    this.mCenter = position;
                    break;
                case Anchor.BOTTOMLEFT:
                    this.mCenter.X = position.X + width / 2;
                    this.mCenter.Y = position.Y - height / 2;
                    break;
                case Anchor.BOTTOMRIGHT:
                    this.mCenter.X = position.X - width / 2;
                    this.mCenter.Y = position.Y - height / 2;
                    break;
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// 添加链接点
 /// </summary>
 /// <param name="Content">链接文字</param>
 /// <param name="FontSize">字体大小</param>
 /// <param name="Name">链接点名</param>
 public void AddAnchorName(string Content, float FontSize, string Name)
 {
     SetFont(FontSize);
     Anchor auc = new Anchor(Content, font);
     auc.Name = Name;
     document.Add(auc);
 }
Exemplo n.º 12
0
 protected void MakeInput( string text, int width, Anchor horAnchor, Anchor verAnchor,
     bool password, int x, int y, int maxChars, string hint)
 {
     WidgetConstructors.MakeInput( game, widgets, ref widgetIndex,
                                  text, width, horAnchor, verAnchor,
                                  inputFont, inputHintFont, null,
                                  password, x, y, maxChars, hint );
 }
 public void DrawAt( IDrawer2D drawer, string text, Font font,
     Anchor horAnchor, Anchor verAnchor, int width, int height, int x, int y)
 {
     ButtonWidth = width; ButtonHeight = height;
     Width = width; Height = height;
     CalculateOffset( x, y, horAnchor, verAnchor );
     Redraw( drawer, text, font );
 }
Exemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of <see cref="Page"/>.
 /// </summary>
 /// <param name="id">Initializes the required <see cref="Id"/>.</param>
 /// <param name="title">Initializes the required <see cref="Title"/>.</param>
 /// <param name="isHome">Initializes the required <see cref="IsHome"/>.</param>
 /// <param name="anchor">Initializes the required <see cref="Anchors"/>.</param>
 /// <param name="content">Initializes the required <see cref="Content"/>.</param>
 public Page(string id, string title, bool isHome, Anchor[] anchor, string content)
 {
     this.Id = id;
     this.Title = title;
     this.IsHome = isHome;
     this.Anchors = anchor;
     this.Content = content;
 }
Exemplo n.º 15
0
 private void bind(PropertyItem propertyItem, RadioButton btnTopLeft, Anchor anchor)
 {
     BindingOperations.SetBinding(btnTopLeft, ToggleButton.IsCheckedProperty, LambdaBinding.New(
         new Binding("Value") { Source = propertyItem, Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay },
         (object source) => { return (Anchor) source == anchor; },
         (bool source) => { return source ? anchor : Binding.DoNothing; }
     ));
 }
Exemplo n.º 16
0
 ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action<Game, ButtonWidget> onClick,
     Func<Game, string> getter, Action<Game, string> setter)
 {
     ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre, vDocking, titleFont, onClick );
     widget.GetValue = getter;
     widget.SetValue = setter;
     return widget;
 }
 public static new ChatTextWidget Create( Game game, int x, int y, string text, Anchor horizontal, Anchor vertical, Font font )
 {
     ChatTextWidget widget = new ChatTextWidget( game, font );
     widget.Init();
     widget.HorizontalAnchor = horizontal; widget.VerticalAnchor = vertical;
     widget.XOffset = x; widget.YOffset = y;
     widget.SetText( text );
     return widget;
 }
Exemplo n.º 18
0
        //----------------------------------------------------------------------
        public BoxGroup( Screen _screen, Orientation _orientation, int _iSpacing, Anchor _contentAnchor = Anchor.Center )
            : base(_screen)
        {
            mlExpandedChildren = new List<bool>();

            mOrientation    = _orientation;
            miSpacing       = _iSpacing;
            mContentAnchor = _contentAnchor;
        }
Exemplo n.º 19
0
 /// <summary>
 /// A menu widget needs everything a normal widget has plus a title for the menu
 /// </summary>
 /// SpriteBatch spriteBatch, String background, int offsetX, int parentX, int offsetY, int parentY, Anchor anchor
 public MenuWidget(SpriteBatch spriteBatch, String background, String name, int offsetX, int parentX, int offsetY, int parentY, Anchor anchor)
     : base(spriteBatch, background, offsetX, parentX, offsetY, parentY, anchor)
 {
     this.title = name;
     this.titleBW = new TextButtonWidget(spriteBatch, name, HandleWidgetInput, offsetX, parentX, offsetY, parentY, Widget.Anchor.TOP_CENTER);
     this.menuItems = new List<TextButtonWidget>();
     this.titleFont = fontHeader;
     this.numItems = 0;
 }
 public void attachRuler(Anchor anchor)
 {
     // when we attach the specified anchor, rotate it according to the orientation of the owner brick
     anchor.rotate(mOwnerBrick.Orientation);
     // then notify the ruler of the attachment
     anchor.AttachedRuler.attachControlPointToBrick(anchor.AttachedPointIndex, mOwnerBrick);
     // and add the anchor in the attachment list
     mAnchors.Add(anchor);
 }
Exemplo n.º 21
0
        public void ValidStartDateTest()
        {
            Anchor target = new Anchor();
            DateTime expected = DateTime.UtcNow;
            target.ValidStartDate = expected;
            DateTime actual = target.ValidStartDate;
            Assert.Equal(expected, actual);

        }
Exemplo n.º 22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Ext.IsAjaxRequest)
                return;

            int spClientChannelID = Convert.ToInt32(this.Request.QueryString["ChannleClientID"]);

            SPClientChannelSettingWrapper settingWrapper = SPClientChannelSettingWrapper.FindById(spClientChannelID);

            this.hidChannelClientID.Text = settingWrapper.Id.ToString();

            this.txtChannelName.Text = settingWrapper.Name;

            this.txtChannelSubmitUrl.Text = settingWrapper.ChannelID.InterfaceUrl;

            this.lblChannelCode.Text = settingWrapper.ChannelCode;

            List<SPChannelParamsWrapper> channelParamsWrappers = settingWrapper.ChannelID.GetAllEnableParams();

            foreach (SPChannelParamsWrapper spChannelParamsWrapper in channelParamsWrappers)
            {
                Anchor anchor = new Anchor();
                anchor.Horizontal = "95%";
                TextField txt = new TextField();
                txt.ID = "txt" + spChannelParamsWrapper.Name;
                txt.FieldLabel = spChannelParamsWrapper.Name;

                if (spChannelParamsWrapper.ParamsMappingName == "linkid")
                {
                    txt.Value = "99999" +StringUtil.GetRandNumber(15);

                    hidLinkIDeName.Text = txt.ClientID;
                }

                if (spChannelParamsWrapper.ParamsMappingName == "mobile")
                {
                    txt.Value = "135" + StringUtil.GetRandNumber(8);

                    hidMobileName.Text = txt.ClientID;
                }

                if (spChannelParamsWrapper.ParamsMappingName == "cpid")
                {
                    if (!string.IsNullOrEmpty(settingWrapper.ChannelCode))
                        txt.Value = settingWrapper.ChannelCode;
                }

                if (spChannelParamsWrapper.ParamsMappingName == "ywid")
                {
                    if (!string.IsNullOrEmpty(settingWrapper.CommandCode))
                        txt.Value = settingWrapper.CommandCode;
                }

                anchor.Items.Add(txt);
                this.FormLayout1.Anchors.Add(anchor);
            }
        }
Exemplo n.º 23
0
        protected void CalculateOffset( int x, int y, Anchor horAnchor, Anchor verAnchor )
        {
            if( horAnchor == Anchor.LeftOrTop ) X = x;
            else if( horAnchor == Anchor.Centre ) X = x + Window.Width / 2 - Width / 2;
            else if( horAnchor == Anchor.BottomOrRight ) X = x + Window.Width - Width;

            if( verAnchor == Anchor.LeftOrTop ) Y = y;
            else if( verAnchor == Anchor.Centre ) Y = y + Window.Height / 2 - Height / 2;
            else if( verAnchor == Anchor.BottomOrRight ) Y = y + Window.Height - Height;
        }
Exemplo n.º 24
0
        public void DrawAt( IDrawer2D drawer, string text, Font font,
            Anchor horAnchor, Anchor verAnchor, int x, int y)
        {
            DrawTextArgs args = new DrawTextArgs( text, font, true );
            Size size = drawer.MeasureSize( ref args );
            Width = size.Width; Height = size.Height;

            CalculateOffset( x, y, horAnchor, verAnchor );
            Redraw( drawer, text, font );
        }
Exemplo n.º 25
0
 public TextGroupWidget( Game game, int elementsCount, Font font, 
     Font underlineFont, Anchor horAnchor, Anchor verAnchor)
     : base(game)
 {
     ElementsCount = elementsCount;
     this.font = font;
     this.underlineFont = underlineFont;
     HorizontalAnchor = horAnchor;
     VerticalAnchor = verAnchor;
 }
Exemplo n.º 26
0
        public void SetDrawData( IDrawer2D drawer, string text, Font font,
            Anchor horAnchor, Anchor verAnchor, int x, int y)
        {
            DrawTextArgs args = new DrawTextArgs( text, font, true );
            Size size = drawer.MeasureSize( ref args );
            Width = size.Width; Height = size.Height;

            CalculateOffset( x, y, horAnchor, verAnchor );
            Text = text;
            this.font = font;
        }
Exemplo n.º 27
0
 public ParallaxBackground(AssetManager assets, Texture2D texture, Vector2 initialOffset, Vector2 velocity, float dist, float scale, Anchor anchor, Vector2 repeat)
 {
     this.texture = texture;
     this.dist = dist;
     this.initialOffset = initialOffset - (GraphicsHelper.ComputeAnchorOrigin(anchor, new Vector2(texture.Width, texture.Height) / GraphicsConstants.VIEWPORT_DIMENSIONS)) + GraphicsHelper.ComputeAnchorOrigin(anchor, Vector2.One);
     this.anchor = anchor;
     this.velocity = velocity;
     this.scale = scale;
     this.repeatX = repeat.X != 0;
     this.repeatY = repeat.Y != 0;
 }
Exemplo n.º 28
0
 /// <summary>
 /// Creates a new sprite instance.
 /// </summary>
 /// <param name="texture">The texture associated with the sprite.</param>
 /// <param name="position">The position at which the sprite should be drawn.</param>
 /// <param name="scale">The scale at which the sprite should be drawn.</param>
 public Sprite(AnimatedTexture texture, Vector2 position, Vector2 scale)
 {
     Texture = texture;
     this.position = position;
     this.scale = scale;
     anchor = Anchor.Center;
     ticksPerFrame = 1;
     looped = true;
     color = Color.White;
     animationCurveStack = new List<AnimationCurve>(10);
 }
Exemplo n.º 29
0
        public Tower(Texture2D texture, Vector2 pPosition, Anchor a, int cost, int upgradeCost, int range, int damage, float fire_reload)
            : base(texture, pPosition, a)
        {
            this.cost = cost;
            this.upgradeCost = upgradeCost;
            this.mRange = range;
            this.mDamage = damage;
            this.mFireReload = fire_reload;

            this.level = 1;
            this.layer_depth = 0.5f;
        }
Exemplo n.º 30
0
        protected void OnValidate()
        {
            if(target != null)
            {
                if(owner.type != target.type)
                {
                    Debug.LogWarning(string.Format("Nodify: Anchors of type: {0} and type: {1} cannot be connected!", owner.type, target.type));

                    target = null;
                }
            }
        }
        /// <summary>
        /// The Unity Update method.
        /// </summary>
        public void Update()
        {
            // Exit the app when the 'back' button is pressed.
            if (Input.GetKey(KeyCode.Escape))
            {
                Application.Quit();
            }

            // Only allow the screen to sleep when not tracking.
            if (Session.Status != SessionStatus.Tracking)
            {
                Screen.sleepTimeout = SleepTimeout.SystemSetting;
            }
            else
            {
                Screen.sleepTimeout = SleepTimeout.NeverSleep;
            }

            // Get updated augmented images for this frame.
            Session.GetTrackables <AugmentedImage>(
                m_TempAugmentedImages, TrackableQueryFilter.Updated);

            // Create visualizers and anchors for updated augmented images that are tracking and do
            // not previously have a visualizer. Remove visualizers for stopped images.
            foreach (var image in m_TempAugmentedImages)
            {
                AugmentedImageVisualizer visualizer = null;
                m_Visualizers.TryGetValue(image.DatabaseIndex, out visualizer);
                if (image.TrackingState == TrackingState.Tracking && visualizer == null)
                {
                    if (newP)
                    {
                        // Create an anchor to ensure that ARCore keeps tracking this augmented image.
                        Anchor anchor = image.CreateAnchor(image.CenterPose);
                        visualizer = (AugmentedImageVisualizer)Instantiate(
                            AugmentedImageVisualizerPrefab, anchor.transform);
                        visualizer.Image = image;
                        visualizer.GetComponent <DragonShooter>().starting = true;
                        visualizer.GetComponent <DragonShooter>().targ     = targe.transform;
                        m_Visualizers.Add(image.DatabaseIndex, visualizer);
                        newP = false;
                    }
                }
                else if (image.TrackingState == TrackingState.Stopped && visualizer != null)
                {
                    m_Visualizers.Remove(image.DatabaseIndex);
                    GameObject.Destroy(visualizer.gameObject);
                }
            }

            // Show the fit-to-scan overlay if there are no images that are Tracking.
            foreach (var visualizer in m_Visualizers.Values)
            {
                if (visualizer.Image.TrackingState == TrackingState.Tracking)
                {
                    FitToScanOverlay.SetActive(false);
                    FitToScanOverlay1.SetActive(true);
                    return;
                }
            }

            FitToScanOverlay.SetActive(true);
        }
Exemplo n.º 32
0
        public void PurchaseRocket()
        {
            App.NavigationService.Navigate("http://demos.bellatrix.solutions/");

            // 2. Create methods accept a generic parameter the type of the web control. Then only the methods for this specific control are accessible.
            // Here we tell BELLATRIX to find your element by name attribute ending with 'orderby'.
            Select sortDropDown = App.ElementCreateService.CreateByNameEndingWith <Select>("orderby");

            // 3. You can select from select inputs by text (SelectByText) or index (SelectByIndex)).
            // Also, you can get the selected option through GetSelected method.
            //    <select name="orderby" class="orderby">
            //       <option value="popularity" selected="selected">Sort by popularity</option>
            //       <option value="rating">Sort by average rating</option>
            //       <option value="date">Sort by newness</option>
            //       <option value="price">Sort by price: low to high</option>
            //       <option value="price-desc">Sort by price: high to low</option>
            //    </select>
            sortDropDown.SelectByText("Sort by price: low to high");

            // 4. Here BELLATRIX finds the first anchor element which has inner text containing the 'Read more' text.
            // <a href='http://demos.bellatrix.solutions/product/proton-m/'>Read more</a>
            Anchor protonMReadMoreButton = App.ElementCreateService.CreateByInnerTextContaining <Anchor>("Read more");

            // 5. You can Hover and Focus on most web elements. Also, can invoke Click on anchors.
            protonMReadMoreButton.Hover();

            // 6. Locate elements by custom attribute. Also, bellow BELLATRIX waits till the anchor is clickable before doing any actions.
            // <a href="/?add-to-cart=28" data-product_id="28">Add to cart</a>
            Anchor addToCartFalcon9 = App.ElementCreateService.CreateByAttributesContaining <Anchor>("data-product_id", "28").ToBeClickable();

            addToCartFalcon9.Focus();
            addToCartFalcon9.Click();

            // 7. Find the anchor by class 'added_to_cart wc-forward' and wait for the element again to be clickable.
            // <a href="http://demos.bellatrix.solutions/cart/" class="added_to_cart wc-forward" title="View cart">View cart</a>
            Anchor viewCartButton = App.ElementCreateService.CreateByClassContaining <Anchor>("added_to_cart wc-forward").ToBeClickable();

            viewCartButton.Click();

            // 8. Find a regular input text element by id = 'coupon_code'.
            TextField couponCodeTextField = App.ElementCreateService.CreateById <TextField>("coupon_code");

            // 9. Instead of using vanilla WebDriver SendKeys to set the text, use the SetText method.
            couponCodeTextField.SetText("happybirthday");

            // 10. Create a button control by value attribute containing the text 'Apply coupon'.
            // <input type="submit" class="button" name="apply_coupon" value="Apply coupon">
            // Button can be any of the following web elements- input button, input submit or button.
            Button applyCouponButton = App.ElementCreateService.CreateByValueContaining <Button>("Apply coupon");

            applyCouponButton.Click();

            Div messageAlert = App.ElementCreateService.CreateByClassContaining <Div>("woocommerce-message");

            // 11. Wait for the message DIV to show up and have some content.
            // <div class="woocommerce-message" role="alert">Coupon code applied successfully.</div>
            messageAlert.ToHasContent().ToBeVisible().WaitToBe();

            // 12. Sometimes you need to verify the content of some element. However, since the asynchronous nature of websites,
            // the text or event may not happen immediately. This makes the simple Assert methods + vanilla WebDriver useless.
            // The commented code fails 1 from 5 times.
            ////Assert.AreEqual("Coupon code applied successfully.", messageAlert.InnerText);

            // To handle these situations, BELLATRIX has hundreds of Validate methods that wait for some condition to happen before asserting.
            // Bellow the statement waits for the specific text to appear and assert it.
            // Note: There are much more details about these methods in the next chapters.
            messageAlert.ValidateInnerTextIs("Coupon code applied successfully.");

            // 13. Find the number element by class 'input-text qty text'.
            // <input type="number" id="quantity_5ad35e76b34a2" step="1" min="0" max="" value="1" size="4" pattern="[0-9]*" inputmode="numeric">
            Number quantityBox = App.ElementCreateService.CreateByClassContaining <Number>("input-text qty text");

            // 14. For numbers elements, you can set the number and get most of the properties of these elements.
            App.BrowserService.WaitForAjax();

            Span totalSpan = App.ElementCreateService.CreateByXpath <Span>("//*[@class='order-total']//span");

            // 15. The same as the case with the DIV here we wait/assert for the total price SPAN to get updated.
            ////Assert.AreEqual("114.00€", totalSpan.InnerText);
            totalSpan.ValidateInnerTextIs("54.00€", 15000);

            Anchor proceedToCheckout = App.ElementCreateService.CreateByClassContaining <Anchor>("checkout-button button alt wc-forward");

            proceedToCheckout.Click();

            // 16. As mentioned before, BELLATRIX has special synchronisation mechanism for locating elements, so usually, there is no need to wait for specific
            // elements to appear on the page. However, there may be some rare cases when you need to do it.
            // Bellow the statement finds the heading by its inner text containing the text 'Billing details'.
            Heading billingDetailsHeading = App.ElementCreateService.CreateByInnerTextContaining <Heading>("Billing details");

            // Wait for the heading with the above text to be visible. This means that the correct page is loaded.
            billingDetailsHeading.ToBeVisible().WaitToBe();

            Anchor showLogin = App.ElementCreateService.CreateByInnerTextContaining <Anchor>("Click here to login");

            // 17. All web controls have multiple properties for their most important attributes and Validate methods for their verification.
            ////Assert.AreEqual("http://demos.bellatrix.solutions/checkout/#", showLogin.Href);
            showLogin.ValidateHrefIs("http://demos.bellatrix.solutions/checkout/#");
            ////Assert.AreEqual("showlogin", showLogin.CssClass);
            showLogin.ValidateCssClassIs("showlogin");

            TextArea orderCommentsTextArea = App.ElementCreateService.CreateById <TextArea>("order_comments");

            // 18. Here we find the order comments text area and since it is below the visible area we scroll down
            // so that it gets visible on the video recordings. Then the text is set.
            orderCommentsTextArea.ScrollToVisible();
            orderCommentsTextArea.SetText("Please send the rocket to my door step! And don't use the elevator, they don't like when it is not clean...");

            TextField billingFirstName = App.ElementCreateService.CreateById <TextField>("billing_first_name");

            billingFirstName.SetText("In");

            TextField billingLastName = App.ElementCreateService.CreateById <TextField>("billing_last_name");

            billingLastName.SetText("Deepthought");

            TextField billingCompany = App.ElementCreateService.CreateById <TextField>("billing_company");

            billingCompany.SetText("Automate The Planet Ltd.");

            Select billingCountry = App.ElementCreateService.CreateById <Select>("billing_country");

            billingCountry.SelectByText("Bulgaria");

            TextField billingAddress1 = App.ElementCreateService.CreateById <TextField>("billing_address_1");

            // 19. Through the Placeholder, you can get the default text of the control.
            Assert.AreEqual("House number and street name", billingAddress1.Placeholder);
            billingAddress1.SetText("bul. Yerusalim 5");

            TextField billingAddress2 = App.ElementCreateService.CreateById <TextField>("billing_address_2");

            billingAddress2.SetText("bul. Yerusalim 6");

            TextField billingCity = App.ElementCreateService.CreateById <TextField>("billing_city");

            billingCity.SetText("Sofia");

            Select billingState = App.ElementCreateService.CreateById <Select>("billing_state").ToBeVisible().ToBeClickable();

            billingState.SelectByText("Sofia-Grad");

            TextField billingZip = App.ElementCreateService.CreateById <TextField>("billing_postcode");

            billingZip.SetText("1000");

            Phone billingPhone = App.ElementCreateService.CreateById <Phone>("billing_phone");

            // 20. Create the special text field control Phone it contains some additional properties unique for this web element.
            billingPhone.SetPhone("+00359894646464");

            Email billingEmail = App.ElementCreateService.CreateById <Email>("billing_email");

            // 21. Here we create the special text field control Email it contains some additional properties unique for this web element.
            billingEmail.SetEmail("*****@*****.**");

            CheckBox createAccountCheckBox = App.ElementCreateService.CreateById <CheckBox>("createaccount");

            // 22. You can check and uncheck checkboxes.
            createAccountCheckBox.Check();

            // 23. Bellow BELLATRIX finds the first RadioButton with attribute 'for' containing the value 'payment_method_cheque'.
            RadioButton checkPaymentsRadioButton = App.ElementCreateService.CreateByAttributesContaining <RadioButton>("for", "payment_method_cheque");

            // The radio buttons compared to checkboxes cannot be unchecked/unselected.
            checkPaymentsRadioButton.Click();
        }
Exemplo n.º 33
0
        protected void settingList_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            DBViewTagSetting setting = e.Item.DataItem as DBViewTagSetting;

            if (setting != null)
            {
                Img icon = e.Item.FindControl("icon") as Img;
                icon.Src = CommonExtension.IdentityIcon((int)setting.Id);//TagId);


                Anchor     tagName  = (Anchor)e.Item.FindControl("tagName");
                SmartLabel userType = (SmartLabel)e.Item.FindControl("userType");
                SmartLabel userMemo = (SmartLabel)e.Item.FindControl("memo");
                tagName.Text = setting.HostName;

                HostTagGroupStatus tagUser = HostTagGroupStatus.SelectByTagId((int)setting.Id);//.TagId);
                int groupId = 0;
                if (tagUser != null)
                {
                    groupId       = tagUser.HostGroupId;
                    userType.Text = BusTagUserType.GetTagUserTypeName(tagUser.HostGroupId);
                    userMemo.Text = tagUser.Description;
                }
                tagName.Href = PathUtil.ResolveUrl(string.Format("/TagUsers/TagUser.aspx?id={0}&type={1}",
                                                                 setting.HostId, groupId));

                SmartLabel idSelection  = (SmartLabel)e.Item.FindControl("idSelection");
                string     disableOrNot = this.IsLocatingServiceAvailable ? "" : " disabled=\"disabled\"";
                idSelection.Text = "<input type=\"checkbox\" name=\"selection\"" + disableOrNot + " onclick=\"javascript:Locating.selectTag(this);\" value=\"" + setting.Id + "\" />";//setting.TagId + "\" />";


                if (setting.CommandState == null)
                {
                    return;     // <-----------------If never been configured ----------------------------------------------
                }

                SmartLabel    commandState = (SmartLabel)e.Item.FindControl("commandState");
                DateTimeLabel startTime    = (DateTimeLabel)e.Item.FindControl("startTime");
                Anchor        operate      = (Anchor)e.Item.FindControl("operate");

                switch ((LocatingCommandState)setting.CommandState)
                {
                case LocatingCommandState.WaitToStart:
                    operate.Text      = "N/A";
                    operate.CssClass  = "t3";
                    commandState.Text = "请求开始中";
                    commandState.Style.Add("color", "Green");
                    break;

                case LocatingCommandState.WaitToStop:
                    operate.Text      = "N/A";
                    operate.CssClass  = "t3";
                    commandState.Text = "请求停止中";
                    commandState.Style.Add("color", "Red");
                    break;

                default:
                case LocatingCommandState.Executed:
                    if (setting.WorkingStatus == (byte)TagWorkingStatus.Locating)
                    {
                        operate.Text           = "停止";
                        operate.Href           = "javascript:Locating.quickStop(" + setting.Id + ");"; //setting.TagId + ");";
                        startTime.DisplayValue = (DateTime)setting.UpdateTime;
                    }
                    else
                    {
                        operate.Text    = "快速启动";
                        operate.ToolTip = "按照已设定参数快速启动";
                        operate.Href    = "javascript:Locating.quickStart(" + setting.Id + ");"; //setting.TagId + ");";
                    }
                    operate.Attributes["id"] = "op_" + setting.Id;                               //setting.TagId;
                    break;
                }

                if (!this.IsLocatingServiceAvailable)
                {
                    operate.Text     = "N/A";
                    operate.Href     = null;
                    operate.CssClass = "t3";
                    operate.ToolTip  = "系统未检测到LocatingServer运行。";
                }
            }
        }
        /// <summary>
        /// The Unity Update() method.
        /// </summary>
        ///

        public void Update()
        {
            _QuitOnConnectionErrors();

            TrackableHitFlag raycastFilter = TrackableHitFlag.PlaneWithinBounds | TrackableHitFlag.PlaneWithinPolygon;

            // The tracking state must be FrameTrackingState.Tracking in order to access the Frame.
            if (Frame.TrackingState != FrameTrackingState.Tracking)
            {
                const int LOST_TRACKING_SLEEP_TIMEOUT = 15;
                Screen.sleepTimeout = LOST_TRACKING_SLEEP_TIMEOUT;
                return;
            }

            Screen.sleepTimeout = SleepTimeout.NeverSleep;
            Frame.GetNewPlanes(ref m_newPlanes);

            // Iterate over planes found in this frame and instantiate corresponding GameObjects to visualize them.
            for (int i = 0; i < m_newPlanes.Count; i++)
            {
                // Instantiate a plane visualization prefab and set it to track the new plane. The transform is set to
                // the origin with an identity rotation since the mesh for our prefab is updated in Unity World
                // coordinates.
                GameObject planeObject = Instantiate(m_trackedPlanePrefab, Vector3.zero, Quaternion.identity,
                                                     transform);
                planeObject.GetComponent <TrackedPlaneVisualizer>().SetTrackedPlane(m_newPlanes[i]);

                // Apply a random color and grid rotation.
                planeObject.GetComponent <Renderer>().material.SetColor("_GridColor", m_planeColors[Random.Range(0,
                                                                                                                 m_planeColors.Length - 1)]);
                planeObject.GetComponent <Renderer>().material.SetFloat("_UvRotation", Random.Range(0.0f, 360.0f));
            }

            // Disable the snackbar UI when no planes are valid.
            bool showSearchingUI = true;

            Frame.GetAllPlanes(ref m_allPlanes);
            for (int i = 0; i < m_allPlanes.Count; i++)
            {
                if (m_allPlanes[i].IsValid)
                {
                    showSearchingUI = false;
                    break;
                }
            }

            m_searchingForPlaneUI.SetActive(showSearchingUI);


            if (Input.touchCount == 1 && objectRendered)
            {
                TrackableHit myHit;
                Touch        mytouch = Input.GetTouch(0);

                if (mytouch.phase == TouchPhase.Stationary || mytouch.phase == TouchPhase.Moved)
                {
                    if (Session.Raycast(m_firstPersonCamera.ScreenPointToRay(mytouch.position), raycastFilter, out myHit))
                    {
                        andyObject.transform.position = Vector3.Lerp(andyObject.transform.position, myHit.Point, Time.deltaTime);
                    }
                }
            }

            if (Input.touchCount >= 1 && !objectSelected && objectRendered)
            {
                RaycastHit myHit;
                Touch      myTouch = Input.GetTouch(0);
                Ray        ray     = m_firstPersonCamera.ScreenPointToRay(myTouch.position);
                if (Physics.Raycast(ray, out myHit, Mathf.Infinity))
                {
                }
            }


            if (Input.touchCount == 2)
            {
                if (!rotating)
                {
                    startVector = Input.GetTouch(1).position - Input.GetTouch(0).position;
                    rotating    = startVector.sqrMagnitude > rotGestureWidth * rotGestureWidth;
                }

                else
                {
                    var currVector  = Input.GetTouch(1).position - Input.GetTouch(0).position;
                    var angleOffset = Vector2.Angle(startVector, currVector);
                    var LR          = Vector3.Cross(startVector, currVector);
                    andyObject.transform.Rotate(0, 2.5f, 0);
                }
            }

            else
            {
                rotating = false;
            }



            TrackableHit hit;
            Touch        touch;

            if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began)
            {
                return;
            }



            if (Session.Raycast(m_firstPersonCamera.ScreenPointToRay(touch.position), raycastFilter, out hit) && objectSelected)
            {
                objectRendered = true;
                objectSelected = false;
                // Create an anchor to allow ARCore to track the hitpoint as understanding of the physical
                // world evolves.
                anchor = Session.CreateAnchor(hit.Point, Quaternion.identity);

                // Intanstiate an Andy Android object as a child of the anchor; it's transform will now benefit
                // from the anchor's tracking.
                andyObject = Instantiate(m_andyAndroidPrefab, hit.Point, Quaternion.identity,
                                         anchor.transform);

                // Andy should look at the camera but still be flush with the plane.
                andyObject.transform.LookAt(m_firstPersonCamera.transform);
                andyObject.transform.rotation = Quaternion.Euler(0.0f,
                                                                 andyObject.transform.rotation.eulerAngles.y, andyObject.transform.rotation.z);


                // Use a plane attachment component to maintain Andy's y-offset from the plane
                // (occurs after anchor updates).
                andyObject.GetComponent <PlaneAttachment>().Attach(hit.Plane);
            }

            anchor.transform.Rotate(Vector3.right * Time.deltaTime, Space.World);
        }
Exemplo n.º 35
0
        void Start()
        {
            _anchor = GetComponent <Anchor>();

            _initScaleVector = scaleTarget.transform.localScale;
        }
Exemplo n.º 36
0
 public void Enqueue(Anchor anchor)
 {
     _queue.Enqueue(anchor);
     _observers.ForEach(observer => observer.OnNext(anchor));
 }
Exemplo n.º 37
0
 public static bool IsLeft(this Anchor a)
 {
     return(a == Anchor.Left || a == Anchor.TopLeft || a == Anchor.BottomLeft);
 }
Exemplo n.º 38
0
 public bool TryDequeue(out Anchor uri)
 {
     return(_queue.TryDequeue(out uri));
 }
Exemplo n.º 39
0
 public static bool IsMiddleX(this Anchor a)
 {
     return(a == Anchor.Top || a == Anchor.Center || a == Anchor.Bottom);
 }
Exemplo n.º 40
0
 public Connection(Anchor source, Anchor target)
 {
     Source = source;
     Target = target;
 }
Exemplo n.º 41
0
    // Update is called once per frame
    void Update()
    {
        if (detectedPlane == null)
        {
            return;
        }

        if (detectedPlane.TrackingState != TrackingState.Tracking)
        {
            return;
        }

        // Check for the plane being subsumed
        // If the plane has been subsumed switch attachment to the subsuming plane.
        while (detectedPlane.SubsumedBy != null)
        {
            detectedPlane = detectedPlane.SubsumedBy;
        }

        if (foodInstance == null || foodInstance.activeSelf == false)
        {
            SpawnFoodInstance();
            return;
        }

        foodAge += Time.deltaTime;
        if (foodAge >= maxAge)
        {
            Destroy(foodInstance);
            foodInstance = null;
        }

        void SpawnFoodInstance()
        {
            GameObject foodItem = foodModels[Random.Range(0, foodModels.Length)];

            // Pick a location.  This is done by selecting a vertex at random and then
            // a random point between it and the center of the plane.
            List <Vector3> vertices = new List <Vector3>();

            detectedPlane.GetBoundaryPolygon(vertices);
            Vector3 pt       = vertices[Random.Range(0, vertices.Count)];
            float   dist     = Random.Range(0.05f, 1f);
            Vector3 position = Vector3.Lerp(pt, detectedPlane.CenterPose.position, dist);

            // Move the object above the plane.
            position.y += .05f;


            Anchor anchor = detectedPlane.CreateAnchor(new Pose(position, Quaternion.identity));

            foodInstance = Instantiate(foodItem, position, Quaternion.identity,
                                       anchor.transform);

            // Set the tag.
            foodInstance.tag = "food";

            foodInstance.transform.localScale = new Vector3(.025f, .025f, .025f);
            foodInstance.transform.SetParent(anchor.transform);
            foodAge = 0;

            foodInstance.AddComponent <FoodMotion>();
        }
    }
Exemplo n.º 42
0
        async public static void MethodSnippets()
        {
            LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout Name"));
            Layout            layout     = await QueuedTask.Run(() => layoutItem.GetLayout());

            Element element = layout.FindElement("Group Element");


            #region Element_ConvertToGraphics
            //Convert a legend to a graphic and move the Title to the bottom of the legend and also move
            //the label in the contents pane to the bottom of the list.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                Legend leg          = layout.FindElement("Legend") as Legend;
                GroupElement result = leg.ConvertToGraphics().First() as GroupElement;
                Element firstElm    = result.Elements.First(); //Note: Bottom element is first in drawing order.
                foreach (Element elm in result.Elements)
                {
                    if (elm.Name == "Title")
                    {
                        elm.SetY(firstElm.GetY() - 0.25);          //Move title below other legend elements
                        elm.SetTOCPositionAbsolute(result, false); // Move Title item in TOC to bottom as well
                    }
                }
            });

            #endregion Element_ConvertToGraphics

            #region Element_GetSetAnchor
            //Change the element's anchor position

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                Anchor elmAnchor = element.GetAnchor();
                elmAnchor        = Anchor.CenterPoint;

                element.SetAnchor(elmAnchor); //You don't have to get to set; a shortcut would be: element.SetAnchor(Anchor.CenterPoint);
            });

            #endregion Element_GetSetAnchor

            #region Element_GetCustomProperty
            //Get a custom property that has been previously set.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                String custProp = element.GetCustomProperty("MyKeyString");
            });

            #endregion Element_GetCustomProperty

            #region Element_GetSetDefinition
            //Modify an element's CIM properties.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                CIMElement CIMElm = element.GetDefinition();

                //Modify a CIM value

                element.SetDefinition(CIMElm);
            });

            #endregion Element_GetSetDefinition

            #region Element_GetSetHeight
            //Modify an element's hieght.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                double elmHeight = element.GetHeight();
                elmHeight        = 11;

                element.SetHeight(elmHeight); //You don't have to get to set; a shortcut would be: element.SetHieght(11);
            });

            #endregion Element_GetSetHeight

            #region Element_SetLocked
            //Modify an element's locked state if it isn't already

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                if (!element.IsLocked)
                {
                    element.SetLocked(true);
                }
            });

            #endregion Element_GetSetLocked

            #region Element_GetSetLockedAspectRatio
            //Modify an element's aspect ratio.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                bool elmLocked = element.GetLockedAspectRatio();
                elmLocked      = false;                  //Turn off the locked state.

                element.SetLockedAspectRatio(elmLocked); //You don't have to get to set; a shortcut would be: element.SetLockedAspectRatio(false);
            });

            #endregion Element_GetSetLockedAspectRatio

            #region Element_GetSetRotation
            //Modify and element's rotation value.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                double elmRot = element.GetRotation();
                elmRot        = 22.5;

                element.SetRotation(elmRot); //You don't have to get to set; a shortcut would be: element.SetRotation(22.5);
            });

            #endregion Element_GetSetRotation

            #region Element_GetSetWidth
            //Modify an element's width.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                double elmWidth = element.GetWidth();
                elmWidth        = 8.5;

                element.SetWidth(elmWidth); //You don't have to get to set; a shortcut would be: element.SetWidth(8.5);
            });

            #endregion Element_GetSetWidth

            #region Element_GetSetX
            //Modify an element's X position.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                double elmX = element.GetX();
                elmX        = 4.25;

                element.SetX(elmX); //You don't have to get to set; a shortcut would be: element.SetX(4.25);
            });

            #endregion Element_GetSetX

            #region Element_GetSetY
            //Modify an element's Y position.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                double elmY = element.GetY();
                elmY        = 5.5;

                element.SetY(elmY); //You don't have to get to set; a shortcut would be: element.SetY(5.5);
            });

            #endregion Element_GetSetY

            #region Element_SetCustomProperty
            //Set a custom property on an element.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                element.SetCustomProperty("MyKeyString", "MyValueString");
            });

            #endregion Element_SetCustomProperty

            #region Element_SetName
            //Modify an element's name.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                element.SetName("New Name");
            });

            #endregion Element_SetName

            #region Element_SetTOCPositionAbsolute
            //Move an element to the top of the TOC

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                element.SetTOCPositionAbsolute(layout, true);
            });

            #endregion Element_SetTOCPositionAbsolute

            #region Element_SetTOCPositionRelative
            //Move a layout element above an existing layout element.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                element.SetTOCPositionRelative(element, true);
            });

            #endregion Element_SetTOCPositionRelative

            #region Element_SetVisible
            //Modify an element's visibility.

            //Perform on the worker thread
            await QueuedTask.Run(() =>
            {
                element.SetVisible(true); //Turn it on / make visible.
            });

            #endregion Element_SetVisible
        }
    public void CopyFrom(tk2dSpriteCollectionDefinition src)
    {
        name                = src.name;
        disableTrimming     = src.disableTrimming;
        disableInnerPadding = src.disableInnerPadding;
        scale               = src.scale;
        texture             = src.texture;
        materialId          = src.materialId;
        anchor              = src.anchor;
        anchorX             = src.anchorX;
        anchorY             = src.anchorY;
        overrideMesh        = src.overrideMesh;

        doubleSidedSprite    = src.doubleSidedSprite;
        customSpriteGeometry = src.customSpriteGeometry;
        geometryIslands      = src.geometryIslands;

        dice       = src.dice;
        diceUnitX  = src.diceUnitX;
        diceUnitY  = src.diceUnitY;
        diceFilter = src.diceFilter;
        pad        = src.pad;

        source           = src.source;
        fromSpriteSheet  = src.fromSpriteSheet;
        hasSpriteSheetId = src.hasSpriteSheetId;
        spriteSheetX     = src.spriteSheetX;
        spriteSheetY     = src.spriteSheetY;
        spriteSheetId    = src.spriteSheetId;
        extractRegion    = src.extractRegion;
        regionX          = src.regionX;
        regionY          = src.regionY;
        regionW          = src.regionW;
        regionH          = src.regionH;
        regionId         = src.regionId;

        colliderType    = src.colliderType;
        boxColliderMin  = src.boxColliderMin;
        boxColliderMax  = src.boxColliderMax;
        polyColliderCap = src.polyColliderCap;

        colliderColor  = src.colliderColor;
        colliderConvex = src.colliderConvex;
        colliderSmoothSphereCollisions = src.colliderSmoothSphereCollisions;

        extraPadding = src.extraPadding;

        colliderData = new List <ColliderData>(src.colliderData.Count);
        foreach (ColliderData srcCollider in src.colliderData)
        {
            ColliderData data = new ColliderData();
            data.CopyFrom(srcCollider);
            colliderData.Add(data);
        }

        if (src.polyColliderIslands != null)
        {
            polyColliderIslands = new tk2dSpriteColliderIsland[src.polyColliderIslands.Length];
            for (int i = 0; i < polyColliderIslands.Length; ++i)
            {
                polyColliderIslands[i] = new tk2dSpriteColliderIsland();
                polyColliderIslands[i].CopyFrom(src.polyColliderIslands[i]);
            }
        }
        else
        {
            polyColliderIslands = new tk2dSpriteColliderIsland[0];
        }

        if (src.geometryIslands != null)
        {
            geometryIslands = new tk2dSpriteColliderIsland[src.geometryIslands.Length];
            for (int i = 0; i < geometryIslands.Length; ++i)
            {
                geometryIslands[i] = new tk2dSpriteColliderIsland();
                geometryIslands[i].CopyFrom(src.geometryIslands[i]);
            }
        }
        else
        {
            geometryIslands = new tk2dSpriteColliderIsland[0];
        }

        attachPoints = new List <tk2dSpriteDefinition.AttachPoint>(src.attachPoints.Count);
        foreach (tk2dSpriteDefinition.AttachPoint srcAp in src.attachPoints)
        {
            tk2dSpriteDefinition.AttachPoint ap = new tk2dSpriteDefinition.AttachPoint();
            ap.CopyFrom(srcAp);
            attachPoints.Add(ap);
        }
    }
        public static ATHCompositeColor Create(ATHComposite parent, Vector2 position, Vector2 size, Color color, Anchor anchor = Anchor.topleft, int order = 0)
        {
            ATHCompositeColor ath = new ATHCompositeColor(parent, position, size, color, anchor, order);

            parent.game.Components.Add(ath);
            parent.Add(ath);
            return(ath);
        }
Exemplo n.º 45
0
 /// <summary>
 /// Create the radio button.
 /// </summary>
 /// <param name="text">Radio button label text.</param>
 /// <param name="anchor">Position anchor.</param>
 /// <param name="size">Radio button size.</param>
 /// <param name="offset">Offset from anchor position.</param>
 /// <param name="isChecked">If true, radio button will be created as checked.</param>
 public RadioButton(string text, Anchor anchor = Anchor.Auto, Vector2?size = null, Vector2?offset = null, bool isChecked = false) :
     base(text, anchor, size, offset, isChecked)
 {
     UpdateStyle(DefaultStyle);
     TextParagraph.UpdateStyle(DefaultParagraphStyle);
 }
 public ATHCompositeColor(ATH parent, Vector2 position, Vector2 size, Color color, Anchor anchor = Anchor.topleft, int order = 0) : base(parent, position, size, anchor, order)
 {
     this.color = color;
 }
Exemplo n.º 47
0
        public static string ToDescriptionString(this Anchor val)
        {
            var attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false);

            return(attributes.Length > 0 ? attributes[0].Description : string.Empty);
        }
 public ImageResizerTransform(IHostEnvironment env, string inputColumn, string outputColumn,
                              int imageWidth, int imageHeight, ResizingKind resizing = ResizingKind.IsoCrop, Anchor cropAnchor = Anchor.Center)
     : this(env, new ColumnInfo(inputColumn, outputColumn, imageWidth, imageHeight, resizing, cropAnchor))
 {
 }
Exemplo n.º 49
0
 public InlineButton(IconUsage icon, Anchor anchor)
 {
     this.icon   = icon;
     this.anchor = anchor;
 }
            public ColumnInfo(string input, string output, int width, int height, ResizingKind scale, Anchor anchor)
            {
                Contracts.CheckNonEmpty(input, nameof(input));
                Contracts.CheckNonEmpty(output, nameof(output));
                Contracts.CheckUserArg(width > 0, nameof(Column.ImageWidth));
                Contracts.CheckUserArg(height > 0, nameof(Column.ImageHeight));
                Contracts.CheckUserArg(Enum.IsDefined(typeof(ResizingKind), scale), nameof(Column.Resizing));
                Contracts.CheckUserArg(Enum.IsDefined(typeof(Anchor), anchor), nameof(Column.CropAnchor));

                Input  = input;
                Output = output;
                Width  = width;
                Height = height;
                Scale  = scale;
                Anchor = anchor;
                Type   = new ImageType(Height, Width);
            }
Exemplo n.º 51
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            switch (displayMode)
            {
            case "Menu":
                _elmDefault = new Table();
                _elmDefault.SetAttribute("mscui:controltype", ControlType);

                _elmDefaultTbody           = new TableBody();
                _elmDefaultTbody.ClassName = "ms-cui-it";
                _elmDefault.SetAttribute("cellspacing", "0");
                _elmDefault.SetAttribute("cellpadding", "0");
                _elmDefaultTbody.SetAttribute("cellspacing", "0");
                _elmDefaultTbody.SetAttribute("cellpadding", "0");

                _elmDefault.MouseOut += OnControlMouseOut;

                EnsureDivArrays();

                TableRow  elmRow;
                TableCell elmCell;
                Anchor    elmCellA;
                Div       elmDiv;
                Div       elmDivOuter;
                int       idx = 0;
                for (int i = 0; i < 10; i++)
                {
                    elmRow = new TableRow();
                    _elmDefaultTbody.AppendChild(elmRow);
                    for (int j = 0; j < 10; j++)
                    {
                        elmCell = new TableCell();
                        elmCell.Style.Padding = "0px";
                        elmRow.AppendChild(elmCell);

                        elmCellA = new Anchor();

                        Utility.NoOpLink(elmCellA);
                        Utility.SetAriaTooltipProperties(Properties, elmCellA);

                        elmCellA.Focus  += OnCellFocus;
                        elmDiv           = new Div();
                        elmDiv.ClassName = "ms-cui-it-inactiveCell";

                        elmDivOuter           = new Div();
                        elmDivOuter.Id        = this.Id + "-" + idx;
                        elmDivOuter.ClassName = "ms-cui-it-inactiveCellOuter";

                        elmCell.MouseOver += OnCellHover;
                        elmCell.Click     += OnCellClick;
                        elmCell.AppendChild(elmDivOuter);
                        elmDivOuter.AppendChild(elmDiv);
                        elmDiv.AppendChild(elmCellA);

                        _innerDivs[idx] = elmDiv;
                        _outerDivs[idx] = elmDivOuter;
                        idx++;
                    }
                }

                _elmDefault.AppendChild(_elmDefaultTbody);
                return(_elmDefault);

            default:
                EnsureValidDisplayMode(displayMode);
                break;
            }
            return(null);
        }
        public void Update()
        {
            // Exit the app when the 'back' button is pressed.
            if (Input.GetKey(KeyCode.Escape))
            {
                Application.Quit();
            }

            // Check that motion tracking is tracking.
            if (Session.Status != SessionStatus.Tracking)
            {
                return;
            }

            // Get updated augmented images for this frame.
            Session.GetTrackables <AugmentedImage>(m_TempAugmentedImages, TrackableQueryFilter.Updated);

            // Create visualizers and anchors for updated augmented images that are tracking and do not previously
            // have a visualizer. Remove visualizers for stopped images.
            foreach (var image in m_TempAugmentedImages)
            {
                AugmentedImageVisualizer visualizer = null;
                m_Visualizers.TryGetValue(image.DatabaseIndex, out visualizer);
                if (image.TrackingState == TrackingState.Tracking && visualizer == null)
                {
                    AugmentedImageVisualizerPrefab.gameObject.SetActive(true);
                    // Create an anchor to ensure that ARCore keeps tracking this augmented image.
                    Anchor anchor = image.CreateAnchor(image.CenterPose);
                    visualizer       = (AugmentedImageVisualizer)Instantiate(AugmentedImageVisualizerPrefab, anchor.transform);
                    visualizer.Image = image;
                    m_Visualizers.Add(image.DatabaseIndex, visualizer);
                    fitFlag = false;
                }
                else if (image.TrackingState == TrackingState.Stopped && visualizer != null)
                {
                    m_Visualizers.Remove(image.DatabaseIndex);
                    GameObject.Destroy(visualizer.gameObject);
                    fitFlag = false;
                }
            }

            // Show the fit-to-scan overlay if there are no images that are Tracking.
            foreach (var visualizer in m_Visualizers.Values)
            {
                if (visualizer.Image.TrackingState == TrackingState.Tracking)
                {
                    FitToScanOverlay.SetActive(false);
                    return;
                }
            }

            if (!fitFlag)
            {
                fitTime = Time.time;
                fitFlag = true;
            }


            if ((Time.time >= 30) && fitTime != 0)
            {
                SceneManager.LoadScene("AugmentedImage");
            }
            else
            {
                FitToScanOverlay.SetActive(true);
            }
        }
Exemplo n.º 53
0
 public static bool IsBottom(this Anchor a)
 {
     return(a == Anchor.BottomLeft || a == Anchor.Bottom || a == Anchor.BottomRight);
 }
Exemplo n.º 54
0
        public static MemoryStream MS_InformeViajes(string nroTransporte, string transportista, string nombreOrigen, string destinos, string tracto, string trailer, string nroContenedor, string conductor, string rutConductor, string score, string nombreCliente, List <Track_GetDetalleTrayecto_Result> _detalleTrayecto, List <Track_GetAlertasInformeViaje_Result> _alertasInformeViaje)
        {
            //Disable SSL certificate security. It´s not working other way
            ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
            { return(true); };

            Document document = new Document();

            MemoryStream memoryStream = new MemoryStream();
            PdfWriter    pdfWriter    = PdfWriter.GetInstance(document, memoryStream);

            PdfPTable pdfTableResumen = new PdfPTable(2);

            pdfTableResumen.WidthPercentage     = 100;
            pdfTableResumen.DefaultCell.Border  = Rectangle.NO_BORDER;
            pdfTableResumen.HorizontalAlignment = Element.ALIGN_LEFT;

            float[] widths = new float[] { 1f, 3f };
            pdfTableResumen.SetWidths(widths);

            pdfTableResumen.SpacingBefore = 30f;
            pdfTableResumen.SpacingAfter  = 40f;

            pdfTableResumen.AddCell("Guía:");
            pdfTableResumen.AddCell(" " + nroTransporte);
            pdfTableResumen.AddCell("Cliente:");
            pdfTableResumen.AddCell(nombreCliente);
            pdfTableResumen.AddCell("Transportista:");
            pdfTableResumen.AddCell(" " + transportista);
            pdfTableResumen.AddCell("Origen");
            pdfTableResumen.AddCell(" " + nombreOrigen);
            pdfTableResumen.AddCell("Destino/s:");
            pdfTableResumen.AddCell(destinos);
            pdfTableResumen.AddCell("Tracto:");
            pdfTableResumen.AddCell(" " + tracto);
            pdfTableResumen.AddCell("Rampla:");
            pdfTableResumen.AddCell(" " + trailer);
            pdfTableResumen.AddCell("Nro. Contenendor:");
            pdfTableResumen.AddCell(" " + nroContenedor);
            pdfTableResumen.AddCell("Conductor:");
            pdfTableResumen.AddCell(" " + conductor);
            pdfTableResumen.AddCell("Rut Conductor:");
            pdfTableResumen.AddCell(" " + rutConductor);
            pdfTableResumen.AddCell("Score:");
            pdfTableResumen.AddCell(" " + score);

            document.Open();

            var   server    = HttpContext.Current.Server;
            var   imagePath = server.MapPath("Images");
            Image logo      = Image.GetInstance(imagePath + "/logo_white_1500x789.png");

            logo.ScalePercent(7f);

            document.Add(logo);

            var boldTitle = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 20);

            Paragraph title = new Paragraph("Informe de Viaje", boldTitle);

            title.Alignment = Element.ALIGN_CENTER;

            document.Add(title);

            document.Add(pdfTableResumen);

            var boldFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12);

            var tituloDetalle = new Phrase();

            tituloDetalle.Add(new Chunk("Detalle de trayecto:", boldFont));
            document.Add(new Paragraph(tituloDetalle));

            PdfPTable pdfTableDetalleTrayecto = new PdfPTable(2);

            pdfTableDetalleTrayecto.WidthPercentage     = 100;
            pdfTableDetalleTrayecto.HorizontalAlignment = Element.ALIGN_LEFT;
            pdfTableDetalleTrayecto.DefaultCell.Border  = Rectangle.NO_BORDER;
            float[] widthsTableDetalleTrayecto = new float[] { 3f, 6f };
            pdfTableDetalleTrayecto.SetWidths(widthsTableDetalleTrayecto);
            pdfTableDetalleTrayecto.SpacingBefore = 10;
            pdfTableDetalleTrayecto.SpacingAfter  = 20;
            //pdfTableDetalleTrayecto.AddCell("Fecha");
            //pdfTableDetalleTrayecto.AddCell("Detalle");

            for (int j = 0; j < _detalleTrayecto.Count; j++)
            {
                pdfTableDetalleTrayecto.AddCell(_detalleTrayecto[j].Fecha);
                pdfTableDetalleTrayecto.AddCell(_detalleTrayecto[j].Detalle);
            }
            document.Add(pdfTableDetalleTrayecto);

            var tituloAlertas = new Phrase();

            tituloAlertas.Add(new Chunk("Alertas:", boldFont));

            var tituloObservaciones = new Phrase();

            tituloObservaciones.Add(new Chunk("Observaciones:", boldFont));

            if (_alertasInformeViaje.Count > 0)
            {
                document.NewPage();
                document.Add(new Paragraph(tituloAlertas));
            }

            int countMapPag = 0;

            for (int i = 0; i < _alertasInformeViaje.Count; i++)
            {
                PdfPTable pdfTableAlertas = new PdfPTable(5);
                pdfTableAlertas.WidthPercentage     = 100;
                pdfTableAlertas.HorizontalAlignment = Element.ALIGN_LEFT;
                //float[] widthsTableAlertas = new float[] { 1f, 3f, 2f, 5f };
                //pdfTableResumen.SetWidths(widths);

                pdfTableAlertas.SpacingBefore = 40;
                pdfTableAlertas.SpacingAfter  = 10f;

                Anchor anchor = new Anchor("Link");

                anchor.Reference = "https://maps.google.com/maps?q=" + _alertasInformeViaje[i].Latitud.ToString() + ',' + _alertasInformeViaje[i].Longitud.ToString();

                pdfTableAlertas.AddCell("Fecha Inicio:");
                pdfTableAlertas.AddCell("Fecha Envío:");
                pdfTableAlertas.AddCell("Destino:");
                pdfTableAlertas.AddCell("Descripción");
                pdfTableAlertas.AddCell("Ver en mapa");
                pdfTableAlertas.AddCell(_alertasInformeViaje[i].FechaInicioAlerta.ToString());
                pdfTableAlertas.AddCell(_alertasInformeViaje[i].FechaHoraCreacion.ToString());
                pdfTableAlertas.AddCell(_alertasInformeViaje[i].LocalDestino.ToString());
                pdfTableAlertas.AddCell(_alertasInformeViaje[i].DescripcionAlerta.ToString());
                pdfTableAlertas.AddCell(anchor);

                document.Add(pdfTableAlertas);

                string center = _alertasInformeViaje[i].Latitud + "," + _alertasInformeViaje[i].Longitud;
                string polygon;

                if (_alertasInformeViaje[i].ZoneLocation != -1)
                {
                    int _idZona;
                    _idZona = Convert.ToInt32(_alertasInformeViaje[i].ZoneLocation);

                    polygon = "&path=color:0x000000%7Cweight:2%7Cfillcolor:0x9966FF%7C";

                    Methods_Zonas         _obj      = new Methods_Zonas();
                    List <Track_Vertices> _vertices = _obj.GetAllVerticesZona(_idZona);
                    for (int k = 0; k < _vertices.Count; k++)
                    {
                        polygon = polygon + _vertices[k].Latitud.ToString().Replace(",", ".") + ',' + _vertices[k].Longitud.ToString().Replace(",", ".");

                        if (k < _vertices.Count - 1)
                        {
                            polygon = polygon + "%7C";
                        }
                    }
                }
                else
                {
                    polygon = "";
                }

                var stringUrlMap = "https://maps.googleapis.com/maps/api/staticmap?zoom=13&maptype=roadmap&size=400x200" + "&markers=color:red%7C" + center + "&key=AIzaSyDKLevfrbLESV7ebpmVxb9P7XRRKE1ypq8" + polygon;

                iTextSharp.text.Image mapImage = iTextSharp.text.Image.GetInstance(stringUrlMap);
                document.Add(mapImage);

                document.Add(new Paragraph(tituloObservaciones));
                if (_alertasInformeViaje[i].Observaciones != "")
                {
                    document.Add(new Paragraph(_alertasInformeViaje[i].Observaciones));
                }
                else
                {
                    document.Add(new Paragraph("Sin observaciones."));
                }

                countMapPag = countMapPag + 1;

                if (countMapPag >= 2)
                {
                    document.NewPage();
                    countMapPag = 0;
                }
            }

            document.Close();

            return(memoryStream);
        }
Exemplo n.º 55
0
 public ResultCard(Vector2 position, Anchor anchor = Anchor.Center)
     : base(Skin.Assets["result_scorecard"], position, anchor: anchor)
 {
 }
Exemplo n.º 56
0
 public static bool IsMiddleY(this Anchor a)
 {
     return(a == Anchor.Left || a == Anchor.Center || a == Anchor.Right);
 }
 public ATHCompositeColor(Game1 game, Vector2 position, Vector2 size, Color color, Anchor anchor = Anchor.topleft, int order = 0) : base(game, position, size, anchor, order)
 {
     this.color = color;
 }
Exemplo n.º 58
0
 public static bool IsRight(this Anchor a)
 {
     return(a == Anchor.TopRight || a == Anchor.Right || a == Anchor.BottomRight);
 }
 /**
  * Constructs a RtfAnchor based on a RtfField
  *
  * @param doc The RtfDocument this RtfAnchor belongs to
  * @param anchor The Anchor this RtfAnchor is based on
  */
 public RtfAnchor(RtfDocument doc, Anchor anchor) : base(doc)
 {
     this.url     = anchor.Reference;
     this.content = new RtfPhrase(doc, anchor);
 }
Exemplo n.º 60
0
 public static bool IsTop(this Anchor a)
 {
     return(a == Anchor.Top || a == Anchor.TopLeft || a == Anchor.TopRight);
 }