public ElementRow AddElementRow(
                string Ref,
                string Description,
                System.Decimal LastMonth,
                System.Decimal ParentElementId,
                string Commentary,
                System.Decimal ThisMonth,
                System.Decimal NextMonth,
                int SLADetailId,
                string LevelDescription,
                System.Decimal GThreshold,
                System.Decimal AThreshold,
                System.Decimal RThreshold,
                bool RTLastMonth,
                bool RTThisMonth,
                System.Decimal Target,
                int Level)
            {
                ElementRow rowElementRow = ((ElementRow)(this.NewRow()));

                rowElementRow.ItemArray = new object[] {
                    null,
                    Ref,
                    Description,
                    LastMonth,
                    ParentElementId,
                    Commentary,
                    ThisMonth,
                    NextMonth,
                    SLADetailId,
                    LevelDescription,
                    GThreshold,
                    AThreshold,
                    RThreshold,
                    RTLastMonth,
                    RTThisMonth,
                    Target,
                    Level
                };
                this.Rows.Add(rowElementRow);
                return(rowElementRow);
            }
示例#2
0
        private static List <ElementRow> PerformLayout(double[] grid, List <ElementWrapper> elements)
        {
            var gridLength = grid.Length;
            var layout     = new List <ElementRow>();

            foreach (var element in elements)
            {
                if (element.Column < 0)
                {
                    element.Column = 0;
                }
                else if (element.Column >= gridLength)
                {
                    element.Column = gridLength - 1;
                }

                if (element.ColumnSpan < 1)
                {
                    element.ColumnSpan = 1;
                }
                else if (element.ColumnSpan > gridLength)
                {
                    element.ColumnSpan = gridLength;
                }

                if (element.Row == null)
                {
                    layout.Add(new ElementRow(null, element));
                }
                else
                {
                    var rowName = element.Row;
                    var added   = false;
                    for (var i = 0; i < layout.Count; i++)
                    {
                        var row = layout[i];
                        if (row.RowName != rowName)
                        {
                            continue;
                        }

                        if (row.Sealed)
                        {
                            // Bad scenario - too many elements in one row.
                            // Search for next row with the same name.
                            // If none exists, insert a new one in the cluster.
                            var found = false;
                            int j;
                            for (j = i + 1; j < layout.Count; j++)
                            {
                                var nextRow = layout[j];
                                if (nextRow.RowName != rowName)
                                {
                                    break;
                                }

                                if (nextRow.Sealed)
                                {
                                    continue;
                                }

                                row   = nextRow;
                                found = true;
                                break;
                            }

                            if (!found)
                            {
                                row = new ElementRow(rowName);
                                layout.Insert(j, row);
                            }
                        }

                        row.Elements.Add(element);
                        row.ColumnSpan += element.ColumnSpan;
                        if (row.ColumnSpan >= gridLength)
                        {
                            row.Sealed = true;
                        }

                        added = true;
                        break;
                    }

                    if (!added)
                    {
                        var row = new ElementRow(rowName, element);
                        layout.Add(row);
                        if (row.ColumnSpan >= gridLength)
                        {
                            row.Sealed = true;
                        }
                    }
                }
            }

            foreach (var row in layout)
            {
                if (row.RowName == null)
                {
                    var element = row.Elements[0];
                    if (element.Column >= gridLength)
                    {
                        element.Column = gridLength - 1;
                    }

                    row.Elements[0].ColumnSpan = gridLength - element.Column;
                }
                else
                {
                    row.Elements.Sort((a, b) => a.Column.CompareTo(b.Column));
                    var rowElements = row.Elements;
                    var count       = 0;
                    var gaps        = new int[rowElements.Count];
                    for (var i = 0; i < rowElements.Count; i++)
                    {
                        var element = rowElements[i];
                        if (element.Column > count)
                        {
                            gaps[i] = element.Column - count;
                            count   = element.Column;
                        }

                        if (count > element.Column)
                        {
                            element.Column = count;
                        }

                        count += element.ColumnSpan;
                    }

                    if (count > gridLength)
                    {
                        // Overflow - close gaps starting from right.
                        var delta = count - gridLength;
                        for (var i = gaps.Length - 1; i >= 0; i--)
                        {
                            if (delta == 0)
                            {
                                break;
                            }

                            var gap = gaps[i];
                            if (gap == 0)
                            {
                                continue;
                            }

                            var subtraction = Math.Min(delta, gap);
                            for (var j = i; j < gaps.Length; j++)
                            {
                                rowElements[j].Column -= subtraction;
                            }

                            delta -= subtraction;
                        }
                    }
                }
            }

            return(layout);
        }
示例#3
0
 public void SetElement(int id, Element element, float[] attackMultipliers)
 {
     _elementTable[id] = new ElementRow(element, (float[])attackMultipliers.Clone());
 }
 public ElementRowChangeEvent(ElementRow row, DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
 public void RemoveElementRow(ElementRow row)
 {
     this.Rows.Remove(row);
 }
 public void AddElementRow(ElementRow row)
 {
     this.Rows.Add(row);
 }
示例#7
0
 public ElementRowChangeEvent(ElementRow row, global::System.Data.DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
示例#8
0
 void Start()
 {
     _animator = GetComponent <Animator>();
     _row      = GetComponentInChildren <ElementRow>();
     _crafter  = GetComponentInChildren <Crafter>();
 }