Esempio n. 1
0
        public TicTacToe()
            : base(0, 0, 0, 0, null, null, null)
        {
            SetupGrid(new ISize[] { new Relative(33), new Relative(33), new Relative(34) },
                      new ISize[] { new Relative(33), new Relative(33), new Relative(34) });

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    int cellType = (i + j) % 2;
                    this[i, j] = new VisualContainer(0, 0, 0, 0, null, new ContainerStyle()
                    {
                        Wall      = cellType == 0 ? WallID.AmberGemspark : WallID.AmethystGemspark,
                        WallColor = PaintID.White
                    }, callback: (self, touch) =>
                    {
                        int turn              = (int)self.Parent["turn"];
                        self["value"]         = turn;
                        Image image           = self.Add(new Image(0, 0, $"worldedit\\schematic-{(turn == 0 ? "X" : "O")}.dat")) as Image;
                        image.Style.TileColor = turn == 0 ? PaintID.DeepBlue : PaintID.DeepRed;
                        self.Update().Apply().Draw();
                        self.Parent["turn"] = 1 - turn;

                        // Check if someone has already won the game
                    });
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Invoked when exit from the view.
 /// </summary>
 /// <param name="listView">The SfListView</param>
 protected override void OnDetachingFrom(SfListView listView)
 {
     base.OnDetachingFrom(listView);
     this.container.PropertyChanged -= this.Container_PropertyChanged;
     this.container = null;
     this.ListView  = null;
 }
Esempio n. 3
0
    public void OnEnable()
    {
        var root = this.GetRootVisualContainer();

        //添加style.uss样式
        root.AddStyleSheetPath("style");

        var boxes = new VisualContainer();

        //设置自动换行
        boxes.style.flexDirection = FlexDirection.Row;
        boxes.style.flexWrap      = Wrap.Wrap;
        for (int i = 0; i < 20; i++)
        {
            TextField mTextField = new TextField();
            boxes.Add(mTextField);
            Button button = new Button(delegate() { Debug.LogFormat("Click"); })
            {
                text = "我是按钮我要自适应"
            };

            boxes.Add(button);
        }
        root.Add(boxes);
    }
Esempio n. 4
0
        public VisualContainer CreateTask(string name)
        {
            var task = new VisualContainer();

            task.focusIndex = 0;
            task.name       = name;
            task.AddToClassList("task");

            task.RegisterCallback <KeyDownEvent, VisualContainer>(DeleteTask, task);

            var taskName = new Toggle(() => {})
            {
                text = name, name = "checkbox"
            };

            task.Add(taskName);

            var taskDelete = new Button(() => task.parent.Remove(task))
            {
                name = "delete", text = "Delete"
            };

            task.Add(taskDelete);

            return(task);
        }
 protected override void OnAttachedTo(SfListView bindable)
 {
     ListView        = bindable;
     visualContainer = ListView.GetVisualContainer();
     visualContainer.ScrollRows.Changed += ScrollRows_Changed;
     base.OnAttachedTo(bindable);
 }
Esempio n. 6
0
        /// <summary>
        /// Перемещает позицию в таблице на позицию необходимой строки и выделяет найденную строку
        /// </summary>
        /// <param name="grid">Таблица для обработки</param>
        /// <param name="filePredicate">Проверка на корректность файла</param>
        /// <param name="stringPredicate">Проверка на корректность строки</param>
        public static void ScrollToFileAndSelectString(this SfDataGrid grid, Predicate <IEditableFile> filePredicate,
                                                       Predicate <IOneString> stringPredicate)
        {
            int parentIndex = grid.View.Records.FindWithIndex(it => filePredicate(it.Data.As <IEditableFile>())).index;

            if (parentIndex == -1)
            {
                return;
            }

            SfDataGrid detailsGrid = grid.GetDetailsViewGridWUpd("Details", parentIndex);

            VisualContainer container = grid.GetVisualContainer();

            container.ScrollRows.ScrollInView(grid.ResolveToRowIndex(parentIndex));

            int childIndex = detailsGrid.View.Records.FindWithIndex(it => stringPredicate(it.Data as IOneString)).index;

            if (childIndex == -1)
            {
                return;
            }

            detailsGrid.SelectedIndex = childIndex;

            for (int i = 0; i < childIndex; i++)
            {
                container.ScrollRows.ScrollToNextLine();
            }
        }
Esempio n. 7
0
        protected override void SetupInputFields(int width = 3, int height = 3)
        {
            style.alignContent  = new StyleValue <Align>(Align.Center);
            style.alignItems    = new StyleValue <Align>(Align.Center);
            style.flexDirection = new StyleValue <FlexDirection>(FlexDirection.Row);

            const int pad         = 4;
            var       fieldWidth  = (this.style.width / width) - pad - 2;
            var       fieldHeight = (this.style.height / height / 2) - pad;

            for (var i = 0; i < width; i++)
            {
                var x         = (fieldWidth + pad) * i;
                var container = new VisualContainer();
                container.style.width         = fieldWidth;
                container.style.flexDirection = FlexDirection.Row;
                for (var j = 0; j < height; j++)
                {
                    var input = new FloatField(6);
                    input.style.width        = fieldWidth - 16;
                    input.style.positionLeft = x;
                    input.style.positionTop  = fieldHeight * j;
                    input.style.positionType = PositionType.Absolute;
                    input.OnValueChanged(OnMatrixInputUpdate);
                    MatrixInputs[i, j] = input;
                    container.Add(input);
                }

                Add(container);
            }
        }
    public void InitializeVisualElement(VisualContainer _vContainer, VarPass _nodeConnection)
    {
        vContainer = _vContainer;
        varPass = _nodeConnection;

        //Get Names for our variables
        if (varPass.dataDirection == DataDirection.OutcomeData) {
            //adjust name position

            if(vContainer.node.outConNames.ContainsKey(varPass.varType)){
                if(vContainer.node.outConNames[varPass.varType].Count > varPass.num){
                    elName.text = vContainer.node.outConNames[varPass.varType][varPass.num];
                }
            }

        }

        if (varPass.dataDirection == DataDirection.IncomeData) {
            //adjust name position
            elName.alignment = TextAnchor.MiddleLeft;
            elName.rectTransform.anchoredPosition = new Vector2(elName.rectTransform.anchoredPosition.x * -1, elName.rectTransform.anchoredPosition.y);

            if(vContainer.node.inConNames.ContainsKey(varPass.varType)){
                if(vContainer.node.inConNames[varPass.varType].Count > varPass.num){
                    elName.text = vContainer.node.inConNames[varPass.varType][varPass.num];
                }
            }

        }
    }
Esempio n. 9
0
        protected override void OnEnteredEditMode(DataColumnBase dataColumn, FrameworkElement currentRendererElement)
        {
#if WPF
            VisualContainer.SetWantsMouseInput(currentRendererElement, false);
#endif
            base.OnEnteredEditMode(dataColumn, currentRendererElement);
        }
Esempio n. 10
0
 /// <summary>
 /// Invoked when adding list view to view.
 /// </summary>
 /// <param name="listView">The SfListView</param>
 protected override void OnAttachedTo(SfListView listView)
 {
     base.OnAttachedTo(listView);
     this.ListView  = listView;
     this.container = listView.GetVisualContainer();
     this.container.PropertyChanged += this.Container_PropertyChanged;
 }
Esempio n. 11
0
        public UdonProgramSourceView()
        {
            // Create and add container and children to display latest Assembly
            _assemblyContainer = new VisualContainer()
            {
                name = "Container",
            };
            _assemblyHeader = new Label("Udon Assembly")
            {
                name = "Header",
            };

            _scrollView = new ScrollView();

            _assemblyField = new TextElement()
            {
                name = "AssemblyField",
            };

            _assemblyContainer.Add(_assemblyHeader);
            _assemblyContainer.Add(_scrollView);
            _assemblyContainer.Add(_assemblyField);
            _scrollView.SetContents(_assemblyField);

            Add(_assemblyContainer);
        }
Esempio n. 12
0
        internal void GetMatchersFor(VisualElement element, List <RuleMatcher> ruleMatchers, List <StyleSheet> stylesheets)
        {
            List <VisualElement> list = new List <VisualElement>();

            list.Add(element);
            VisualContainer visualContainer = element as VisualContainer;

            if (visualContainer == null)
            {
                visualContainer = element.parent;
            }
            while (visualContainer != null)
            {
                if (visualContainer.styleSheets != null)
                {
                    stylesheets.AddRange(visualContainer.styleSheets);
                    this.AddMatchersFromSheet(visualContainer.styleSheets);
                }
                list.Add(visualContainer);
                visualContainer = visualContainer.parent;
            }
            int num = 0;

            for (int i = list.Count - 1; i >= 0; i--)
            {
                this.GetMatchersFor(list, i, num++, ruleMatchers);
            }
            this.m_Matchers.Clear();
        }
Esempio n. 13
0
    private void TaskInputSection(VisualElement root)
    {
        VisualContainer row = new VisualContainer {
            name = "newTaskRow"
        };

        root.Add(row);
        if (_newTaskName == null)
        {
            _newTaskName = new TextField()
            {
                name = "newTaskNameInput"
            };
            _newTaskName.RegisterCallback <KeyUpEvent>(TaskNameKeyDownCallback);
        }

        row.Add(_newTaskName);

        Button newTaskButton = new Button(NewTodoTask)
        {
            name = "newTaskButton", text = "Add Task"
        };

        row.Add(newTaskButton);
    }
Esempio n. 14
0
        public void OnEnable()
        {
            var root = this.GetRootVisualContainer();

            root.AddStyleSheetPath("styles");

            // Here we just take all layout properties and other to extract them in USS!
            var boxes = new VisualContainer()
            {
                name = "boxesContainer"
            };

            boxes.AddToClassList("horizontalContainer");
            root.Add(boxes);

            for (int i = 0; i < m_Colors.Length; i++)
            {
                Color c = m_Colors[i];

                // inform layout system of desired width for each box
                boxes.Add(new VisualElement()
                {
                    style =
                    {
                        backgroundColor = c
                    }
                });
            }

            // Some more advanced layout now!
            var twoPlusOneContainer = new VisualContainer()
            {
                name = "2Plus1Container"
            };

            twoPlusOneContainer.AddToClassList("horizontalContainer");
            root.Add(twoPlusOneContainer);
            twoPlusOneContainer.Add(new VisualElement()
            {
                name = "large"
            });
            twoPlusOneContainer.Add(new VisualElement()
            {
                name = "small"
            });

            var wrapContainer = new VisualContainer()
            {
                name = "wrapContainer"
            };

            wrapContainer.AddToClassList("horizontalContainer");
            root.Add(wrapContainer);

            for (int i = 0; i < 20; i++)
            {
                wrapContainer.Add(new VisualElement());
            }
        }
        public void Load(GenericEntity item, Transform parent)
        {
            GameObject entityObj = VisualContainer.CreateObject(item.Type.IdName, item.Location, 0.2f, parent);

            item.Instance        = entityObj.AddComponent <EntityManager>();
            item.Object          = entityObj;
            item.Instance.Entity = item;
        }
Esempio n. 16
0
 protected override void OnDetachingFrom(SfListView bindable)
 {
     base.OnDetachingFrom(bindable);
     scrollview.Scrolled -= Scrollview_Scrolled;
     container            = null;
     scrollview           = null;
     listview             = null;
 }
 public CatalogListPage(string OfferCode)
 {
     InitializeComponent();
     vm              = new CatalogPageViewModel(OfferCode);
     BindingContext  = vm;
     visualContainer = ListViewList.GetVisualContainer();
     visualContainer.ScrollRows.Changed += ScrollRows_Changed;
 }
Esempio n. 18
0
 protected override void OnDetachingFrom(ContentPage bindable)
 {
     Button.Clicked -= Button_Clicked;
     Button          = null;
     ListView        = null;
     Container       = null;
     base.OnDetachingFrom(bindable);
 }
Esempio n. 19
0
        protected override void OnAttachedTo(ContentPage bindable)
        {
            ListView         = bindable.FindByName <SfListView>("ListView");
            ListView.Loaded += ListView_Loaded;
            visualContainer  = ListView.GetVisualContainer();

            base.OnAttachedTo(bindable);
        }
Esempio n. 20
0
    void OnMouseUp()
    {
        if (draggingThis)
        {
            dragging     = false;
            draggingThis = false;
            StartCoroutine(DelayPreviews());  // re-enable previews after 0.25 seconds (so previews don't immediately pop up when releasing a card)
            string cardName         = GetComponent <CardInfo>().cardName;
            bool   targetsPlayers   = GetComponent <CardInfo>().targetsPlayers;
            bool   canTargetSelf    = GetComponent <CardInfo>().canTargetSelf;
            string hit              = DetectHit(targetsPlayers, canTargetSelf);
            bool   returnToPosition = true;

            // if it's your main step
            if (Logic.Instance.currentPlayer == Player.localPlayer && Logic.Instance.mainStepActive && Logic.Instance.currentEvent == null)
            {
                if (cardName == "shootSpring" && hit != null)
                {
                    Player.localPlayer.CmdShoot(hit, transform.GetSiblingIndex());
                    returnToPosition = false;
                }
            }
            // if you're reacting to an event
            else if (Logic.Instance.currentEvent != null)
            {
                VisualContainer vcHand       = Player.localPlayer.visual.transform.Find("Hand").GetComponent <VisualContainer>();
                VisualContainer vcIntentArea = GameObject.Find("Visual/IntentArea").GetComponent <VisualContainer>();

                if (cardName == "grazeSpring" && hit == "PlayArea" && transform.parent.name == "Hand")
                {
                    Player.localPlayer.CmdIntendGraze();
                    transform.GetComponent <HoverPreview>().ThisPreviewEnabled = false;

                    vcHand.Remove(transform);
                    vcHand.Adjust(transform.childCount);
                    vcIntentArea.Add(transform);
                    vcIntentArea.Adjust(transform.childCount);

                    returnToPosition = false;
                }

                if (cardName == "grazeSpring" && hit == "HandArea" && transform.parent.name == "IntentArea")
                {
                    vcIntentArea.Remove(transform);
                    vcIntentArea.Adjust(transform.childCount);
                    vcHand.Add(transform);
                    vcHand.Adjust(transform.childCount);

                    returnToPosition = false;
                }
            }

            if (returnToPosition)
            {
                StartCoroutine(PlayAnimation("ReturnToPosition"));
            }
        }
    }
Esempio n. 21
0
        public UdonArrayInspector(System.Action <object> valueChangedAction, object value)
        {
            _setValueCallback = valueChangedAction;

            AddToClassList("input-inspector");
            var resizeContainer = new VisualElement()
            {
                name = "resize-container",
            };

            resizeContainer.Add(new Label("size"));

            _sizeField           = new IntegerField();
            _sizeField.isDelayed = true;
            _sizeField.OnValueChanged((evt) =>
            {
                ResizeTo(evt.newValue);
            });
            resizeContainer.Add(_sizeField);
            Add(resizeContainer);

            _scroller = new ScrollView()
            {
                name = "array-scroll",
            };
            Add(_scroller);

            _container = new VisualContainer();
            _scroller.SetContents(_container);

            if (value == null)
            {
                // Can't show if array is empty
                _sizeField.value = 0;
                return;
            }
            else
            {
                IEnumerable <T> values = (value as IEnumerable <T>);
                if (values == null)
                {
                    Debug.LogError($"Couldn't convert {value} to {typeof(T).ToString()} Array");
                    return;
                }

                // Populate fields and their values from passed-in array
                _fields = new List <VisualElement>();
                foreach (var item in values)
                {
                    var field = GetValueField(item);
                    _fields.Add(field);

                    _container.Add(field);
                }

                _sizeField.value = values.Count();
            }
        }
Esempio n. 22
0
        protected override void OnAttachedTo(ContentPage bindable)
        {
            ListView        = bindable.FindByName <SfListView>("listView");
            Button          = bindable.FindByName <Button>("scrollButton");
            Container       = ListView.GetVisualContainer();
            Button.Clicked += Button_Clicked;

            base.OnAttachedTo(bindable);
        }
Esempio n. 23
0
 public TextHighlighter(string highlightClass, ILifetimeManager <Label> labels = null)
 {
     _container = new VisualContainer();
     _container.style.flexDirection = FlexDirection.Row;
     _labels = new ObjectList <Label>(
         labels ?? ListPool.New(() => new Label())
         );
     _highlightClass = highlightClass;
 }
 public MainPage()
 {
     InitializeComponent();
     ViewModel          = new MainPageViewModel();
     BindingContext     = ViewModel;
     ViewModel.ListView = this.ListView;
     ListView.Loaded   += ListView_Loaded;
     visualContainer    = ListView.GetVisualContainer();
 }
Esempio n. 25
0
        /// <summary>
        /// Called when [create edit unique identifier element].
        /// </summary>
        /// <returns></returns>
        protected override ComboBox OnCreateEditUIElement()
        {
            var comboBox = base.OnCreateEditUIElement();

#if WPF
            VisualContainer.SetWantsMouseInput(comboBox, true);
#endif
            return(comboBox);
        }
Esempio n. 26
0
 protected override void OnAttachedTo(SfListView bindable)
 {
     base.OnAttachedTo(bindable);
     listview  = bindable as SfListView;
     viewModel = new ViewModel();
     listview.BindingContext = viewModel;
     container            = listview.GetVisualContainer();
     scrollview           = listview.GetScrollView();
     scrollview.Scrolled += Scrollview_Scrolled;
 }
Esempio n. 27
0
 public void DeleteTask(KeyDownEvent e, VisualContainer task)
 {
     if (e.keyCode == KeyCode.Delete)
     {
         if (task != null)
         {
             task.parent.Remove(task);
         }
     }
 }
Esempio n. 28
0
        protected override void OnAttachedTo(ContentPage bindable)
        {
            ListView = bindable.FindByName <SfListView>("listView");
            VM       = new ContactsViewModel();
            ListView.BindingContext = VM;
            AddButton          = bindable.FindByName <Button>("addItem");
            AddButton.Clicked += AddItem_Clicked;
            visualContainer    = ListView.GetVisualContainer();

            base.OnAttachedTo(bindable);
        }
Esempio n. 29
0
 public SettingTabView()
 {
     InitializeComponent();
     BindingContext = viewModel;
     UpdateSettingItem();
     viewModel.heightImages = 150;
     this.listView.DragDropController.UpdateSource = true;
     container            = listView.GetVisualContainer();
     scrollview           = listView.GetScrollView();
     scrollview.Scrolled += Scrollview_Scrolled;
 }
Esempio n. 30
0
        /// <summary>
        /// Called when [create edit unique identifier element].
        /// </summary>
        /// <returns></returns>
        protected override SfMultiColumnDropDownControl OnCreateEditUIElement()
        {
            var sfMultiColumnDropDownControl = base.OnCreateEditUIElement();

#if WPF
            VisualContainer.SetWantsMouseInput(sfMultiColumnDropDownControl, true);
            //WPF-29023 - While using GridMultiColumnDropDownList column, no need to set the BorderThickness to SfMultiColumnDropDownControl.
            sfMultiColumnDropDownControl.BorderThickness = new Thickness(1);
#endif
            return(sfMultiColumnDropDownControl);
        }
Esempio n. 31
0
 public ReuseList(System.Func <T> spawner)
 {
     _parent  = new VisualContainer();
     _entries = new List <T>();
     _pool    = ListPool.New(() =>
     {
         var entry = spawner();
         _parent.Add(entry.Element);
         return(entry);
     }
                             );
 }
 void ShowElementsConnections(VisualContainer _container)
 {
     Debug.Log ("Processing container "+_container.node.nodeName);
     for (int i = 0; i < _container.vOutElements.Count; i++) {
         List <VarPass> oppCons = _container.node.outConnections[i].oppositeConnections;
         for (int con = 0; con < oppCons.Count; con++) {
             GameObject lineGO = Instantiate(connectionPrefab, Vector3.zero, Quaternion.identity) as GameObject;
             lineGO.transform.SetParent(_container.vOutElements[i].transform);
             VarPassUI conUI = lineGO.GetComponent<VarPassUI>();
             conUI.varPass = oppCons[con];
             conUI.InitializeConnectionUI(_container.vOutElements[i], elementsVisualsDict[oppCons[con]]);
             _container.vOutElements[i].AddConnection(conUI);
         }
     }
 }
    void ShowNodeElements(VisualContainer _container)
    {
        for (int i = 0; i < _container.node.inConnections.Count; i++) {
            GameObject element = Instantiate(varElementPrefab, Vector3.zero, Quaternion.identity) as GameObject;
            element.transform.SetParent(_container.inputTrans);
            RectTransform rTrans = element.GetComponent<RectTransform>();
            rTrans.localScale = Vector3.one;
            rTrans.anchoredPosition3D = new Vector3(rTrans.anchoredPosition3D.x, rTrans.anchoredPosition3D.y, 0);
            VisualElement elVisual = element.GetComponent<VisualElement> ();
            _container.vInElements.Add(elVisual);
            elementsVisualsDict.Add(_container.node.inConnections[i], elVisual);
            elVisual.InitializeVisualElement(_container, _container.node.inConnections[i]);

        }

        for (int i = 0; i < _container.node.outConnections.Count; i++) {
            GameObject elementGO = Instantiate(varElementPrefab, Vector3.zero, Quaternion.identity) as GameObject;
            RectTransform rTrans = elementGO.GetComponent<RectTransform>();
            elementGO.transform.SetParent(_container.outputTrans);
            rTrans.localScale = Vector3.one;
            rTrans.anchoredPosition3D = new Vector3(rTrans.anchoredPosition3D.x, rTrans.anchoredPosition3D.y, 0);
            VisualElement elVisual = elementGO.GetComponent<VisualElement> ();
            _container.vOutElements.Add(elVisual);
            elementsVisualsDict.Add(_container.node.outConnections[i], elVisual);
            elVisual.InitializeVisualElement(_container, _container.node.outConnections[i]);
        }
    }
 void ShowInputNodeConnections(VisualContainer _container)
 {
 }