Esempio n. 1
0
 public UnitVector(string Name, int Order)
 {
     this.Name          = Name;
     this.Order         = Order;
     this.IsRowOrColumn = RowColumn.Column;
     Init();
 }
Esempio n. 2
0
        private IEnumerable <OpenXmlAttribute> EnumCellProxyAttributes(uint row, uint col, CellProxy cellProxy)
        {
            OpenXmlAttribute iteratorVariable0 = new OpenXmlAttribute {
                LocalName = "r",
                Value     = RowColumn.ToAddress(row, col)
            };

            yield return(iteratorVariable0);

            if (cellProxy.DataType.HasValue)
            {
                OpenXmlAttribute iteratorVariable1 = new OpenXmlAttribute {
                    LocalName = "t",
                    Value     = this.STCellType(cellProxy.DataType.Value)
                };
                yield return(iteratorVariable1);
            }
            if (cellProxy.StyleIndex.HasValue)
            {
                OpenXmlAttribute iteratorVariable2 = new OpenXmlAttribute {
                    LocalName = "s",
                    Value     = cellProxy.StyleIndex.Value.ToString()
                };
                yield return(iteratorVariable2);
            }
        }
Esempio n. 3
0
        private void CreateColumnCopies(uint colFromIdx, int numOfColumns, Func <CellProxy, CellProxy> fnCreate)
        {
            Action <uint, uint> action = delegate(uint rowIdx, uint colIdx) {
                RowColumn column = new RowColumn {
                    Row    = rowIdx,
                    Column = colIdx
                };
                if (column.Column == colFromIdx)
                {
                    foreach (int num in Enumerable.Range(((int)colFromIdx) + 1, numOfColumns))
                    {
                        RowColumn column2 = new RowColumn {
                            Row    = column.Row,
                            Column = (uint)num
                        };
                        CellProxy cell = this.GetCell(column.Row, column.Column);
                        if (cell != null)
                        {
                            CellProxy c = fnCreate(cell);
                            if (c != null)
                            {
                                this.AddCellToCache(c, column2.Row, column2.Column);
                            }
                        }
                    }
                }
            };

            this.LoopCells(action);
        }
Esempio n. 4
0
 public UnitVector(int value)
 {
     this.Name          = "e";
     this.Order         = 1;
     this.IsRowOrColumn = RowColumn.Column;
     this.Add(value);
 }
Esempio n. 5
0
 public UnitVector(string Name, int Order, RowColumn rc)
 {
     this.Name          = Name;
     this.Order         = Order;
     this.IsRowOrColumn = rc;
     Init();
 }
        private void CreateColumnCopies(uint colFromIdx, int numOfColumns, Func <CellProxy, CellProxy> fnCreate)
        {
            Action <uint, uint> actionCopyColumn = (rowIdx, colIdx) =>
            {
                RowColumn rcOld = new RowColumn()
                {
                    Row = rowIdx, Column = colIdx
                };
                if (rcOld.Column == colFromIdx)
                {
                    foreach (var newColIdx in Enumerable.Range((int)colFromIdx + 1, numOfColumns))
                    {
                        RowColumn rcNew = new RowColumn()
                        {
                            Row = rcOld.Row, Column = (uint)newColIdx
                        };
                        CellProxy cOld = GetCell(rcOld.Row, rcOld.Column);
                        if (cOld != null)
                        {
                            CellProxy cNew = fnCreate(cOld);
                            if (cNew != null)
                            {
                                AddCellToCache(cNew, rcNew.Row, rcNew.Column);
                            }
                        }
                    }
                }
            };

            LoopCells(actionCopyColumn);
        }
Esempio n. 7
0
        // Calculates Gamma values
        private static void calculatePolyPi(double[] dj, double[,] prov, double[,] prov1, double[,] prov2, double[,] prov3, double[] v, int i)
        {
            double[] Gammaj   = new double[dj.Length];
            double[] dGammaj  = new double[dj.Length];
            double[] d2Gammaj = new double[dj.Length];
            double[] d3Gammaj = new double[dj.Length];

            for (int c = 0; c < dj.Length; c++)
            {
                Gammaj[c]   = Math.Exp(dj[c]);
                dGammaj[c]  = Gammaj[c] * v[c];
                d2Gammaj[c] = Gammaj[c] * Math.Pow(v[c], 2);
                d3Gammaj[c] = Gammaj[c] * Math.Pow(v[c], 3);
            }

            double Sg   = RowColumn.Sum(Gammaj);
            double Sdg  = RowColumn.Sum(dGammaj);
            double Sd2g = RowColumn.Sum(d2Gammaj);
            double Sd3g = RowColumn.Sum(d3Gammaj);

            for (int index = 0; index < Gammaj.Length; index++)
            {
                prov[i, index] = Gammaj[index] / Sg;

                prov1[i, index] = dGammaj[index] / Sg - Gammaj[index] * Sdg / Math.Pow(Sg, 2);

                prov2[i, index] = d2Gammaj[index] / Sg - 2 * dGammaj[index] * Sdg / Math.Pow(Sg, 2) - Gammaj[index] *
                                  Sd2g / Math.Pow(Sg, 2) + 2 * Gammaj[index] * Math.Pow(Sdg, 2) / Math.Pow(Sg, 3);

                prov3[i, index] = d3Gammaj[index] / Sg - (Gammaj[index] * Sd3g + 3 * dGammaj[index] * Sd2g + 3 * d2Gammaj[index] * Sdg) / Math.Pow(Sg, 2) +
                                  (6 * Gammaj[index] * Sdg * Sd2g + 6 * dGammaj[index] * Math.Pow(Sdg, 2)) / Math.Pow(Sg, 3) - 6 * Gammaj[index] * Math.Pow(Sdg, 3) / Math.Pow(Sg, 4);
            }
        }
        public void Hash()
        {
            var rowColumn1 = new RowColumn(10, 20);
            var rowColumn2 = new RowColumn(40, 10);

            var dictionary = new Dictionary <RowColumn, int>();

            dictionary.Add(rowColumn1, dictionary.Count);

            try
            {
                dictionary.Add(rowColumn2, dictionary.Count);
            }
            catch
            {
                Assert.True(false, $"{typeof(RowColumn)} must not throw exception.");
            }

            try
            {
                dictionary.Add(rowColumn2, dictionary.Count);
                Assert.True(false, $"{typeof(RowColumn)} must throw exception because key is duplicate.");
            }
            catch (ArgumentException)
            {
            }
        }
 public ExcelCell this[string address]
 {
     get
     {
         RowColumn column = ExcelAddress.ToRowColumn(address);
         return(this[column.Row, column.Column]);
     }
 }
Esempio n. 10
0
 public OleDbCell this[string address]
 {
     get
     {
         RowColumn rc = ExcelAddress.ToRowColumn(address);
         return(this[rc.Row, rc.Column]);
     }
 }
        public static RowColumn CacheIndexToRowCol(ulong cacheIdx)
        {
            RowColumn rc = new RowColumn();

            // Note: 0-indexed --> 1-indexed
            rc.Row    = (uint)(cacheIdx / (ulong)ExcelConstraints.MaxColumns) + 1;
            rc.Column = (uint)(cacheIdx % (ulong)ExcelConstraints.MaxColumns) + 1;
            return(rc);
        }
Esempio n. 12
0
 public Model(string Name, CompassDirection Direction, string Icon, RowColumn RowColumn) : base(Name)
 {
     this.Direction     = Direction;
     this.Icon          = string.Concat(@"pack://application:,,,/Imagin.Controls.Common;component/Images/", Icon, ".png");
     this.Row           = RowColumn.Row.ToInt32();
     this.Column        = RowColumn.Column.ToInt32();
     this.DefaultRow    = RowColumn.Row.ToInt32();
     this.DefaultColumn = RowColumn.Column.ToInt32();
 }
Esempio n. 13
0
 /// <summary>
 /// Generates a new row in every column
 /// </summary>
 private void CreateNewRow()
 {
     RowColumn.AddRow();
     foreach (KeyValuePair <string, Column> c in SpreadSheet)
     {
         c.Value.AddRow();
     }
     RowCount++;
 }
        public void NotEqual()
        {
            var rowColumn1 = new RowColumn(10, 20);
            var rowColumn2 = new RowColumn(40, 10);

            Assert.NotEqual(rowColumn1, rowColumn2);
            Assert.True(rowColumn1 != rowColumn2);
            Assert.True(!rowColumn1.Equals(rowColumn2));
            Assert.False(rowColumn1 == rowColumn2);
        }
Esempio n. 15
0
        private bool ValidateColumn(Value value, RowColumn column)
        {
            foreach (var row in rowColumnManager.rowColumns)
            {
                if (GetMatValue(testMat, row, column) == value)
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 16
0
        public static void GetExcelRowColumn(int i, out RowColumn sRowColumn)
        {
            sRowColumn = new RowColumn();
            //料號
            sRowColumn.PartNoRow    = 52;
            sRowColumn.PartNoColumn = 10;
            //品名
            sRowColumn.PartDescRow    = 51;
            sRowColumn.PartDescColumn = 10;
            //設計
            sRowColumn.DesignedRow    = 52;
            sRowColumn.DesignedColumn = 5;
            //審核
            sRowColumn.ReviewedRow    = 52;
            sRowColumn.ReviewedColumn = 6;
            //批准
            sRowColumn.ApprovedRow    = 52;
            sRowColumn.ApprovedColumn = 7;


            int currentNo = (i % 40);
            int RowNo     = 7;

            RowNo = RowNo + currentNo;

            sRowColumn.ToolNumberRow    = RowNo;
            sRowColumn.ToolNumberColumn = 1;

            sRowColumn.ERPNumberRow    = RowNo;
            sRowColumn.ERPNumberColumn = 2;

            sRowColumn.CutterQtyRow    = RowNo;
            sRowColumn.CutterQtyColumn = 3;

            sRowColumn.CutterLifeRow    = RowNo;
            sRowColumn.CutterLifeColumn = 4;

            sRowColumn.FluteQtyRow    = RowNo;
            sRowColumn.FluteQtyColumn = 5;

            sRowColumn.TitleRow    = RowNo;
            sRowColumn.TitleColumn = 6;

            sRowColumn.SpecificationRow    = RowNo;
            sRowColumn.SpecificationColumn = 8;

            sRowColumn.NoteRow    = RowNo;
            sRowColumn.NoteColumn = 10;

            sRowColumn.HolderRow    = RowNo;
            sRowColumn.HolderColumn = 12;
        }
        protected override void LayoutChildren(IGUIContext ctx, RectangleF bounds)
        {
            base.LayoutChildren(ctx, bounds);

            float totalHeight = Editor.RowManager.Height + Editor.Padding.Height;

            if (totalHeight != lastTotalHeight)
            {
                lastTotalHeight = totalHeight;
                RowColumn.Update();
                //Editor.Update ();
            }
        }
Esempio n. 18
0
        public Area GetRowColumnArea(RowColumn rowColumn)
        {
            switch (((int)rowColumn / 3) + 1)
            {
            case 1: return(Area.One);

            case 2: return(Area.Two);

            case 3: return(Area.Three);

            default: return(Area.Zero);
            }
        }
Esempio n. 19
0
 /// <summary>
 /// Instantiates new instance
 /// </summary>
 /// <param name="start">Start of the selection</param>
 /// <param name="end">End of the selection</param>
 public Selection(RowColumn start, RowColumn end)
 {
     if (start.Row > end.Row || (start.Row == end.Row && start.Column > end.Column))
     {
         Start = end;
         End   = start;
     }
     else
     {
         Start = start;
         End   = end;
     }
 }
Esempio n. 20
0
        /// <summary>
        /// タイムライン生成
        /// </summary>
        private int AddTimeline(string name, string status, bool append)
        {
            if (timelineChildren.Count > MAX_TIMELINE)
            {
                var count = timelineChildren.Count - MAX_TIMELINE;
                foreach (var item in timelineChildren.GetRange(MAX_TIMELINE, count))
                {
                    item.Destroy();
                }
                timelineChildren.RemoveRange(MAX_TIMELINE, count);
            }

            var rc = new RowColumn();

            if (!append)
            {
                rc.RowColumnConstraint.PositionIndex = 0;
            }
            var label = new Text();

            label.Editable        = false;
            label.EditMode        = EditMode.Multi;
            label.Rows            = 2;
            label.BorderWidth     = 0;
            label.ShadowThickness = 0;
            label.WordWrap        = true;
            label.ResizeHeight    = true;
            label.LeftAttachment  = AttachmentType.Form;
            label.RightAttachment = AttachmentType.Form;
            label.Value           = $"[{name}]\n{status}";

            rc.Children.Add(label);
            rc.Children.Add(new SeparatorGadget());

            this.timelineView.Children.Add(rc);

            if (append)
            {
                timelineChildren.Add(rc);
            }
            else
            {
                timelineChildren.Insert(0, rc);
            }
            return(0);
        }
Esempio n. 21
0
        public void UpdateDesignBlock(RowColumn curRC)
        {
            if (_currentBlock == null)
            {
                _currentBlock = new GridBlockModel(false);
                //fe.Children.Add(_currentBlock);
                AddCustomBlock(_currentBlock);
                OnCustomBlockAdded(new BlockCreateEventArgs(_currentBlock));
            }

            int rSpan = Math.Abs(curRC.Row - _starRC.Row) + 1;
            int cSpan = Math.Abs(curRC.Column - _starRC.Column) + 1;

            _currentBlock.Row        = Math.Min(curRC.Row, _starRC.Row);
            _currentBlock.Column     = Math.Min(curRC.Column, _starRC.Column);
            _currentBlock.RowSpan    = rSpan;
            _currentBlock.ColumnSpan = cSpan;
        }
Esempio n. 22
0
        private bool ValidateArea(Value value, RowColumn row, RowColumn column)
        {
            var rowArea    = areaManager.GetRowColumnArea(row);
            var columnArea = areaManager.GetRowColumnArea(column);

            foreach (var indexRow in rowColumnManager.rowColumns)
            {
                foreach (var indexColumn in rowColumnManager.rowColumns)
                {
                    if (areaManager.GetRowColumnArea(indexRow) == rowArea &&
                        areaManager.GetRowColumnArea(indexColumn) == columnArea &&
                        GetMatValue(testMat, indexRow, indexColumn) == value)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Esempio n. 23
0
 /// <summary>
 /// Checks whether or not row and column is within the selection
 /// </summary>
 /// <param name="rowColumn">The row and column</param>
 /// <returns>True if inside the selection</returns>
 public bool Inside(RowColumn rowColumn)
 {
     if (rowColumn.Row == Start.Row && rowColumn.Row == End.Row)                     // same row
     {
         return(rowColumn.Column >= Start.Column && rowColumn.Column <= End.Column); // between columns
     }
     if (rowColumn.Row > Start.Row && rowColumn.Row < End.Row)                       // between rows
     {
         return(true);
     }
     if (rowColumn.Row == Start.Row)               // start row
     {
         return(rowColumn.Column <= Start.Column); // before column
     }
     if (rowColumn.Row == End.Row)                 // end row
     {
         return(rowColumn.Column >= End.Column);   // after column
     }
     return(false);
 }
Esempio n. 24
0
        void ShiftPositions(Model Model)
        {
            if (Model.Direction == CompassDirection.Origin)
            {
                this.Direction = CompassDirection.Origin;
            }

            ShiftType Shift = this.Shifts[(int)Model.Direction];

            if (Shift == ShiftType.None)
            {
                return;
            }

            foreach (Model d in this.Items)
            {
                if (Shift.HasFlag(ShiftType.Up))
                {
                    d.Row--;
                }
                if (Shift.HasFlag(ShiftType.Down))
                {
                    d.Row++;
                }
                if (Shift.HasFlag(ShiftType.Left))
                {
                    d.Column--;
                }
                if (Shift.HasFlag(ShiftType.Right))
                {
                    d.Column++;
                }
            }

            var Origin    = this.Items.Where(x => x.Direction == CompassDirection.Origin).First();
            var RowColumn = new RowColumn(Origin.Row, Origin.Column);

            this.Direction = (CompassDirection)this.Directions[(--RowColumn.Row).ToInt32(), (--RowColumn.Column).ToInt32()];
        }
        private IEnumerable <OpenXmlAttribute> EnumCellProxyAttributes(uint row, uint col, CellProxy cellProxy)
        {
            yield return(new OpenXmlAttribute()
            {
                LocalName = "r", Value = RowColumn.ToAddress(row, col)
            });

            if (cellProxy.DataType != null)
            {
                yield return(new OpenXmlAttribute()
                {
                    LocalName = "t", Value = STCellType((CellValues)cellProxy.DataType)
                });
            }
            if (cellProxy.StyleIndex != null)
            {
                yield return(new OpenXmlAttribute()
                {
                    LocalName = "s", Value = cellProxy.StyleIndex.Value.ToString()
                });
            }
        }
Esempio n. 26
0
        /*TODO: remove this GPG
         * public static UnitVector operator*(ElementaryMatrix em, UnitVector uv)
         * {
         *  UnitVector uvOut = null;
         *  //using following realtionships
         *  //Eij * er = ei * e'j * er
         *  // = &jr * ei where & is the Kronecker Delta
         *  UnitVectorSpace uvp = new UnitVectorSpace(uv.Order);
         *  UnitVector ei = uvp["e" + em.Major.ToString()];
         *  UnitVector ej = uvp["e" + em.Minor.ToString()];
         *  RowColumn rc = ej.IsRowOrColumn;
         *  ej.IsRowOrColumn = RowColumn.Row;
         *
         *  uvOut = ei * ej * uv;
         *  ej.IsRowOrColumn = rc; //Set it back to what it was
         *  return uvOut;
         * }
         */

        public static ElementaryMatrix operator*(UnitVector e1, UnitVector e2)
        {
            ElementaryMatrix em = null;
            RowColumn        rc = e2.IsRowOrColumn;


            if (e1.IsRowOrColumn == RowColumn.Row) //Dot product
            {
                return((ElementaryMatrix)DotProduct(e1, e2));
            }


            e2.IsRowOrColumn = RowColumn.Row; //transpose

            string emName = "E" + e1.Name[1].ToString() + e2.Name[1].ToString();

            em         = new ElementaryMatrix(e1.Order, e2.Order, emName);
            em.FullRep = em.LatexName + " = " + e1.ToLatex() + e2.ToLatex() + " = " + em.ToLatex();

            e2.IsRowOrColumn = rc; //set back to what it was
            return(em);
        }
Esempio n. 27
0
        public static void GetExcelRowColumn(int i, out RowColumn sRowColumn)
        {
            sRowColumn = new RowColumn();

            sRowColumn.FixInsNoRow      = 32;
            sRowColumn.FixInsNoColumn   = 1;
            sRowColumn.ERPRow           = 31;
            sRowColumn.ERPColumn        = 21;
            sRowColumn.FixInsDescRow    = 34;
            sRowColumn.FixInsDescColumn = 1;

            int currentNo = (i % 15);
            int RowNo     = 16;

            RowNo = RowNo + currentNo;

            sRowColumn.BallonRow    = RowNo;
            sRowColumn.BallonColumn = 1;

            sRowColumn.FixInsDimensionRow    = RowNo;
            sRowColumn.FixInsDimensionColumn = 2;
        }
        private void CreateRowCopies(uint rowFromIdx, int numOfRows, Func <CellProxy, CellProxy> fnCreate)
        {
            SortedList <uint, CellProxy> rowCache;

            if (_cachedCells.TryGetValue(rowFromIdx, out rowCache))
            {
                Row cachedRow;
                _cachedRows.TryGetValue(rowFromIdx, out cachedRow);

                foreach (var newRowIdx in Enumerable.Range((int)rowFromIdx + 1, numOfRows))
                {
                    if (cachedRow != null)
                    {
                        Row cachedRowCopy = (Row)cachedRow.CloneNode(false);
                        cachedRowCopy.RowIndex = (uint)newRowIdx;
                        _cachedRows.Add(cachedRowCopy.RowIndex, cachedRowCopy);
                    }

                    foreach (var colIdx in rowCache.Keys)
                    {
                        RowColumn rcOld = new RowColumn()
                        {
                            Row = rowFromIdx, Column = colIdx
                        };
                        RowColumn rcNew = new RowColumn()
                        {
                            Row = (uint)newRowIdx, Column = colIdx
                        };
                        CellProxy cOld = GetCell(rcOld.Row, rcOld.Column);
                        CellProxy cNew = fnCreate(cOld);
                        if (cNew != null)
                        {
                            AddCellToCache(cNew, rcNew.Row, rcNew.Column);
                        }
                    }
                }
            }
        }
Esempio n. 29
0
        private void CreateRowCopies(uint rowFromIdx, int numOfRows, Func <CellProxy, CellProxy> fnCreate)
        {
            SortedList <uint, CellProxy> list;

            if (this._cachedCells.TryGetValue(rowFromIdx, out list))
            {
                Row row;
                this._cachedRows.TryGetValue(rowFromIdx, out row);
                foreach (int num in Enumerable.Range(((int)rowFromIdx) + 1, numOfRows))
                {
                    if (row != null)
                    {
                        Row row2 = (Row)row.CloneNode(false);
                        row2.RowIndex = (UInt32Value)(uint)num;
                        this._cachedRows.Add((uint)row2.RowIndex, row2);
                    }
                    foreach (uint num2 in list.Keys)
                    {
                        RowColumn column = new RowColumn {
                            Row    = rowFromIdx,
                            Column = num2
                        };
                        RowColumn column2 = new RowColumn {
                            Row    = (uint)num,
                            Column = num2
                        };
                        CellProxy cell = this.GetCell(column.Row, column.Column);
                        CellProxy c    = fnCreate(cell);
                        if (c != null)
                        {
                            this.AddCellToCache(c, column2.Row, column2.Column);
                        }
                    }
                }
            }
        }
Esempio n. 30
0
        static int GetMax(RowColumn rowColumn, ExcelVersion version)
        {
            switch (rowColumn)
            {
            case RowColumn.Row:
                switch (version)
                {
                case ExcelVersion.Xls: return(RowMaxXls);

                case ExcelVersion.Xlsx: return(RowMaxXlsx);
                }
                break;

            case RowColumn.Column:
                switch (version)
                {
                case ExcelVersion.Xls: return(ColumnMaxXls);

                case ExcelVersion.Xlsx: return(ColumnMaxXlsx);
                }
                break;
            }
            throw new InvalidEnumArgumentException("version", (int)version, version.GetType());
        }