public void AddPreIcon(Image preIcon)
        {
            this.Insert(0, preIcon);
            preIcon.RegisterCallback <MouseDownEvent>(evt =>
            {
                this.value = !this.value;
            });
            preIcon.AddToClassList(UssClasses.DotsEditorCommon.CustomToolbarToggleIcon);

            m_Label = this.Q <Label>();

            m_Label.RemoveFromClassList(UssClasses.DotsEditorCommon.CustomToolbarToggleOnlyLabel);
            m_Label.AddToClassList(UssClasses.DotsEditorCommon.CustomToolbarToggleLabel);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor of the ComponentTypeVisualElement.
        /// Given an component type, a visual element contains <see cref="CustomToolbarToggle"/>
        /// and an icon representing its access mode will be created.
        /// <para><see cref="ComponentType"/>></para>>
        /// </summary>
        public ComponentToggleWithAccessMode(ComponentType.AccessMode accessMode)
        {
            this.AddToClassList(UssClasses.SystemScheduleWindow.Detail.EachComponentContainer);

            // Access mode.
            var componentAccessModeIcon = new Image()
            {
                tooltip = accessMode.ToString()
            };

            componentAccessModeIcon.AddToClassList(UssClasses.SystemScheduleWindow.Detail.ComponentAccessModeIcon);
            componentAccessModeIcon.AddToClassList(EntityQueryUtility.StyleForAccessMode(accessMode));

            // Component toggle.
            ComponentTypeNameToggle = new CustomToolbarToggle();
            ComponentTypeNameToggle.AddPreIcon(componentAccessModeIcon);
            this.Add(ComponentTypeNameToggle);
        }
Ejemplo n.º 3
0
        public override void Initialize()
        {
            base.Initialize();
            _canvasImage = _rootElement.Q <Image>("CanvasImage");
            _canvasImage.RegisterCallback <PointerDownEvent>(e => PaintDocument.StartPainting());
            _canvasImage.RegisterCallback <PointerUpEvent>(e => PaintDocument.StopPainting());

            _toolButtons = new ToolButton[PaintDocument.Tools.Length];
            for (var i = 0; i < PaintDocument.Tools.Length; i++)
            {
                var tool = PaintDocument.Tools[i];
                if (tool == null)
                {
                    throw new Exception("Empty tool in tools list of PaintView");
                }
                _toolButtons[i]          = _rootElement.Q <ToolButton>(tool.name);
                _toolButtons[i].Clicked += () => SelectTool(tool);

                if (tool.name == "EraserTool")
                {
                    _toolButtons[i].DoubleClicked += PaintDocument.Clear;
                }
            }

            _undoButton          = _rootElement.Q <ToolButton>("Undo");
            _undoButton.Clicked += () => PaintDocument.Undo();
            _redoButton          = _rootElement.Q <ToolButton>("Redo");
            _redoButton.Clicked += () => PaintDocument.Redo();

            _closeButton          = _rootElement.Q <ToolButton>("Close");
            _closeButton.Clicked += () => OpenView("BookView");

            _colorPalette         = _rootElement.Q <ColorPalette>();
            _colorPalette.Choices = ColorSet.Colors;
            _colorPalette.RegisterCallback <ChangeEvent <Color> >(evt => PaintDocument.Color = evt.newValue);
            _colorPalette.Value = PaintDocument.Color;

            _brushSizePalette         = _rootElement.Q <BrushSizePalette>();
            _brushSizePalette.Choices = BrushSizeSet.BrushSizes;
            _brushSizePalette.RegisterCallback <ChangeEvent <float> >(evt => PaintDocument.BrushSize = evt.newValue);
            _brushSizePalette.Value = PaintDocument.BrushSize;
        }
Ejemplo n.º 4
0
    public void OnEnable()
    {
        var root = this.rootVisualElement;

        #region Label
        m_Label = new Label()
        {
            text = "Clients"
        };
        m_Label.style.fontSize = 20f;
        m_Label.style.color    = new Color(1f, 0f, 0.25f);

        #endregion
        #region KillFeedLabel
        m_KillFeedLabel = new Label()
        {
            text = "Kill Feed"
        };
        m_KillFeedLabel.style.fontSize = 20f;
        m_KillFeedLabel.style.color    = new Color(0.33f, 0.5f, 0.45f);

        #endregion
        #region Client Field
        m_IntField = new IntegerField()
        {
            bindingPath = "ClientCount"
        };
        m_IntField.style.unityTextAlign = new StyleEnum <TextAnchor>(TextAnchor.MiddleCenter);
        m_IntField.style.fontSize       = 20;
        #endregion
        #region Wi-Fighters Logo
        m_Logo = new Image()
        {
            image = Resources.Load("Images/Wi-Fighters") as Texture
        };
        m_Logo.style.alignSelf = new StyleEnum <Align>(Align.Center);
        m_Logo.style.width     = 300f;
        m_Logo.style.height    = 50f;
        m_Logo.style.top       = 7;
        #endregion
        #region KillFeed Section
        m_RefreshKillFeed = new Button();

        m_Killer = new TextField();
        m_Killed = new TextField();
        m_Killer.style.maxWidth    = 70;
        m_Killed.style.maxWidth    = 70;
        m_RefreshKillFeed.text     = "Refresh Kill";
        m_RefreshKillFeed.clicked += RefreshKillFeed;
        #endregion
        root.Add(m_Logo);
        root.Add(m_Label);
        root.Add(m_IntField);

        root.Add(m_KillFeedLabel);
        root.Add(m_Killer);
        root.Add(m_Killed);
        root.Add(m_RefreshKillFeed);

        Bind();
    }