private void InitializeToSelectedPlayer()
        {
            List <DynamicColumn> columns = SelectedGameStatistics.Players.Select(x => new DynamicColumn
            {
                Name        = x.PlayerName,
                DisplayName = x.PlayerName,
                Type        = typeof(int),
                IsReadOnly  = true,
            }).ToList();
            List <Specials>             specials = SelectedGameStatistics.Players.Where(p => p.SpecialsUsed != null).SelectMany(p => p.SpecialsUsed.Select(kv => kv.Key)).Distinct().ToList();
            List <SpecialStatisticsRow> rows     = specials.Select(x => new SpecialStatisticsRow
            {
                Special = x
            }).ToList();

            foreach (GameStatisticsByPlayer statsByPlayer in SelectedGameStatistics.Players)
            {
                foreach (SpecialStatisticsRow row in rows)
                {
                    int value = 0;
                    if (statsByPlayer.SpecialsUsed != null && statsByPlayer.SpecialsUsed.ContainsKey(row.Special))
                    {
                        KeyValuePair <string, int> kv = statsByPlayer.SpecialsUsed[row.Special].FirstOrDefault(x => x.Key == SelectedPlayer);
                        value = kv.Equals(default(KeyValuePair <string, int>)) ? 0 : kv.Value;
                    }
                    row.TryAddProperty(statsByPlayer.PlayerName, value);
                }
            }
            SpecialsToSelectedPlayerGrid = new DynamicGrid <SpecialStatisticsRow, DynamicColumn>(rows, columns);
        }
        private async void CheckBox_Unchecked(object sender, RoutedEventArgs e)
        {
            CheckBox cb        = sender as CheckBox;
            int      tempID    = Int32.Parse(cb.Name.Substring(1));
            string   stBor128  = "Bor128" + tempID;
            string   stBor204  = "Bor204" + tempID;
            Border   border128 = (Border)DynamicGrid.FindName(stBor128);
            Border   border204 = (Border)DynamicGrid.FindName(stBor204);

            if (border128 != null)
            {
                border128.Background         = new SolidColorBrush(Color.FromRgb(128, 0, 0));
                border128.Background.Opacity = 0.5;
            }
            else
            {
                border204.Background         = new SolidColorBrush(Color.FromRgb(204, 0, 0));
                border204.Background.Opacity = 0.5;
            }


            if (EventHandler)
            {
                string        stPaid = "P" + tempID;
                DecimalUpDown paid   = (DecimalUpDown)DynamicGrid.FindName(stPaid);
                paid.Value = 0.0m;
            }
        }
Example #3
0
    /// <summary>
    /// 设置单个cell位置
    /// </summary>
    /// <param name="grid"></param>
    /// <param name="index"></param>
    void SetGridsAlongAxis(int axis, DynamicGrid grid, int index)
    {
        //得到當前曲线的值
        float showCount = GetShowingCount();
        float fValue    = 0.5f - (CurOffsetValue - index * InteralFactor) / InteralFactor / showCount;

        //取出当前各个曲线的值
        float posCurveValue   = GetPositionValue(fValue, 0);
        float scaleCurveValue = GetScaleValue(fValue, 0);
        float depthCurveValue = DepthCurve.Evaluate(fValue);

        //设置位置和缩放
        grid.name = index.ToString();
        float size = ViewSize[axis] * SpaceRate;

        int order = Order == LayoutRule.Order.Positive ? 1 : -1;

        if (axis == 0)
        {
            grid.rectTransform.anchoredPosition = new Vector2((posCurveValue * size - size / 2) * order, AxisOffset);
        }
        else
        {
            grid.rectTransform.anchoredPosition = new Vector2(AxisOffset, (posCurveValue * size - size / 2) * order);
        }

        grid.rectTransform.localScale = new Vector3(scaleCurveValue, scaleCurveValue, scaleCurveValue);
        grid.rectTransform.sizeDelta  = GridSize;
        //设置深度
        int newDepth = (int)(depthCurveValue * (float)transform.childCount);

        grid.rectTransform.SetSiblingIndex(newDepth);
    }
        private void ComponentLoad()
        {
            DynamicGrid dynamicGrid = new DynamicGrid(Enums.DynamicGridEnum.Custom, 30, 20, 20, 30)
            {
                VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand
            };

            dynamicGrid.AddView(new BoxView()
            {
                BackgroundColor = Color.Aqua, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand
            });
            dynamicGrid.AddView(new BoxView()
            {
                BackgroundColor = Color.Black, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand
            });
            dynamicGrid.AddView(new BoxView()
            {
                BackgroundColor = Color.Violet, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand
            });
            dynamicGrid.AddView(new BoxView()
            {
                BackgroundColor = Color.Yellow, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand
            });
            dynamicGrid.AddView(new BoxView()
            {
                BackgroundColor = Color.Aquamarine, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, HeightRequest = 60
            });
            Content = dynamicGrid;
        }
    protected override void OnDestroy()
    {
        base.OnDestroy();

        Grid = null;
        Clear();
    }
Example #6
0
    /// <summary>
    /// 根据Index更新Grid
    /// </summary>
    /// <param name="index"></param>
    /// <returns></returns>
    protected virtual DynamicGrid TableGridAtIndex(int index)
    {
        if (index < 0 || index >= TotalCount)
        {
            return(null);
        }

        DynamicGrid grid = LoadGridFormPool();

        if (grid == null)
        {
            Debug.LogErrorFormat("DynamicTableCurve load grid at index {0} fail!", index);
        }

        grid.Index = index;
        UsingGridSet.Add(grid);


        OnTableGridAtIndex(grid);

        if (!grid.gameObject.activeSelf)
        {
            grid.gameObject.SetActive(true);
        }


        //设置位置
        SetGridsAlongAxis((int)Direction, grid, index);

        return(grid);
    }
        private View GetItem(ReportViewModel model)
        {
            StackLayout sl = new StackLayout()
            {
                Padding = 0, Margin = 0, Spacing = 0
            };
            DynamicGrid dynamicGrid = new DynamicGrid(DynamicGridEnum.Custom, 45, 55)
            {
                Padding = 0, HeightRequest = 20
            };

            dynamicGrid.AddView(new Label()
            {
                Text = $"{model.Name}", HorizontalTextAlignment = TextAlignment.Start, VerticalTextAlignment = TextAlignment.Center, TextColor = Color.Black, Margin = 0
            });
            dynamicGrid.AddView(new Label()
            {
                Text = $"{model.Value} TL", FontAttributes = FontAttributes.Bold, HorizontalTextAlignment = TextAlignment.Start, VerticalTextAlignment = TextAlignment.Center, Margin = 0, TextColor = Color.Black
            });
            sl.Children.Add(dynamicGrid);
            sl.Children.Add(new PercentShowCardView(Color.Green, Color.Red, model.Percent, Color.Black, 88, 12)
            {
                Margin = 0, Padding = 0
            });
            sl.Children.Add(new Line(LineEnum.Horizontal)
            {
                Margin = new Thickness(0, 10, 0, 0)
            });
            return(sl);
        }
    /// <summary>
    /// 根据Index更新Cell
    /// </summary>
    /// <param name="index"></param>
    /// <returns></returns>
    public virtual DynamicGrid DynamicGridAtIndex(int index)
    {
        if (index <= 0 || index - START_INDEX >= TotalCount)
        {
            Debug.LogErrorFormat("Index {0} Overflow TotalCount {1}", index, TotalCount);
            return(null);
        }

        DynamicGrid grid = LoadGridFormPool();

        if (grid == null)
        {
            Debug.LogErrorFormat("DynamicTable Load Grid at Index {0} Fail!", index);
        }

        grid.Index = index;
        UsingGridSet.Add(grid);

        //设置位置
        OnTableGridAtIndex(grid);

        if (!grid.gameObject.activeSelf)
        {
            grid.gameObject.SetActive(true);
        }

        SetGridsAlongAxis(grid, index);

        return(grid);
    }
Example #9
0
        private void Conway()
        {
            //increase the border to easily allow detection of border tiles (if the borders were to be realigned, mid conway, it would break)
            lobby.IncreaseX(true);
            lobby.IncreaseX(false);
            lobby.IncreaseY(true);
            lobby.IncreaseY(false);
            //create a copy of our lobby with the lobbys dimensions
            DynamicGrid <bool> newLobby = new DynamicGrid <bool>(lobby.XDim, lobby.YDim);

            //classic conway. determine the new state based on the counted neighbours
            for (int y = 0; y < lobby.YDim; ++y)
            {
                for (int x = 0; x < lobby.XDim; ++x)
                {
                    int  neighbours = GetTileNeighbours(x, y);
                    bool tileState  = false;
                    if (lobby[x, y])
                    {
                        tileState = neighbours >= 1 && neighbours <= 2;
                    }
                    else
                    {
                        tileState = neighbours == 2;
                    }
                    newLobby[x, y] = tileState;
                }
            }
            //remove excess borders, to avoid excessive growth (it's pretty large as it is.)
            newLobby.CutDown();
            lobby = newLobby;
        }
Example #10
0
        private DynamicGrid GetFormContent()
        {
            DynamicGrid dynamicGrid = new DynamicGrid(Enums.DynamicGridEnum.Star, 2, 50)
            {
                ColumnSpacing = 5, RowSpacing = 5
            };

            dynamicGrid.AddView(new Entry()
            {
                Placeholder = "Ad-Soyad", ClassId = nameof(_model.Name)
            });
            dynamicGrid.AddView(new Entry()
            {
                Placeholder = "Telefon", ClassId = nameof(_model.Phone)
            });
            dynamicGrid.AddView(new Picker()
            {
                ItemsSource = new List <string>()
                {
                    "Malatya", "Istanbul"
                }, Title = "İl", ClassId = nameof(_model.City)
            });
            dynamicGrid.AddView(new Picker()
            {
                ItemsSource = new List <string>()
                {
                    "Babıhtı", "Çırmıhtı"
                }, Title = "İlçe", ClassId = nameof(_model.District)
            });
            return(dynamicGrid);
        }
Example #11
0
        public MainPage()
        {
            StackLayout sl          = new StackLayout();
            DynamicGrid dynamicGrid = new DynamicGrid(Enums.DynamicGridEnum.Custom, 20, 50, 20, 0);

            dynamicGrid.AddView(new BoxView()
            {
                BackgroundColor = Color.AliceBlue
            });
            dynamicGrid.AddView(new BoxView()
            {
                BackgroundColor = Color.Aqua
            });
            dynamicGrid.AddView(new BoxView()
            {
                BackgroundColor = Color.AntiqueWhite
            });
            dynamicGrid.AddView(new BoxView()
            {
                BackgroundColor = Color.Azure
            });
            sl.Children.Add(new PercentShowCardView(Color.Beige, Color.Bisque, 60, Color.Black, 90, 10));
            sl.Children.Add(dynamicGrid);
            Content = sl;
        }
 private void OnHorizontalDynamicTableViewCallBack(int evt, int index, DynamicGrid grid)
 {
     if (evt == (int)LayoutRule.DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX)
     {
         TestNormalGrid testGrid = grid as TestNormalGrid;
         testGrid.SetContent(index);
     }
 }
 /// <summary>
 /// 回收节点
 /// </summary>
 /// <param name="index"></param>
 public void OnTableGridRecycle(DynamicGrid grid)
 {
     if (DynamicTableGridDelegate == null)
     {
         return;
     }
     DynamicTableGridDelegate((int)LayoutRule.DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE, grid.Index, grid);
 }
 /// <summary>
 /// Grid被点击
 /// </summary>
 /// <param name="index"></param>
 public void OnTableGridTouched(DynamicGrid grid, PointerEventData eventData = null)
 {
     if (DynamicTableGridDelegate == null)
     {
         return;
     }
     DynamicTableGridDelegate((int)LayoutRule.DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED, grid.Index, grid);
 }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="index"></param>
 public void OnTableGridAtIndex(DynamicGrid grid)
 {
     if (DynamicTableGridDelegate == null)
     {
         return;
     }
     DynamicTableGridDelegate((int)LayoutRule.DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX, grid.Index, grid);
 }
 private void DynamicTableGridDelegateEx2(int evt, int index, DynamicGrid grid)
 {
     if (evt == (int)LayoutRule.DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX)
     {
         TestNormalGrid testGrid = grid as TestNormalGrid;
         testGrid.SetContent(index);
     }
 }
        public PageRealTimeData()
        {
            InitializeComponent();
            var dynamicGrid = new DynamicGrid
            {
                ItemNum = 2
            }.Init();

            grid.Children.Add(dynamicGrid);
        }
Example #18
0
    /// <summary>
    /// Grid的回收和出现逻辑
    /// </summary>
    protected virtual void OnGridsInOut()
    {
        //计算出开始索引和结束索引
        int offest = Mathf.RoundToInt(CurOffsetValue / InteralFactor);

        //获得最近的一个修正位置
        if (!IsTweening)
        {
            float fixValue = offest * InteralFactor;
            if (fixValue <= 0)
            {
                FixOffsetValue = 0;
            }
            else if (fixValue > TotalOffsetValue)
            {
                FixOffsetValue = TotalOffsetValue;
            }
            else
            {
                FixOffsetValue = fixValue;
            }
        }


        StartIndex = Mathf.Clamp(offest, 0, TotalCount - 1);
        int endIndex = (StartIndex + CentralIndex - 1);

        endIndex = endIndex > TotalCount - 1 ? TotalCount - 1 : endIndex;

        //回收
        foreach (var grid in UsingGridSet)
        {
            if (grid.Index > endIndex || grid.Index < StartIndex - CentralIndex + 1)
            {
                PreRecycleGridStack.Push(grid);
            }
        }

        RecycleGrids();
        //出现
        for (int i = StartIndex - CentralIndex + 1; i <= endIndex; i++)
        {
            DynamicGrid grid = GetGridByIndex(i);

            if (grid == null)
            {
                grid = TableGridAtIndex(i);
            }
            else
            {
                SetGridsAlongAxis((int)Direction, grid, i);
            }
        }
    }
        private void GridLoad()
        {
            DynamicGrid dynamicGrid = new DynamicGrid(2)
            {
                Margin = 5, ColumnSpacing = 5
            };

            dynamicGrid.AddView(PageLeft());
            dynamicGrid.AddView(PageRight());

            GridFrame.Content = dynamicGrid;
        }
 private void DynamicTableGridDelegateEx1(int evt, int index, DynamicGrid grid)
 {
     if (evt == (int)LayoutRule.DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX)
     {
         TestNormalGrid testGrid = grid as TestNormalGrid;
         testGrid.SetContent(index);
     }
     else if (evt == (int)LayoutRule.DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED)
     {
         DynamicTableCurveExample1.TweenToIndex(index);
     }
 }
        private decimal GetTotalDepth()
        {
            decimal sum = 0.0m;

            foreach (Depth d in depths)
            {
                int       tempID = d.DepthID;
                string    stDif  = "D" + tempID;
                TextBlock dif    = (TextBlock)DynamicGrid.FindName(stDif);
                sum += decimal.Parse(dif.Text);
            }
            return(sum);
        }
Example #22
0
 private void InitializeSpecialsGrid()
 {
     if (SelectedPlayer == null || SelectedGameStatistics?.Players == null)
     {
         SpecialsFromSelectedPlayerGrid = null;
         SpecialsToSelectedPlayerGrid   = null;
     }
     else
     {
         InitializeFromSelectedPlayer();
         InitializeToSelectedPlayer();
     }
 }
 public DynamicGridPage()
 {
     InitializeComponent();
     grid = new DynamicGrid()
     {
         BackgroundColor   = Color.Maroon,
         HorizontalOptions = LayoutOptions.FillAndExpand,
         VerticalOptions   = LayoutOptions.FillAndExpand
     };
     dynamicButtonsView.AddChildren(grid);
     dynamicButtonsView.HorizontalButtonClickedEvent += HorizontalButtonClicked;
     dynamicButtonsView.VerticalButtonClickedEvent   += VerticalButtonClicked;
 }
        private decimal GetSum()
        {
            decimal sum = 0.0m;

            foreach (Depth d in depths)
            {
                int           tempIDd = d.DepthID;
                string        stPaidd = "P" + tempIDd;
                DecimalUpDown paidd   = (DecimalUpDown)DynamicGrid.FindName(stPaidd);
                sum += paidd.Value ?? 0.0m;
            }
            return(sum);
        }
        private void CreateComment()
        {
            string        comment  = "";
            List <string> comments = new List <string>();

            foreach (Depth d in depths)
            {
                int tempID = d.DepthID;

                string stDif   = "D" + tempID;
                string stPaid  = "P" + tempID;
                string stCheck = "C" + tempID;

                DecimalUpDown paid  = (DecimalUpDown)DynamicGrid.FindName(stPaid);
                TextBlock     dif   = (TextBlock)DynamicGrid.FindName(stDif);
                CheckBox      check = (CheckBox)DynamicGrid.FindName(stCheck);

                if (paid.Value != 0.0m)
                {
                    comments.Add(", " + d.DepthDate.ToString("dd/MM/yyyy") + " ");
                }
            }
            if (comments.Count > 1)
            {
                comment += "Πληρωμή βάρδιας για τις ημερομηνίες : ";
            }
            else if (comments.Count == 1)
            {
                comment += "Πληρωμή βάρδιας για την ημερομηνία : ";
            }
            foreach (string s in comments)
            {
                comment += s;
            }

            decimal sum = GetSum();

            if (sum != TotalPaid)
            {
                decimal difRes = TotalPaid - sum;
                if (difRes > 0)
                {
                    comment += $"-Πρόσθετο αποθεματικό : {difRes}. ";
                }
            }



            comentbox.Text = comment;
        }
Example #26
0
    /*public bool ShouldCatchRaycast
     * {
     *  get { return _shouldCatchRaycast; }
     *  set
     *  {
     *      if(_shouldCatchRaycast != value)
     *      {
     *          _shouldCatchRaycast = value;
     *          //SetCellsShouldCatchRaycast();
     *      }
     *  }
     * }*/

    // Start is called before the first frame update
    void Start()
    {
        grid = FindObjectOfType <DynamicGrid>();
        if (Layout != null)
        {
            if (transform.childCount == 0)
            {
                GenerateCells();
            }
            else
            {
                FindExistingCells();
            }
        }
    }
Example #27
0
 void Start()
 {
     uigrid = this.GetComponent<UIGrid>();
     if(uigrid == null){
         Debug.LogError("UIGrid must in parent");
     }
     dynamicGrid = this.GetComponent<DynamicGrid>();
     if(uigrid == null){
         Debug.LogError("DynamicGrid must in parent");
     }
     centerOnChild = this.GetComponent<UICenterOnChild>();
     if(centerOnChild == null){
         Debug.LogError("UICenterOnChild must in parent");
     }
     centerOnChild.recalculateCenterCellOnUpdate = true;
 }
Example #28
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        DynamicGrid grid = (DynamicGrid)target;

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Generate Grid"))
        {
            grid.InitMatrix();
        }
        if (GUILayout.Button("Clear Grid"))
        {
            grid.ClearGrid();
        }
        EditorGUILayout.EndHorizontal();
    }
    /// <summary>
    /// 从本地加载一个Grid
    /// </summary>
    /// <returns></returns>
    protected virtual DynamicGrid LoadGridFormPool()
    {
        if (Grid == null)
        {
            Debug.LogError("Error:TableView m_Grid is null");
            return(null);
        }

        DynamicGrid grid = DequeueCell();

        if (grid != null)
        {
            return(grid);
        }


        GameObject obj = Instantiate(Grid.gameObject);

        grid = obj.GetComponent <DynamicGrid>();
        grid.transform.SetParent(ScrRect.content, false);

        //内嵌套点击事件
        if (IsGridTouchEventEnable)
        {
            DynamicGridClickHelper trigger = grid.GetComponent <DynamicGridClickHelper>();
            if (trigger == null)
            {
                trigger = grid.gameObject.AddComponent <DynamicGridClickHelper>();
            }

            trigger.SetupClickEnable(true, delegate(PointerEventData eventData)
            {
                OnTableGridTouched(grid, eventData);
            });
        }
        else
        {
            DynamicGridClickHelper trigger = grid.GetComponent <DynamicGridClickHelper>();
            if (trigger != null)
            {
                trigger.SetupClickEnable(false);
            }
        }


        return(grid);
    }
Example #30
0
        private ScrollView GetTable()
        {
            ScrollView scrollView = new ScrollView()
            {
                Padding = 0, Margin = 0
            };
            StackLayout tablestack = new StackLayout()
            {
                Padding = 0, Margin = 0, Spacing = -2
            };

            foreach (var item in _wordList)
            {
                DynamicGrid dynamicGrid = new DynamicGrid(Xamarin.CustomViews.Enums.DynamicGridEnum.Custom, 20, 34, 40, 6)
                {
                    Padding = 0, Margin = 0, RowSpacing = 0, ColumnSpacing = 0
                };
                dynamicGrid.AddView(new Label()
                {
                    VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold, TextColor = TextExtensions.GetTextColor(item.Type), Text = item.Type.ToString(), Margin = 0
                });
                dynamicGrid.AddView(new Label()
                {
                    VerticalOptions = LayoutOptions.Center, Text = item.Key, TextColor = UserSettings.TextColor, Margin = new Thickness(5, 0, 0, 0)
                });
                dynamicGrid.AddView(new Label()
                {
                    HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, TextColor = UserSettings.TextColor, Text = item.Description, Margin = 0
                });

                dynamicGrid.AddView(new CircleImage()
                {
                    Source = "delete.png", GestureRecognizers = { new TapGestureRecognizer()
                                                                  {
                                                                      Command = new Command(DeleteButtonPressed), CommandParameter = item
                                                                  } }
                });
                tablestack.Children.Add(dynamicGrid);
                tablestack.Children.Add(new Line(LineEnum.Horizontal, UserSettings.MainColor)
                {
                    Margin = 0
                });
            }
            scrollView.Content = tablestack;
            return(scrollView);
        }
    /// <summary>
    /// 回收节点
    /// </summary>
    /// <param name="grid"></param>
    private void RecycleTableGrid(DynamicGrid grid)
    {
        if (grid == null)
        {
            return;
        }

        OnTableGridRecycle(grid);
        grid.Index = -1;

        if (grid.gameObject.activeSelf)
        {
            grid.gameObject.SetActive(false);
        }

        GridPoolStack.Push(grid);
    }
Example #32
0
 void Awake()
 {
     dynamicGrid = GetComponent<DynamicGrid>();
 }
Example #33
0
 void Start()
 {
     if (viewCamera == null) {
         Debug.LogError ("no viewCamera");
     }
     dynamicGrid = this.transform.parent.GetComponent<DynamicGrid> ();
     if (dynamicGrid == null) {
         Debug.LogError ("DynamicCell must has parent DynamicGrid");
     }
     this.renderRange = dynamicGrid.renderRange;
     selectableGrid = transform.parent.GetComponent<SelectableGrid> ();
 }