// Use this for initialization
	void Start () {

        canvas = GetComponent<Canvas>();
       
        foreach (Transform t in transform)
        {
            if (t.name == "Item0")
                items[0] = t.gameObject;
            if (t.name == "Item1")
                items[1] = t.gameObject;
            if (t.name == "Item2")
                items[2] = t.gameObject;
            if (t.name == "Item3")
                items[3] = t.gameObject;
            if (t.name == "Item4")
                items[4] = t.gameObject;
            if (t.name == "Item5")
                items[5] = t.gameObject;
            if (t.name == "Item6")
                items[6] = t.gameObject;
            if (t.name == "Item7")
                items[7] = t.gameObject;
            if (t.name == "HandCursor")
                handCursor = t.gameObject;
            if (t.name == "Background")
                background = t.gameObject;
        }

        handCusorPositionX = handCursor.GetComponent<RectTransform>().position.x;
        originalHandCursorPositionX = handCusorPositionX;
    }
Пример #2
0
 void Awake()
 {
     text = GameObject.Find("Info").GetComponent<Text>();
     myCanvas = transform.parent.parent.parent.GetComponent<Canvas>();
     infoMessage = new List<string>();
     DisableMe();
 }
 // Use this for initialization
 void Start()
 {
     player = GameObject.FindObjectOfType<Player>();
     canvas = GetComponent<Canvas>();
     canvas.enabled = false;
     state = GameObject.FindObjectOfType<LevelState>();
 }
Пример #4
0
 void Start()
 {
     QuitMenu = QuitMenu.GetComponent<Canvas>();
     startText = startText.GetComponent<Button>();
     exitText = exitText.GetComponent<Button>();
     QuitMenu.enabled = false;
 }
Пример #5
0
 // Use this for initialization
 void Start()
 {
     startMenu = startMenu.GetComponent<Canvas> ();
     gameoverMenu = gameoverMenu.GetComponent<Canvas> ();
     startMenu.enabled = true;
     gameoverMenu.enabled = false;
 }
Пример #6
0
        public static void Render(Canvas target, IViewport viewport, IEnumerable<ILayer> layers, bool rasterizing)
        {
            #if !SILVERLIGHT &&  !NETFX_CORE
            target.BeginInit();
            #endif
            target.Visibility = Visibility.Collapsed;
            foreach (var child in target.Children)
            {
                if (child is Canvas)
                {
                    (child as Canvas).Children.Clear();
                }
            }
            target.Children.Clear();

            foreach (var layer in layers)
            {
                if (!layer.Enabled) continue;
                if (layer.MinVisible > viewport.Resolution) continue;
                if(layer.MaxVisible < viewport.Resolution) continue;

                RenderLayer(target, viewport, layer, rasterizing);

            }
            target.Arrange(new Rect(0, 0, viewport.Width, viewport.Height));
            target.Visibility = Visibility.Visible;

            //DrawDebugInfo(target, layers);

            #if !SILVERLIGHT &&  !NETFX_CORE
            target.EndInit();
            #endif
        }
		public CanvasExample () {
			Gtk.Window win = new Gtk.Window ("Canvas example");
			win.DeleteEvent += new DeleteEventHandler (Window_Delete);

			VBox vbox = new VBox (false, 0);
			win.Add (vbox);

			vbox.PackStart (new Label ("Drag - move object.\n" +
						   "Double click - change color\n" +
						   "Right click - delete object"),
					false, false, 0);
			
			canvas = new Canvas ();
			canvas.SetSizeRequest (width, height);
			canvas.SetScrollRegion (0.0, 0.0, (double) width, (double) height);
			vbox.PackStart (canvas, false, false, 0);

			HBox hbox = new HBox (false, 0);
			vbox.PackStart (hbox, false, false, 0);

			Button add_button = new Button ("Add an object");
			add_button.Clicked += new EventHandler (AddObject);
			hbox.PackStart (add_button, false, false, 0);

			Button quit_button = new Button ("Quit");
			quit_button.Clicked += new EventHandler (Quit);
			hbox.PackStart (quit_button, false, false, 0);

			win.ShowAll ();
		}
 void Start()
 {
     rect = GetComponent<RectTransform>();
     canvas = transform.parent.GetComponentInParent<Canvas>();
     camToUse = canvas.worldCamera;
     SetLocation();
 }
Пример #9
0
	// Use this for initialization
	void Start () 
    {
        canvas = GameObject.FindObjectOfType<Canvas>();
        sceneManager = canvas.GetComponent<csBedroomSceneManager>();
        kagotchi = GameObject.Find("Kagotchi");
        on = true;
	}
Пример #10
0
	void Start(){
		qm = qm.GetComponent<Canvas> ();
		toggle = toggle.GetComponent<Button> ();
	
		//playing = true;
		//AudioListener.pause = false;
	}
        /// <summary>
        /// Create a ScrollViewer that can be used by the tests.
        /// </summary>
        /// <returns>A ScrollViewer that can be used by the tests.</returns>
        private static ScrollViewer CreateTestScrollViewer()
        {
            LinearGradientBrush brush = new LinearGradientBrush
            {
                StartPoint = new Point(),
                EndPoint = new Point(1, 1)
            };
            brush.GradientStops.Add(new GradientStop { Offset = 0, Color = Colors.Red });
            brush.GradientStops.Add(new GradientStop { Offset = 1, Color = Colors.Blue });

            Canvas panel = new Canvas
            {
                Height = 400,
                Width = 400,
                Background = brush
            };

            return new ScrollViewer
            {
                Height = 100,
                Width = 100,
                HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
                VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
                Content = panel
            };
        }
Пример #12
0
    // Use this for initialization
    void Start()
    {
        //general setup
        menu = GetComponentInParent<Menu>();
        options = new List<MenuViewOptionBasic>();
        GetComponentsInChildren<MenuViewOptionBasic>(options);
        toDraw = true;
        if(options == null) options = new List<MenuViewOptionBasic>();
        //Setup view
        viewObject = new GameObject("MenuViewBasic");
        viewObject.transform.SetParent(transform);
        canvas = viewObject.AddComponent<Canvas>();
        canvas.renderMode = RenderMode.ScreenSpaceCamera;
        canvas.worldCamera = drawCamera;
        canvas.planeDistance = 1f;
        viewObject.AddComponent<CanvasScaler>();
        viewObject.AddComponent<GraphicRaycaster>();
        //Setup textbox
        textbox = new GameObject("TextBox");
        textPosition = textbox.AddComponent<RectTransform>();
        textPosition.SetParent(viewObject.transform);
        textPosition.localPosition = new Vector3(position.x,position.y, 0);
        textbox.AddComponent<CanvasRenderer>();

        text = textbox.AddComponent<Text>();
        text.font = textFont;
        text.alignment = TextAnchor.MiddleCenter;
        text.color = new Color(color.r, color.g, color.b);
        if(options.Count > 0) text.text = options[menu.CurOption].optionText;
    }
Пример #13
0
        protected internal override void OnCollectDrawcalls(Canvas canvas)
        {
            base.OnCollectDrawcalls(canvas);
            canvas.State.TextInvariantScale = true;
            canvas.State.ZOffset = -1;

            RigidBody selectedBody = this.QuerySelectedCollider();

            List<RigidBody> visibleColliders = this.QueryVisibleColliders().ToList();
            List<JointInfo> visibleJoints = new List<JointInfo>();
            foreach (RigidBody c in visibleColliders)
            {
                if (c.Joints == null) continue;
                visibleJoints.AddRange(c.Joints.Where(j => !visibleJoints.Contains(j)));
            }
            foreach (JointInfo j in visibleJoints)
            {
                float jointAlpha = selectedBody != null && (j.BodyA == selectedBody || j.BodyB == selectedBody) ? 1.0f : 0.5f;
                if (!j.Enabled) jointAlpha *= 0.25f;
                canvas.State.ColorTint = canvas.State.ColorTint.WithAlpha(jointAlpha);

                if (j.BodyA == null) continue;
                if (j.DualJoint && j.BodyB == null) continue;
                this.DrawJoint(canvas, j);
            }
        }
Пример #14
0
 void Start()
 {
     exitText = exitText.GetComponent<Canvas> ();
     menu = menu.GetComponent<Canvas> ();
     menu.enabled = true;
     exitText.enabled = false;
 }
Пример #15
0
	// Use this for initialization
	void Start () {
		timer = timer.GetComponent<Text> ();
		end = end.GetComponent<Canvas> ();
		disablingScreen = disablingScreen.GetComponent<Canvas> ();
		disablingScreen.enabled = false;

	}
 // Use this for initialization
 void Start()
 {
     cpt = 0.0F;
     GetComponent<AudioSource>().PlayOneShot(nekoNya);
     canvas = GameObject.FindGameObjectWithTag("marmotteUI").GetComponent<Canvas>();
     canvas.enabled = false;
 }
Пример #17
0
	void Start () {
		sceneManagerScript.setUserVisited(41);
		sceneManagerScript.printCurrentKillerID();
		
		dialogue_1 = sceneManagerScript.readFile("Scene41_1.txt");
		emotion_1 = sceneManagerScript.readEmotion("41_1.txt");
		dialogue_1Length = dialogue_1.Length;

		dialogue_2 = sceneManagerScript.readFile("Scene41_2.txt");
		emotion_2 = sceneManagerScript.readEmotion("41_2.txt");
		dialogue_2Length = dialogue_2.Length;

		dialogue_3 = sceneManagerScript.readFile("Scene41_3.txt");
		emotion_3 = sceneManagerScript.readEmotion("41_3.txt");
		dialogue_3Length = dialogue_3.Length;

		dialogue_4 = sceneManagerScript.readFile("Scene41_4.txt");
		emotion_4 = sceneManagerScript.readEmotion("41_4.txt");
		dialogue_4Length = dialogue_4.Length;

		dialogue_5 = sceneManagerScript.readFile("Scene41_5.txt");
		emotion_5 = sceneManagerScript.readEmotion("41_5.txt");
		dialogue_5Length = dialogue_5.Length;

		dialogue_6 = sceneManagerScript.readFile("Scene41_6.txt");
		emotion_6 = sceneManagerScript.readEmotion("41_6.txt");
		dialogue_6Length = dialogue_6.Length;

		displayDialogue();

		sceneCanvas = sceneCanvas.GetComponent<Canvas>(); 
		sceneCanvas.enabled = true; 
		decision1Canvas = decision1Canvas.GetComponent<Canvas>();
		decision1Canvas.enabled = false;
	}
Пример #18
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            mvarHDC = Internal.System.Windows.Methods.GetDC(this.Handle);
            mvarCanvas = new Canvas(mvarHDC, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
        }
Пример #19
0
	// Use this for initialization
	void Start()
	{
		player = GameObject.FindGameObjectWithTag("Player").GetComponent<PuppetScript>();

		theGUI = GameObject.Find("GUI").GetComponent<Canvas>();
		tutorial = GameObject.Find("Tutorial").GetComponent<Canvas>();

		if (theGUI)
		{
			guardLeft = GameObject.Find("GUI/Panel/Guard HUD/Guard Left").GetComponent<Image>();
			guardRight = GameObject.Find("GUI/Panel/Guard HUD/Guard Right").GetComponent<Image>();
			guardTop = GameObject.Find("GUI/Panel/Guard HUD/Guard Top").GetComponent<Image>();

			tally1 = GameObject.Find("GUI/Panel/Tally1").GetComponent<Image>();
			tally2 = GameObject.Find("GUI/Panel/Tally2").GetComponent<Image>();
			tally3 = GameObject.Find("GUI/Panel/Tally3").GetComponent<Image>();
		}

		dances.Add("Twerk");
		dances.Add("Gangnam Style");
		dances.Add("Robot");
		dances.Add("Thriller 1");
		dances.Add("Thriller 2");
		dances.Add("Thriller 3");
		dances.Add("Thriller 4");
	}
 /// <summary>
 ///   <para>Deregister the given Graphic from a Canvas.</para>
 /// </summary>
 /// <param name="c">Canvas.</param>
 /// <param name="graphic">Graphic to deregister.</param>
 public static void UnregisterGraphicForCanvas(Canvas c, Graphic graphic)
 {
   IndexedSet<Graphic> indexedSet;
   if ((Object) c == (Object) null || !GraphicRegistry.instance.m_Graphics.TryGetValue(c, out indexedSet))
     return;
   indexedSet.Remove(graphic);
 }
 /// <summary>
 ///   <para>Return a list of Graphics that are registered on the Canvas.</para>
 /// </summary>
 /// <param name="canvas">Input canvas.</param>
 /// <returns>
 ///   <para>Graphics on the input canvas.</para>
 /// </returns>
 public static IList<Graphic> GetGraphicsForCanvas(Canvas canvas)
 {
   IndexedSet<Graphic> indexedSet;
   if (GraphicRegistry.instance.m_Graphics.TryGetValue(canvas, out indexedSet))
     return (IList<Graphic>) indexedSet;
   return (IList<Graphic>) GraphicRegistry.s_EmptyList;
 }
Пример #22
0
	// Use this for initialization
	void Start () {

        winningPlayer = 0;
        Time.timeScale = 1;
        players = GameObject.FindGameObjectsWithTag("Player");

        if (players.Length > numOfPlayers)
        {
            for (int i = 0; i < players.Length; i++)
            {
                if (players[i].GetComponent<CarScript>().player > numOfPlayers)
                    if (players[i].transform.name != ("RC Car 1"))
                    {
                        Destroy(players[i].gameObject);
                    }
                else
                    continue;
            }
        }

        lapText = GameObject.Find("Lap Text").GetComponent<Text>();
        winnerText = GameObject.Find("Winner Text").GetComponent<Text>();
        gameOverCanvas = GameObject.Find("Game Over Canvas").GetComponent<Canvas>();
        pauseCanvas = GameObject.Find("Pause Canvas").GetComponent<Canvas>();
        hudCanvas = GameObject.Find("HUD").GetComponent<Canvas>();

        pauseCanvas.enabled = false;
        gameOverCanvas.enabled = false;
	
	}
Пример #23
0
 public TextLayout(Canvas canvas)
 {
     ToolkitEngine = canvas.Surface.ToolkitEngine;
     handler = ToolkitEngine.TextLayoutBackendHandler;
     Backend = handler.Create ((ICanvasBackend)Toolkit.GetBackend (canvas));
     Font = canvas.Font;
 }
Пример #24
0
    // Use this for initialization
    void Start()
    {
        SetSound();

        Image[] images = GetComponentsInChildren<Image>();
        foreach (Image i in images)
            if (i.name == "SoundButton")
            {
                _soundImage = i;
                _soundImage.sprite = (sound == 1) ? soundOnImage : soundOffImage;
            }

        _startMenuCanvas = GetComponentInChildren<Canvas>();
        _startMenuCanvas.enabled = true;

        try {
            _highScoreCanvas = GameObject.Find("HighScoreUI").GetComponentInChildren<Canvas>();
            if (_highScoreCanvas != null)
            {
                _highScoreCanvas.enabled = false;
                SetFontSize(_startMenuCanvas);
            }
        }
        catch(Exception e) { Debug.Log(e);  }

        Text[] textArry = _startMenuCanvas.GetComponentsInChildren<Text>();
        foreach (Text ctext in textArry)
        {
            if (ctext.name.Contains("Score")) ctext.text = "" + Score.getScore();
        }
    }
	public void Awake () 
	{
		_canvas = FindObjectOfType<Canvas>();
		_renderers = FindObjectsOfType<Renderer>();
		_scnManager = FindObjectOfType<SceneManager> ();
		DOTween.Init();
	}
Пример #26
0
    private void initUI()
    {
        //UI Initializations - Grab Canvas with find object, then grab children for efficiency
        gameUI = FindObjectOfType<Canvas>();

        //get all child sliders
        Component[] canvasSliders = gameUI.GetComponentsInChildren<Slider> ();
        //get all text sliders
        Component[] canvasTexts = gameUI.GetComponentsInChildren<Text> ();

        //loop through and find specific slider
        foreach (Slider child in canvasSliders) {
            if (child.tag.Equals("Enemy HP")) {
                enemyHealth = child;
            }
        }

        //loop through and find specific text
        foreach (Text child in canvasTexts) {
            if (child.tag.Equals("Enemy Ratio")) {
                enemyRatio = child;
            }
        }

        //create listener to run delegate function for updating text ratio of enemy
        enemyHealth.onValueChanged.AddListener (updateEnemyRatio);
    }
Пример #27
0
        public int KeepWindowInCanvas = 5;            // # of pixels of the window that must stay inside the canvas view.

        // Use this for initialization
        void Start()
        {
            m_transform = GetComponent<RectTransform>();
            m_originalCoods = m_transform.position;
            m_canvas = GetComponentInParent<Canvas>();
            m_canvasRectTransform = m_canvas.GetComponent<RectTransform>();
        }
Пример #28
0
 // Use this for initialization
 void Start()
 {
     quitMenu = quitMenu.GetComponent<Canvas> ();
     play = play.GetComponent<Button> ();
     quit = quit.GetComponent<Button> ();
     quitMenu.enabled = false;
 }
Пример #29
0
	// Use this for initialization
	void Start () {
		quitMenu = quitMenu.GetComponent<Canvas> ();
		playText = playText.GetComponent<Button> ();
		exitText = exitText.GetComponent<Button> ();
		quitMenu.enabled = false;

	}
Пример #30
0
 public void onClick(Canvas soal)
 {
     Destroy(soal);
     Time.timeScale = 1;
 }
Пример #31
0
 // Use this for initialization
 void Start()
 {
     stateManager = ObjectStateManager.Instance;
     canvas       = GetComponent <Canvas> ();
 }
Пример #32
0
 public static Vector2 WorldSize(this Canvas canvas) => Vector2.Scale(canvas.RectTransform().sizeDelta, canvas.RectTransform().localScale);
Пример #33
0
 private Rect GetItemRect(ElementContentItem item)
 {
     return(new Rect(Canvas.GetLeft(item), Canvas.GetTop(item), item.ActualWidth, item.ActualHeight));
 }
Пример #34
0
 public abstract void Draw(Canvas canvas, double scaleFactor);
        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw(canvas);

            if (null == _viewPager)
            {
                return;
            }

            var count = _viewPager.Adapter.Count;

            if (0 == count)
            {
                return;
            }

            if (-1 == _currentPage && _viewPager != null)
            {
                _currentPage = _viewPager.CurrentItem;
            }

            var bounds     = CalculateAllBounds(_paintText);
            var boundsSize = bounds.Count;

            if (_currentPage >= boundsSize)
            {
                CurrentItem = boundsSize - 1;
                return;
            }

            var countMinusOne = count - 1;
            var halfWidth     = Width / 2f;
            var leftClip      = Left + ClipPadding;
            var right         = Left + Width;
            var rightClip     = right - ClipPadding;
            var height        = Height;
            var left          = Left;

            var   page = _currentPage;
            float offsetPercent;

            if (_pageOffset <= 0.5)
            {
                offsetPercent = _pageOffset;
            }
            else
            {
                page         += 1;
                offsetPercent = 1 - _pageOffset;
            }

            var currentSelected = (offsetPercent <= SelectionFadePercentage);
            var currentBold     = (offsetPercent <= BoldFadePercentage);
            var selectedPercent = (SelectionFadePercentage - offsetPercent) / SelectionFadePercentage;

            //Verify if the current view must be clipped to the screen
            var curPageBound = bounds[_currentPage];
            var curPageWidth = curPageBound.Right - curPageBound.Left;

            if (curPageBound.Left < leftClip)
            {
                ClipViewOnTheLeft(curPageBound, curPageWidth, left);
            }
            if (curPageBound.Right > rightClip)
            {
                ClipViewOnTheRight(curPageBound, curPageWidth, right);
            }

            //Left view is starting from the current position
            if (_currentPage > 0)
            {
                for (var i = _currentPage - 1; i >= 0; i--)
                {
                    var bound = bounds[i];
                    //Is left side outside the screen?
                    if (bound.Left < leftClip)
                    {
                        var w = bound.Right - bound.Left;
                        //Clip to the left screen side
                        ClipViewOnTheLeft(bound, w, left);

                        var rightBound = bounds[i + 1];
                        //Except if there is an intersection with the right view
                        if (bound.Right + TitlePadding > rightBound.Left)
                        {
                            bound.Left  = (int)(rightBound.Left - w - TitlePadding);
                            bound.Right = bound.Left + w;
                        }
                    }
                }
            }

            //Right view is starting from the current position
            if (_currentPage < countMinusOne)
            {
                for (var i = _currentPage + 1; i < count; i++)
                {
                    var bound = bounds[i];
                    //Is right side outside the screen?
                    if (bound.Right > rightClip)
                    {
                        var w = bound.Right - bound.Left;
                        //Clip to the right screen side
                        ClipViewOnTheRight(bound, w, Right);

                        var leftBound = bounds[i - 1];
                        //Except if there is an intersection with the left view
                        if (bound.Left - TitlePadding < leftBound.Right)
                        {
                            bound.Left  = (int)(leftBound.Right + TitlePadding);
                            bound.Right = bound.Left + w;
                        }
                    }
                }
            }

            //Now draw views!
            var colorTextAlpha = _colorText >> 24;

            for (var i = 0; i < count; i++)
            {
                //Get the title
                var bound = bounds[i];
                //Only if one side is visible
                if ((bound.Left > left && bound.Left < right) || (bound.Right > left && bound.Right < right))
                {
                    var currentPage = (i == page);
                    var pageTitle   = GetTitle(i);

                    //Only set bold if we are within bounds
                    _paintText.FakeBoldText = currentPage && currentBold && _boldText;

                    //Draw text as unselected
                    _paintText.Color = _colorText;
                    if (currentPage && currentSelected)
                    {
                        //Fade out/in unselected text as the selected text fades in/out
                        _paintText.Alpha = colorTextAlpha - (int)(colorTextAlpha * selectedPercent);
                    }

                    //Except if there is an intersection with the right view
                    if (i < boundsSize - 1)
                    {
                        var rightBound = bounds[i + 1];
                        if (bound.Right + TitlePadding > rightBound.Left)
                        {
                            var w = bound.Right - bound.Left;
                            bound.Left  = (int)(rightBound.Left - w - TitlePadding);
                            bound.Right = bound.Left + w;
                        }
                    }
                    canvas.DrawText(pageTitle, 0, pageTitle.Length, bound.Left, bound.Bottom + TopPadding, _paintText);

                    //If we are within the selected bound draw the selected text
                    if (currentPage && currentSelected)
                    {
                        _paintText.Color = _colorSelected;
                        _paintText.Alpha = (int)((_colorSelected >> 24) * selectedPercent);
                        canvas.DrawText(pageTitle, 0, pageTitle.Length, bound.Left, bound.Bottom + TopPadding, _paintText);
                    }
                }
            }

            //If we want the line on the top change height to zero and invert line height to trick the drawing code
            var footerLineHeight          = _footerLineHeight;
            var footerIndicatorLineHeight = _footerIndicatorHeight;

            if (_linePosition == LinePosition.Top)
            {
                height                    = 0;
                footerLineHeight          = -footerLineHeight;
                footerIndicatorLineHeight = -footerIndicatorLineHeight;
            }

            //Draw the footer line
            _path.Reset();
            _path.MoveTo(0, height - footerLineHeight / 2f);
            _path.MoveTo(Width, height - footerLineHeight / 2f);
            _path.Close();
            canvas.DrawPath(_path, _paintFooterLine);

            var heightMinusLine = height - footerLineHeight;

            switch (_footerIndicatorStyle)
            {
            case IndicatorStyle.Triangle:
                _path.Reset();
                _path.MoveTo(halfWidth, heightMinusLine - footerIndicatorLineHeight);
                _path.LineTo(halfWidth + footerIndicatorLineHeight, heightMinusLine);
                _path.LineTo(halfWidth - footerIndicatorLineHeight, heightMinusLine);
                _path.Close();
                canvas.DrawPath(_path, _paintFooterIndicator);
                break;

            case IndicatorStyle.Underline:
                if (!currentSelected || page >= boundsSize)
                {
                    break;
                }

                var underlineBounds  = bounds[page];
                var rightPlusPadding = underlineBounds.Right + _footerIndicatorUnderlinePadding;
                var leftMinusPadding = underlineBounds.Left - _footerIndicatorUnderlinePadding;
                var heightMinusLineMinusIndicator = heightMinusLine - footerIndicatorLineHeight;

                _path.Reset();
                _path.MoveTo(leftMinusPadding, heightMinusLine);
                _path.LineTo(rightPlusPadding, heightMinusLine);
                _path.LineTo(rightPlusPadding, heightMinusLineMinusIndicator);
                _path.LineTo(leftMinusPadding, heightMinusLineMinusIndicator);
                _path.Close();

                _paintFooterIndicator.Alpha = (int)(0xFF * selectedPercent);
                canvas.DrawPath(_path, _paintFooterIndicator);
                _paintFooterIndicator.Alpha = 0xFF;
                break;
            }
        }
Пример #36
0
 public static GameObject CreateMinimapObj(Canvas canvas)
 {
     GameObject minimapPref = Resources.Load<GameObject>("Prefabs/UI/Minimap/MinimapHUD");
     GameObject minimap = UnityEngine.Object.Instantiate(minimapPref, canvas.transform);
     return minimap;
 }
Пример #37
0
 void Start()
 {
     this.canvas = this.GetComponentInChildren <Canvas>();
 }
Пример #38
0
 // Start is called before the first frame update
 void Start()
 {
     _Shader = this.GetComponent <Image>();
     _canvas = GameObject.Find("Canvas").GetComponent <Canvas>();
 }
Пример #39
0
        private static Canvas RenderLayerStatic(IViewport viewport, ILayer layer, SymbolCache symbolCache, bool rasterizing = false)
        {
            // todo:
            // find solution for try catch. Sometimes this method will throw an exception
            // when clearing and adding features to a layer while rendering
            var canvas = new Canvas
            {
                Opacity = layer.Opacity,
                IsHitTestVisible = false
            };

            try
            {
                var features = layer.GetFeaturesInView(viewport.Extent, viewport.Resolution).ToList();
                var layerStyles = BaseLayer.GetLayerStyles(layer);

                // If rasterizing (which is usually on a background thread) create a new SymbolCache 
                // just for this rendering because cross thread access is not allowed in WPF.

                if (rasterizing) symbolCache = new SymbolCache();
                
                foreach (var layerStyle in layerStyles)
                {
                    var style = layerStyle; // This is the default that could be overridden by an IThemeStyle

                    foreach (var feature in features)
                    {
                        if (layerStyle is IThemeStyle) style = (layerStyle as IThemeStyle).GetStyle(feature);
                        if (style == null || 
                            style.Enabled == false || 
                            style.MinVisible > viewport.Resolution ||
                            style.MaxVisible < viewport.Resolution) continue;

                        RenderFeature(viewport, canvas, feature, style, symbolCache, rasterizing);
                    }
                }

                foreach (var feature in features)
                {
                    var styles = feature.Styles ?? Enumerable.Empty<IStyle>();
                    foreach (var style in styles)
                        if (feature.Styles != null && style.Enabled)
                            RenderFeature(viewport, canvas, feature, style, symbolCache, rasterizing);
                }

                return canvas;
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, "Unexpected error in renderer", ex);
                return canvas;
                // If exception happens inside RenderFeature function after 
                // at -least one child has been added to the canvas,
                // returning new canvas will leave the previously created (but 
                // not yet added to parent canvas) canvas abandoned, that will 
                // cause the exception when resuing RenderedGeometry object, because 
                // at -least one RenderedGeometry was attached to that abandoned canvas.
                // returning the same canvas will solve this error, as it will 
                // be clear this canvas childs on next render call.
                // return new Canvas { IsHitTestVisible = false };
            }
        }
Пример #40
0
 private void Render(Canvas target, IViewport viewport, IEnumerable<ILayer> layers)
 {
     Render(target, viewport, layers,  _symbolCache, false);
 }
Пример #41
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            // This uses the eval's duration, and uses a neural net for the trial tick count.  This is to recreate what the training actually sees

            try
            {
                imageInput.Source = null;
                canvasMain.Children.Clear();

                DateTime now = DateTime.UtcNow;

                if (_harness == null || _evalArgs == null)
                {
                    _prevTick = now;
                    return;
                }

                // Reset
                if (_tickCounter >= _evalArgs.TotalNumberEvaluations)
                {
                    #region reset

                    if (_experiment != null)
                    {
                        NeatGenome winner = _ea.CurrentChampGenome;
                        _genomeViewer.RefreshView(winner);

                        if (winner == null)
                        {
                            _prevTick = now;
                            return;
                        }

                        bool showedHyper = false;
                        if (_experiment.IsHyperNEAT)
                        {
                            var decoder = _experiment.CreateGenomeDecoder(_hyperneatArgs);
                            if (decoder is HyperNeatDecoder hyperDecoder)
                            {
                                //NOTE: There is a flaw.  The INetworkDefinition that this method returns is acyclic, but the method that generates the IBlackBox is CreateSubstrateNetwork_FastCyclicNetwork.
                                //So that INetworkDefinition seems to be limited or incorrect
                                //
                                //Actually, that might not be a flaw.  The FastCyclic may be processing the CPPN which is cyclic

                                var finalPhenome = hyperDecoder.Decode2(winner);

                                _genomeViewer2.RefreshView(finalPhenome.Item2);

                                nnViewerHost2.Visibility = Visibility.Visible;
                                showedHyper = true;
                            }
                        }

                        if (!showedHyper)
                        {
                            nnViewerHost2.Visibility = Visibility.Collapsed;
                        }

                        if (_experiment.IsHyperNEAT)
                        {
                            _winningBrain = _experiment.GetBlackBox(winner, _hyperneatArgs);
                        }
                        else
                        {
                            _winningBrain = _experiment.GetBlackBox(winner);
                        }

                        _winningBrainTime = now;

                        _harness.ClearItem();

                        _harness.SetItem(AntPos_Evaluator.GetNewItem(_harness, _evalArgs));
                        _tickCounter = -1;
                    }

                    #endregion
                }

                // Tell the harness to go
                _harness.Tick(_evalArgs.ElapsedTime_Seconds);
                _tickCounter++;

                var prevPosition    = _harness.GetPreviousPosition(_harness.Time - _evalArgs.Delay_Seconds);
                var currentPosition = _harness.Item;

                #region draw input

                double[] inputArr = new double[_harness.InputSizeXY * _harness.InputSizeXY];

                AntPos_Evaluator.ClearArray(inputArr);

                if (prevPosition != null)
                {
                    double dotRadius = (_harness.VisionSize / _harness.InputSizeXY) * Math.Sqrt(2);
                    AntPos_Evaluator.ApplyPoint(inputArr, _harness.InputCellCenters, dotRadius, prevPosition.Item2, true);
                }

                imageInput.Source = UtilityWPF.GetBitmap(inputArr, _harness.InputSizeXY, _harness.InputSizeXY, invert: true);

                #endregion
                #region draw expected output

                double[] expectedOutput = null;

                if (currentPosition == null)
                {
                    expectedOutput = AntPos_Evaluator.GetExpectedOutput(null, _harness, _evalArgs);
                }
                else
                {
                    var currentPos = Tuple.Create(currentPosition, currentPosition.Position, currentPosition.Velocity);
                    expectedOutput = AntPos_Evaluator.GetExpectedOutput(currentPos, _harness, _evalArgs);
                }

                imageExpectedOutput.Source = UtilityWPF.GetBitmap(expectedOutput, _harness.OutputSizeXY, _harness.OutputSizeXY, invert: true);

                #endregion
                #region draw nn output

                double[] nnOutput = null;

                if (_winningBrain != null)
                {
                    nnOutput = new double[_harness.OutputSizeXY * _harness.OutputSizeXY];

                    // Brain.Tick
                    _winningBrain.InputSignalArray.CopyFrom(inputArr, 0);
                    _winningBrain.Activate();
                    _winningBrain.OutputSignalArray.CopyTo(nnOutput, 0);

                    imageNNOutput.Source = UtilityWPF.GetBitmap(nnOutput, _harness.OutputSizeXY, _harness.OutputSizeXY, invert: true);
                }
                else
                {
                    imageNNOutput.Source = null;
                }

                #endregion
                #region draw error (nn - expected)

                double[] error = null;

                if (nnOutput != null)
                {
                    error = Enumerable.Range(0, nnOutput.Length).
                            Select(o => Math.Abs(nnOutput[o] - expectedOutput[o])).
                            ToArray();

                    imageError.Source = UtilityWPF.GetBitmap(error, _harness.OutputSizeXY, _harness.OutputSizeXY, invert: true);
                }
                else
                {
                    imageError.Source = null;
                }

                #endregion
                #region draw actual

                // Vision Rectangle
                Rectangle visionRect = new Rectangle()
                {
                    Stroke          = Brushes.Silver,
                    StrokeThickness = .3,
                    Width           = _harness.VisionSize,
                    Height          = _harness.VisionSize,
                };

                Canvas.SetLeft(visionRect, _harness.VisionSize / -2);
                Canvas.SetTop(visionRect, _harness.VisionSize / -2);

                canvasMain.Children.Add(visionRect);

                // Dot Previous
                if (prevPosition != null)
                {
                    Ellipse dot = new Ellipse()
                    {
                        Fill            = new SolidColorBrush(prevPosition.Item1.Color),
                        Stroke          = Brushes.Black,
                        StrokeThickness = .3,
                        Width           = 2,
                        Height          = 2,
                    };

                    Canvas.SetLeft(dot, prevPosition.Item2.X - 1);
                    Canvas.SetTop(dot, prevPosition.Item2.Y - 1);

                    canvasMain.Children.Add(dot);
                }

                // Dot Current
                if (currentPosition != null)
                {
                    Ellipse dot = new Ellipse()
                    {
                        Fill            = new SolidColorBrush(currentPosition.Color),
                        Stroke          = Brushes.White,
                        StrokeThickness = .3,
                        Width           = 2,
                        Height          = 2,
                    };

                    Canvas.SetLeft(dot, currentPosition.Position.X - 1);
                    Canvas.SetTop(dot, currentPosition.Position.Y - 1);

                    canvasMain.Children.Add(dot);
                }

                // Transform
                TransformGroup transform = new TransformGroup();

                transform.Children.Add(new ScaleTransform(canvasMain.ActualWidth / _harness.MapSize, canvasMain.ActualHeight / _harness.MapSize));
                transform.Children.Add(new TranslateTransform(canvasMain.ActualWidth / 2, canvasMain.ActualHeight / 2));

                canvasMain.RenderTransform = transform;

                #endregion

                _prevTick = now;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #42
0
        public static void RenderLayer(Canvas target, IViewport viewport, ILayer layer, SymbolCache symbolCache, bool rasterizing = false)
        {
            if (layer.Enabled == false) return;

            target.Children.Add(RenderLayerStatic(viewport, layer, symbolCache, rasterizing));
        }
Пример #43
0
        public override void Draw(Canvas canvas)
        {
            canvas.ClipShape(Context, Element);

            base.Draw(canvas);
        }
Пример #44
0
        private void Timer_Tick_REAL(object sender, EventArgs e)
        {
            // This uses actual time elapsed, and runs continuously, grabbing a new neural net every 10 seconds

            try
            {
                imageInput.Source = null;
                canvasMain.Children.Clear();

                DateTime now = DateTime.UtcNow;

                if (_harness == null)
                {
                    _prevTick = now;
                    return;
                }

                // Tell the harness to go
                _harness.Tick((now - _prevTick).TotalSeconds);

                var prevPosition    = _harness.GetPreviousPosition(_harness.Time - _evalArgs.Delay_Seconds);
                var currentPosition = _harness.Item;

                if (_experiment != null && (_winningBrain == null || (now - _winningBrainTime).TotalSeconds > 10))
                {
                    NeatGenome winner = _ea.CurrentChampGenome;
                    _genomeViewer.RefreshView(winner);
                    _winningBrain     = _experiment.GetBlackBox(winner);
                    _winningBrainTime = now;
                }

                #region draw input

                double[] inputArr = new double[_harness.InputSizeXY * _harness.InputSizeXY];

                AntPos_Evaluator.ClearArray(inputArr);

                if (prevPosition != null)
                {
                    double dotRadius = (_harness.VisionSize / _harness.InputSizeXY) * Math.Sqrt(2);
                    AntPos_Evaluator.ApplyPoint(inputArr, _harness.InputCellCenters, dotRadius, prevPosition.Item2, true);
                }

                imageInput.Source = UtilityWPF.GetBitmap(inputArr, _harness.InputSizeXY, _harness.InputSizeXY, invert: true);

                #endregion
                #region draw expected output

                double[] expectedOutput = null;

                if (currentPosition == null)
                {
                    expectedOutput = AntPos_Evaluator.GetExpectedOutput(null, _harness, _evalArgs);
                }
                else
                {
                    var currentPos = Tuple.Create(currentPosition, currentPosition.Position, currentPosition.Velocity);
                    expectedOutput = AntPos_Evaluator.GetExpectedOutput(currentPos, _harness, _evalArgs);
                }

                imageExpectedOutput.Source = UtilityWPF.GetBitmap(expectedOutput, _harness.OutputSizeXY, _harness.OutputSizeXY, invert: true);

                #endregion
                #region draw nn output

                double[] nnOutput = null;

                if (_winningBrain != null)
                {
                    nnOutput = new double[_harness.OutputSizeXY * _harness.OutputSizeXY];

                    // Brain.Tick
                    _winningBrain.InputSignalArray.CopyFrom(inputArr, 0);
                    _winningBrain.Activate();
                    _winningBrain.OutputSignalArray.CopyTo(nnOutput, 0);

                    imageNNOutput.Source = UtilityWPF.GetBitmap(nnOutput, _harness.OutputSizeXY, _harness.OutputSizeXY, invert: true);
                }
                else
                {
                    imageNNOutput.Source = null;
                }

                #endregion
                #region draw error (nn - expected)

                double[] error = null;

                if (nnOutput != null)
                {
                    error = Enumerable.Range(0, nnOutput.Length).
                            Select(o => Math.Abs(nnOutput[o] - expectedOutput[o])).
                            ToArray();

                    imageError.Source = UtilityWPF.GetBitmap(error, _harness.OutputSizeXY, _harness.OutputSizeXY, invert: true);
                }
                else
                {
                    imageError.Source = null;
                }

                #endregion
                #region draw actual

                // Vision Rectangle
                Rectangle visionRect = new Rectangle()
                {
                    Stroke          = Brushes.Silver,
                    StrokeThickness = .3,
                    Width           = _harness.VisionSize,
                    Height          = _harness.VisionSize,
                };

                Canvas.SetLeft(visionRect, _harness.VisionSize / -2);
                Canvas.SetTop(visionRect, _harness.VisionSize / -2);

                canvasMain.Children.Add(visionRect);

                // Dot Previous
                if (prevPosition != null)
                {
                    Ellipse dot = new Ellipse()
                    {
                        Fill            = new SolidColorBrush(prevPosition.Item1.Color),
                        Stroke          = Brushes.Black,
                        StrokeThickness = .3,
                        Width           = 2,
                        Height          = 2,
                    };

                    Canvas.SetLeft(dot, prevPosition.Item2.X - 1);
                    Canvas.SetTop(dot, prevPosition.Item2.Y - 1);

                    canvasMain.Children.Add(dot);
                }

                // Dot Current
                if (currentPosition != null)
                {
                    Ellipse dot = new Ellipse()
                    {
                        Fill            = new SolidColorBrush(currentPosition.Color),
                        Stroke          = Brushes.White,
                        StrokeThickness = .3,
                        Width           = 2,
                        Height          = 2,
                    };

                    Canvas.SetLeft(dot, currentPosition.Position.X - 1);
                    Canvas.SetTop(dot, currentPosition.Position.Y - 1);

                    canvasMain.Children.Add(dot);
                }

                // Transform
                TransformGroup transform = new TransformGroup();

                transform.Children.Add(new ScaleTransform(canvasMain.ActualWidth / _harness.MapSize, canvasMain.ActualHeight / _harness.MapSize));
                transform.Children.Add(new TranslateTransform(canvasMain.ActualWidth / 2, canvasMain.ActualHeight / 2));

                canvasMain.RenderTransform = transform;

                #endregion

                _prevTick = now;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #45
0
        public void initCanvas()                //캔버스 초기화
        {
            myCanvas.Children.Clear();

            int row = this.maze.getRow();
            int col = this.maze.getCol();

            myCanvas.Width  = (col + 2) * Constants.BOX_SIZE;
            myCanvas.Height = rightPanel.Height = (row + 2) * Constants.BOX_SIZE;

            for (int i = 0; i <= row + 1; i++)
            {
                for (int j = 0; j <= col + 1; j++)
                {
                    Rectangle myRectangle = new Rectangle();

                    int value = this.maze.getMazeArr(i, j);
                    if (value != -1 && this.mice.getMemory(i, j) == 0)
                    {
                        value = Constants.DONT_KNOW;
                    }

                    String uri = "box_02.png";
                    switch (value)
                    {
                    case -1:
                        uri = "box_03.png";
                        break;

                    case 1:
                        uri = "box_02.png";
                        break;

                    case 0:
                        uri = "road.png";
                        break;

                    case Constants.DONT_KNOW:
                        uri = "no.png";
                        break;
                    }

                    if (mice.isMyPoint(new Point(i, j)))
                    {
                        uri = "mouse.png";
                    }
                    if (i == 1 && j == 2)
                    {
                        uri = "start.png";
                    }

                    BitmapImage theImage     = new BitmapImage(new Uri(uri, UriKind.Relative));
                    ImageBrush  myImageBrush = new ImageBrush(theImage);

                    myRectangle.Fill = myImageBrush;

                    myRectangle.Width  = Constants.BOX_SIZE;
                    myRectangle.Height = Constants.BOX_SIZE;

                    myCanvas.Children.Add(myRectangle);
                    Canvas.SetTop(myRectangle, Constants.BOX_SIZE * i);
                    Canvas.SetLeft(myRectangle, Constants.BOX_SIZE * j);
                }
            }

            for (int i = 0; i <= row + 1; i++)
            {
                for (int j = 0; j <= col + 1; j++)
                {
                    TextBlock textBlockTemp = new TextBlock();
                    textBlockTemp.Margin = new Thickness(Constants.BOX_SIZE * j, Constants.BOX_SIZE * i, 0, 0);
                    myCanvas.Children.Add(textBlockTemp);
                }
            }
        }
Пример #46
0
 private void Awake()
 {
     canvas = FindObjectOfType <Canvas>();
 }
Пример #47
0
        /// <summary>
        /// Adds a page body.
        /// </summary>
        /// <param name="sourceFlowDocPaginator">The source flow document paginator.</param>
        /// <param name="pageNumber">The page number.</param>
        /// <param name="pageCanvas">The page canvas.</param>
        /// <param name="margins">The margins.</param>
        private void AddPageBody(DocumentPaginator sourceFlowDocPaginator, int pageNumber, Canvas pageCanvas, Thickness margins)
        {
            var dpv = new DocumentPageView {
                DocumentPaginator = sourceFlowDocPaginator, PageNumber = pageNumber
            };

            Canvas.SetTop(dpv, margins.Top);
            Canvas.SetLeft(dpv, margins.Left);
            pageCanvas.Children.Add(dpv);
        }
Пример #48
0
 public void drawCharacter(Character character)
 {
     Canvas.SetLeft(character.display, character.positionX);
     Canvas.SetTop(character.display, character.positionY);
     GameArea.Children.Add(character.display);
 }
Пример #49
0
 private void Awake()
 {
     _noTarget = target == null;
     _canvas = GetComponentInParent<Canvas>();
 }
Пример #50
0
        private void RenderFaceDetectionResults(Face[] faces)
        {
            ResetFaceDetectionOverlay();
            foreach (var face in faces)
            {
                var heightRatio     = SelectedImage.ActualHeight / _currentImage.PixelHeight;
                var widthRatio      = SelectedImage.ActualWidth / _currentImage.PixelWidth;
                var localRectHeight = face.FaceRectangle.Height * heightRatio;
                var localRectWidth  = face.FaceRectangle.Width * widthRatio;

                Rectangle rect = new Rectangle()
                {
                    Stroke            = new SolidColorBrush(Colors.Red),
                    Height            = localRectHeight,
                    Width             = localRectWidth,
                    IsTapEnabled      = true,
                    IsRightTapEnabled = true,
                    IsHitTestVisible  = true
                };
                PopupMenu menu = new PopupMenu();


                var horizontalOffset = (PhotoOverlayCanvas.ActualWidth - SelectedImage.ActualWidth) / 2;
                var verticalOffset   = (PhotoOverlayCanvas.ActualHeight - SelectedImage.ActualHeight) / 2;

                var localRectLeft = face.FaceRectangle.Left * widthRatio + horizontalOffset;
                var localRectTop  = face.FaceRectangle.Top * heightRatio + verticalOffset;

                StackPanel outlinePanel = new StackPanel()
                {
                    IsRightTapEnabled = true,
                    IsHitTestVisible  = true,
                    Background        = new SolidColorBrush(Colors.Transparent)
                };
                outlinePanel.RightTapped += async(o, e) =>
                {
                    var command = await menu.ShowForSelectionAsync(GetElementRect(o as FrameworkElement));
                };
                outlinePanel.Loaded += (s, e) =>
                {
                    Canvas.SetLeft(outlinePanel, localRectLeft - ((outlinePanel.ActualWidth - localRectWidth) / 2));
                    Canvas.SetTop(outlinePanel, localRectTop - (outlinePanel.ActualHeight - localRectHeight));
                };
                Grid grid = new Grid()
                {
                    Background = new SolidColorBrush(Colors.White)
                };
                TextBlock description = new TextBlock()
                {
                    Text                = string.Format("{0} year old {1}", face.Attributes.Age, face.Attributes.Gender),
                    Foreground          = new SolidColorBrush(Colors.Black),
                    HorizontalAlignment = HorizontalAlignment.Center
                };
                grid.Children.Add(description);
                outlinePanel.Children.Add(grid);
                outlinePanel.Children.Add(rect);
                PhotoOverlayCanvas.Children.Add(outlinePanel);

                menu.Commands.Add(new UICommand("Assign", async(o) =>
                {
                    var selectedFace = o.Id as Face;
                    await AssignFaceToPersonAsync(selectedFace);
                }, face));
                menu.Commands.Add(new UICommand("Identify", async(o) =>
                {
                    var selectedFace = o.Id as Face;
                    var person       = await IdentifyPersonAsync(selectedFace);
                    if (person != null)
                    {
                        description.Text = person.Name;
                        Canvas.SetLeft(outlinePanel, localRectLeft - ((outlinePanel.ActualWidth - localRectWidth) / 2));
                    }
                }, face));
            }
        }
Пример #51
0
 // LIFECYCLE METHODS
 private void Awake()
 {
     parentCanvas = GetComponentInParent <Canvas>();
     source       = GetComponentInParent <IDragSource <T> >();
 }
Пример #52
0
        void Init()
        {
            GameObject textObj = new GameObject("GMPDisplayText");

            chargeText          = textObj.AddComponent <TextMeshPro>();
            chargeText.text     = "Charges";
            chargeText.fontSize = 3;
            chargeText.color    = Color.white;
            chargeText.font     = Resources.Load <TMP_FontAsset>("Teko-Medium SDF No Glow");
            chargeText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 1f);
            chargeText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f);
            if (Plugin.Config.uiOnTop)
            {
                chargeText.rectTransform.position = new Vector3(0.1f, 3f, 7f);
                textObj.transform.localScale     *= 1.5f;
            }

            else
            {
                chargeText.rectTransform.position = new Vector3(0.2f, -1f, 7f);
                textObj.transform.localScale     *= 2.0f;
            }


            var counterImage = ReflectionUtil.GetPrivateField <Image>(
                Resources.FindObjectsOfTypeAll <ScoreMultiplierUIController>().First(), "_multiplierProgressImage");

            GameObject canvasobj = new GameObject("GMPDisplayCanvas");
            Canvas     canvas    = canvasobj.AddComponent <Canvas>();

            canvas.renderMode = RenderMode.WorldSpace;
            CanvasScaler cs = canvasobj.AddComponent <CanvasScaler>();

            cs.scaleFactor          = 10.0f;
            cs.dynamicPixelsPerUnit = 10f;
            GraphicRaycaster gr = canvasobj.AddComponent <GraphicRaycaster>();

            canvasobj.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 1f);
            canvasobj.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f);

            GameObject counter = new GameObject("GMPDisplayCounter");

            chargeCounter            = counter.AddComponent <Image>();
            counter.transform.parent = canvasobj.transform;
            counter.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 0.5f);
            counter.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0.5f);
            counter.transform.localScale = new Vector3(1f, 1f, 1f);

            chargeCounter.sprite        = counterImage.sprite;
            chargeCounter.type          = Image.Type.Filled;
            chargeCounter.fillMethod    = Image.FillMethod.Radial360;
            chargeCounter.fillOrigin    = (int)Image.Origin360.Top;
            chargeCounter.fillClockwise = true;
            chargeCounter.fillAmount    = Plugin.charges / Plugin.Config.maxCharges;
            chargeCounter.color         = Color.green;

            GameObject background = new GameObject("GMPDisplayBackGround");
            var        bg         = background.AddComponent <Image>();

            background.transform.parent = canvasobj.transform;
            background.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 0.5f);
            background.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0.5f);
            background.transform.localScale = new Vector3(1f, 1f, 1f);

            bg.sprite = counterImage.sprite;
            bg.CrossFadeAlpha(0.05f, 1f, false);

            canvasobj.GetComponent <RectTransform>().SetParent(textObj.transform, false);
            canvasobj.transform.localPosition = new Vector3(-0.1f, -.1f, 0f);

            chargeCountText           = new GameObject("GMPDisplayChargeCount").AddComponent <TextMeshPro>();
            chargeCountText.text      = Plugin.charges.ToString();
            chargeCountText.alignment = TextAlignmentOptions.Center;
            chargeCountText.fontSize  = 2.5f;
            chargeCountText.color     = Color.white;
            chargeCountText.font      = Resources.Load <TMP_FontAsset>("Teko-Medium SDF No Glow");
            chargeCountText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 1f);
            chargeCountText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f);
            chargeCountText.GetComponent <RectTransform>().SetParent(textObj.transform, false);
            chargeCountText.transform.localPosition = new Vector3(-0.0925f, -.13f, 0f);

            cooldownText           = new GameObject("GMPDisplayCoolDown").AddComponent <TextMeshPro>();
            cooldownText.text      = "";
            cooldownText.alignment = TextAlignmentOptions.MidlineRight;
            cooldownText.fontSize  = 2.5f;
            cooldownText.color     = Color.red;
            cooldownText.font      = Resources.Load <TMP_FontAsset>("Teko-Medium SDF No Glow");
            cooldownText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 10f);
            cooldownText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f);
            cooldownText.GetComponent <RectTransform>().SetParent(textObj.transform, false);
            cooldownText.transform.localPosition = new Vector3(-5.5f, -.13f, 0f);

            activeCommandText           = new GameObject("GMPDisplayActiveCommands").AddComponent <TextMeshPro>();
            activeCommandText.text      = "";
            activeCommandText.alignment = TextAlignmentOptions.MidlineLeft;
            activeCommandText.fontSize  = 2.5f;
            activeCommandText.color     = Color.yellow;
            activeCommandText.font      = Resources.Load <TMP_FontAsset>("Teko-Medium SDF No Glow");
            activeCommandText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 10f);
            activeCommandText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f);
            activeCommandText.GetComponent <RectTransform>().SetParent(textObj.transform, false);
            activeCommandText.transform.localPosition = new Vector3(5.3f, -.13f, 0f);
        }
Пример #53
0
 void Start()
 {
     _canvas = GetComponent<Canvas>();
 }
Пример #54
0
 public void SetEnvironment(Canvas canvas, GameObject questPrefab, QuestGiver questGiver)
 {
     this.canvas      = canvas;
     this.questPrefab = questPrefab;
     this.questGiver  = questGiver;
 }
Пример #55
0
        public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
        {
            if (IsNew)
            {
                Slice.Width  = chart.DrawMargin.Width;
                Slice.Height = chart.DrawMargin.Height;

                Slice.WedgeAngle    = 0;
                Slice.RotationAngle = 0;
            }

            if (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel)))
            {
                Canvas.SetTop(DataLabel, chart.DrawMargin.Height / 2);
                Canvas.SetLeft(DataLabel, chart.DrawMargin.Width / 2);
            }

            if (HoverShape != null)
            {
                var hs = (PieSlice)HoverShape;

                hs.Width         = chart.DrawMargin.Width;
                hs.Height        = chart.DrawMargin.Height;
                hs.WedgeAngle    = Wedge;
                hs.RotationAngle = Rotation;
                hs.InnerRadius   = InnerRadius;
                hs.Radius        = Radius;
            }

            Slice.Width  = chart.DrawMargin.Width;
            Slice.Height = chart.DrawMargin.Height;

            var lh = 0d;

            if (DataLabel != null)
            {
                DataLabel.UpdateLayout();
                lh = DataLabel.ActualHeight;
            }

            var hypo = ((PieSeries)current.SeriesView).LabelPosition == PieLabelPosition.InsideSlice
                ? (Radius + InnerRadius) * (Math.Abs(InnerRadius) < 0.01 ? .65 : .5)
                : Radius + lh;
            var gamma = current.Participation * 360 / 2 + Rotation;
            var cp    = new Point(hypo * Math.Sin(gamma * (Math.PI / 180)), hypo * Math.Cos(gamma * (Math.PI / 180)));

            if (chart.View.DisableAnimations)
            {
                Slice.InnerRadius   = InnerRadius;
                Slice.Radius        = Radius;
                Slice.WedgeAngle    = Wedge;
                Slice.RotationAngle = Rotation;
                Canvas.SetTop(Slice, chart.DrawMargin.Height / 2);
                Canvas.SetLeft(Slice, chart.DrawMargin.Width / 2);

                if (DataLabel != null)
                {
                    DataLabel.UpdateLayout();

                    var lx = cp.X + chart.DrawMargin.Width / 2 - DataLabel.ActualWidth * .5;
                    var ly = chart.DrawMargin.Height / 2 - cp.Y - DataLabel.ActualHeight * .5;

                    Canvas.SetLeft(DataLabel, lx);
                    Canvas.SetTop(DataLabel, ly);
                }

                return;
            }

            var animSpeed = chart.View.AnimationsSpeed;

            if (DataLabel != null)
            {
                DataLabel.UpdateLayout();

                var lx = cp.X + chart.DrawMargin.Width / 2 - DataLabel.ActualWidth * .5;
                var ly = chart.DrawMargin.Height / 2 - cp.Y - DataLabel.ActualHeight * .5;

                DataLabel.CreateCanvasStoryBoardAndBegin(lx, ly, animSpeed);
            }

            Slice.BeginDoubleAnimation("(Canvas.Left)", chart.DrawMargin.Width / 2, animSpeed);
            Slice.BeginDoubleAnimation("(Canvas.Top)", chart.DrawMargin.Height / 2, animSpeed);
            Slice.BeginDoubleAnimation(nameof(PieSlice.InnerRadius), InnerRadius, animSpeed);
            Slice.BeginDoubleAnimation(nameof(PieSlice.Radius), Radius, animSpeed);
            Slice.BeginDoubleAnimation(nameof(PieSlice.WedgeAngle), Wedge, animSpeed);
            Slice.BeginDoubleAnimation(nameof(PieSlice.RotationAngle), Rotation, animSpeed);
        }
Пример #56
0
        double curTopValue;         // текущая координата Top


        public OrderPageHelper(Canvas uiBuffer)
        {
            _canvas = uiBuffer;
        }
Пример #57
0
 /// <summary>
 /// Performs the event when button clicked.
 /// Sets the <see cref="Modes.Mode"/> of <see cref="Canvas"/> to the
 /// one held by this button.
 /// </summary>
 /// <param name="sender">
 /// The <seealso cref="object"/> that fires the event.
 /// </param>
 /// <param name="e">
 /// The <seealso cref="EventArgs"/> that holds information of event.
 /// </param>
 private void OnClickEvent(object sender, EventArgs e)
 {
     _parenToolBar.SetFocusItem(this);
     Canvas.GetInstance().CurrentMode = Mode;
 }
Пример #58
0
 // Start is called before the first frame update
 void Start()
 {
     Canvas_Lore         = GetComponent <Canvas>();
     Canvas_Lore.enabled = false;
 }
Пример #59
0
        protected override void OnAttached()
        {
            attachedElement = AssociatedObject;
            if (attachedElement is ListBox)
            {
                return;
            }

            var attachedElementPanel = attachedElement as Panel;

            if (attachedElementPanel != null)
            {
                attachedElementPanel.Loaded += (sl, el) =>
                {
                    var elements = attachedElementPanel.Children.Cast <UIElement>().ToList();

                    elements.ForEach(element =>
                                     Interaction.GetBehaviors(element).Add(
                                         new TiltBehavior
                    {
                        KeepDragging = KeepDragging,
                        TiltFactor   = TiltFactor
                    }));
                };

                return;
            }

            originalPanel = attachedElement.Parent as Panel ?? GetParentPanel(attachedElement);

            originalMargin = attachedElement.Margin;
            originalSize   = new Size(attachedElement.Width, attachedElement.Height);
            double              left   = Canvas.GetLeft(attachedElement);
            double              right  = Canvas.GetRight(attachedElement);
            double              top    = Canvas.GetTop(attachedElement);
            double              bottom = Canvas.GetBottom(attachedElement);
            int                 z      = Panel.GetZIndex(attachedElement);
            VerticalAlignment   va     = attachedElement.VerticalAlignment;
            HorizontalAlignment ha     = attachedElement.HorizontalAlignment;

            RotatorParent = new Planerator
            {
                Margin              = originalMargin,
                Width               = originalSize.Width,
                Height              = originalSize.Height,
                VerticalAlignment   = va,
                HorizontalAlignment = ha
            };

            RotatorParent.SetValue(Canvas.LeftProperty, left);
            RotatorParent.SetValue(Canvas.RightProperty, right);
            RotatorParent.SetValue(Canvas.TopProperty, top);
            RotatorParent.SetValue(Canvas.BottomProperty, bottom);
            RotatorParent.SetValue(Panel.ZIndexProperty, z);

            originalPanel.Children.Remove(attachedElement);
            attachedElement.Margin = new Thickness();
            attachedElement.Width  = double.NaN;
            attachedElement.Height = double.NaN;

            originalPanel.Children.Add(RotatorParent);
            RotatorParent.Child = attachedElement;

            CompositionTarget.Rendering += CompositionTargetRendering;
        }
Пример #60
-9
 void Start()
 {
     quitMenu = quitMenu.GetComponent<Canvas>();
     startMessage = startMessage.GetComponent<Button>();
     exitText = exitText.GetComponent<Button>();
     quitMenu.enabled = false;
 }