Exemple #1
0
        public TimeSpan Duration()
        {
            TitleTime tt = new TitleTime();
            TimeSpan duration = TimeSpan.Zero;
            List<SimpleCell> SortedCells = new List<SimpleCell>();

            int pgc_num = ifoGetNumPGCI(Handle);
            for (int i = 0; i < pgc_num; i++)
            {
                int num_cells = ifoGetPGCIInfo(Handle, i, ref tt);
                IntPtr ptr_cells = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(t_vs_vobcellid)) * num_cells);
                if (ptr_cells != IntPtr.Zero)
                {
                    try
                    {
                        if (ifoGetPGCICells(Handle, i, ptr_cells))
                        {
                            IntPtr ptr_cell = ptr_cells;
                            for (int k = 0; k < num_cells; k++)
                            {
                                t_vs_vobcellid cell = (t_vs_vobcellid)Marshal.PtrToStructure(ptr_cell, typeof(t_vs_vobcellid));
                                ptr_cell = new IntPtr(ptr_cell.ToInt64() + Marshal.SizeOf(typeof(t_vs_vobcellid))); //ptr += offset

                                //Сохраняем инфу от cell, если у нас такой еще нет (берутся только start\end_lba и time)
                                SimpleCell obj = new SimpleCell() { start = cell.start_lba, end = cell.end_lba, time = cell.time };
                                if (!SortedCells.Contains(obj))
                                    SortedCells.Add(obj);
                            }
                        }
                    }
                    finally
                    {
                        Marshal.FreeHGlobal(ptr_cells);
                    }
                }
            }

            foreach (SimpleCell cell in SortedCells)
            {
                #region frames bits
                /*
                1 0 0 1 0 0 1 0  (73)
                1 0 0 1 0 0 0 0  (9, & 0x3f) 25fps
                0 0 0 0 0 0 1 0  (64, & ~0x3f) 25fps

                0 1 0 1 0 0 0 0  (10, & 0x3f) 29fps
                0 0 0 0 0 0 1 1  (192, & ~0x3f) 29fps
                */
                #endregion

                duration += TimeSpan.FromHours(cell.time.hours) +
                    TimeSpan.FromMinutes(cell.time.minutes) +
                    TimeSpan.FromSeconds(cell.time.seconds) +
                    TimeSpan.FromMilliseconds((cell.time.frames & 0x3f) * //Перевод кадров в ms
                    (((cell.time.frames & (1 << 7)) != 0) ? 1000.0 / (30000.0 / 1001.0) : 40.0));
            }

            return duration;
        }
Exemple #2
0
        /**
         * Returns a Cell based on the styleattributes.
         *
         * @param attributes
         * @param styleattributes
         * @return an iText Cell
         */
        private IElement RetrieveTableCell(Properties attributes,
                                           Properties styleattributes)
        {
            SimpleCell cell = (SimpleCell)RetrieveTableRow(attributes,
                                                           styleattributes);

            cell.Cellgroup = false;
            return(cell);
        }
Exemple #3
0
        public void AddCell(string container, SimpleCell cell)
        {
            _cells.TryGetValue(container, out CellContainer cellContainer);
            if (cellContainer == null)
            {
                _cells.Add(container, cellContainer = new CellContainer());
            }

            cellContainer.Add(cell);
        }
        public void SimpleTest()
        {
            var cell1 = new SimpleCell("1");
            var cell2 = new SimpleCell("2");
            var cell3 = new FormulaCell("={0}+{1}", cell1, cell2);

            var spreadsheet = new TSVSpreadsheet();
            spreadsheet.AddCell(cell1, 0, 0);
            spreadsheet.AddCell(cell2, 1, 0);
            spreadsheet.AddCell(cell3, 1, 1);

            Assert.AreEqual("1\t2\t\n\t=A1+B1\t\n", spreadsheet.Export());
        }
 private void SetCellCostInternal(SimpleCell cell)
 {
     if (cell.IsOccupied)
     {
         cell.Cost = cell.Occupied == _playerID ? _playerCost : _occupiedCost;
     }
     else if (cell.IsPathClaimed)
     {
         cell.Cost = _claimedCost;
     }
     else
     {
         cell.Cost = cell.IsEdge? _edgeCost : _defaultCost;
     }
 }
Exemple #6
0
 public void Add(SimpleCell cell)
 {
     _cells.AddLast(cell);
 }
Exemple #7
0
        public static TSpreadsheet Create <TSpreadsheet>(IBlueprint bp, int rowNum = 0, TSpreadsheet existing = null, Cell blueprintCost = null, int numToMake = 1) where TSpreadsheet : class, Spreadsheet, new()
        {
            var spreadsheet = existing ?? new TSpreadsheet();

            spreadsheet.AddCell(new SimpleCell(CommonQueries.GetTypeName(bp.Product)), 0, rowNum);
            var quantity = new SimpleCell(numToMake.ToString());

            var brokerFee      = new SimpleCell("0.0045");
            var transactionTax = new SimpleCell("0.0105");

            rowNum++;

            spreadsheet.AddCell(new SimpleCell("Quantity"), 1, rowNum);
            spreadsheet.AddCell(new SimpleCell("Buy"), 2, rowNum);
            spreadsheet.AddCell(new SimpleCell("Sell"), 3, rowNum);
            spreadsheet.AddCell(new SimpleCell("BrokerFee"), 4, rowNum);
            spreadsheet.AddCell(new SimpleCell("TransactionTax"), 5, rowNum);
            spreadsheet.AddCell(new SimpleCell("Buy/Sell/CustomBuy"), 6, rowNum);
            spreadsheet.AddCell(new SimpleCell("Unit Cost"), 7, rowNum);
            spreadsheet.AddCell(new SimpleCell("Cost per run"), 8, rowNum);
            spreadsheet.AddCell(new SimpleCell("Total cost"), 9, rowNum);
            spreadsheet.AddCell(new SimpleCell("(Needed)"), 10, rowNum);

            rowNum++;
            Cell topUnitCost = null, bottomUnitCost = null;
            Cell topCostPerRun = null, bottomCostPerRun = null;
            Cell topTotalCost = null, bottomTotalCost = null;

            foreach (var mat in bp.Materials)
            {
                spreadsheet.AddCell(new SimpleCell(CommonQueries.GetTypeName(mat.matID)), 0, rowNum);
                var matQty = spreadsheet.AddCell(new SimpleCell("=" + mat.quantity.ToString() + "*" + mat.damagePerJob.ToString()), 1, rowNum);

                var buy      = spreadsheet.AddCell(new EveCentralCell(mat.matID, type: PriceType.buy, measure: PriceMeasure.max), 2, rowNum);
                var sell     = spreadsheet.AddCell(new EveCentralCell(mat.matID, type: PriceType.sell, measure: PriceMeasure.min), 3, rowNum);
                var bfAmount = spreadsheet.AddCell(new FormulaCell("={0}*{1}", brokerFee, buy), 4, rowNum);
                // 5 empty
                var buysell = spreadsheet.AddCell(new SimpleCell("Sell"), 6, rowNum);

                var unitCost = spreadsheet.AddCell(new FormulaCell("=if({0}=\"Sell\",{1},if({0}=\"Buy\",{2}+{3},{0}+{3}))", buysell, sell, buy, bfAmount), 7, rowNum);

                bottomUnitCost = unitCost; topUnitCost = topUnitCost ?? unitCost;

                var costPerRun = spreadsheet.AddCell(new FormulaCell("={0}*{1}", unitCost, matQty), 8, rowNum);
                bottomCostPerRun = costPerRun; topCostPerRun = topCostPerRun ?? bottomCostPerRun;

                var totalCost = spreadsheet.AddCell(new FormulaCell("={0}*{1}", costPerRun, quantity), 9, rowNum);
                bottomTotalCost = totalCost; topTotalCost = topTotalCost ?? totalCost;

                var needed = spreadsheet.AddCell(new FormulaCell("={0}*{1}", matQty, quantity), 10, rowNum);

                rowNum++;
            }

            if (blueprintCost != null)
            {
                spreadsheet.AddCell(new SimpleCell("Blueprint (per unit)"), 0, rowNum);
                var costPerRun = spreadsheet.AddCell(new FormulaCell("={0}", blueprintCost), 8, rowNum);
                bottomCostPerRun = costPerRun; topCostPerRun = topCostPerRun ?? bottomCostPerRun;

                var totalCost = spreadsheet.AddCell(new FormulaCell("={0}*{1}", costPerRun, quantity), 9, rowNum);
                bottomTotalCost = totalCost; topTotalCost = topTotalCost ?? totalCost;

                rowNum++;
            }

            var totalUnitCost   = spreadsheet.AddCell(new FormulaCell("=SUM({0}:{1})", topUnitCost, bottomUnitCost), 7, rowNum);
            var totalCostPerRun = spreadsheet.AddCell(new FormulaCell("=SUM({0}:{1})", topCostPerRun, bottomCostPerRun), 8, rowNum);
            var totalTotalCost  = spreadsheet.AddCell(new FormulaCell("=SUM({0}:{1})", topTotalCost, bottomTotalCost), 9, rowNum);

            rowNum += 2;

            spreadsheet.AddCell(new SimpleCell("Buy/Sell/CustomSell"), 6, rowNum);
            spreadsheet.AddCell(new SimpleCell("Unit Value"), 7, rowNum);
            spreadsheet.AddCell(new SimpleCell("Total Value"), 9, rowNum);

            rowNum++;
            spreadsheet.AddCell(new SimpleCell(CommonQueries.GetTypeName(bp.Product)), 0, rowNum);
            var prodBuy  = spreadsheet.AddCell(new EveCentralCell(bp.Product, type: PriceType.buy, measure: PriceMeasure.max), 2, rowNum);
            var prodSell = spreadsheet.AddCell(new EveCentralCell(bp.Product, type: PriceType.sell, measure: PriceMeasure.min), 3, rowNum);
            // 4 empty
            var ttAmount    = spreadsheet.AddCell(new FormulaCell("={0}*{1}", prodSell, transactionTax), 5, rowNum);
            var prodBuySell = spreadsheet.AddCell(new SimpleCell("Sell"), 6, rowNum);
            var prodValue   = spreadsheet.AddCell(new FormulaCell("=if({0}=\"Sell\",{1}-{3},if({0}=\"Buy\",{2},{0}-{3}))", prodBuySell, prodSell, prodBuy, ttAmount), 7, rowNum);
            var totalValue  = spreadsheet.AddCell(new FormulaCell("={0}*{1}", prodValue, quantity), 9, rowNum);

            rowNum += 2;
            spreadsheet.AddCell(new SimpleCell("Profit"), 9, rowNum);
            spreadsheet.AddCell(new SimpleCell("Margin"), 10, rowNum);

            rowNum++;
            var profit = spreadsheet.AddCell(new FormulaCell("={0}-{1}", totalValue, totalTotalCost), 9, rowNum);

            spreadsheet.AddCell(new FormulaCell("={0}/{1}", profit, totalValue), 10, rowNum);

            rowNum--;

            spreadsheet.AddCell(new SimpleCell("Number of runs: "), 0, rowNum);
            spreadsheet.AddCell(quantity, 1, rowNum);
            rowNum++;
            spreadsheet.AddCell(new SimpleCell("Broker fee: "), 0, rowNum);
            spreadsheet.AddCell(brokerFee, 1, rowNum);
            rowNum++;
            spreadsheet.AddCell(new SimpleCell("Transaction tax: "), 0, rowNum);
            spreadsheet.AddCell(transactionTax, 1, rowNum);
            rowNum++;
            spreadsheet.AddCell(new SimpleCell("Production time: "), 0, rowNum);
            spreadsheet.AddCell(new SimpleCell(bp.ManufacturingTime().FormatSeconds()), 1, rowNum);
            var mt = spreadsheet.AddCell(new SimpleCell(bp.ManufacturingTime().ToString()), 2, rowNum);

            return(spreadsheet);
        }
Exemple #8
0
        /**
         * Returns a Cell based on the styleattributes.
         *
         * @param attributes
         * @param styleattributes
         * @return an iText Cell
         */
        private IElement RetrieveTableRow(Properties attributes,
                                          Properties styleattributes)
        {
            SimpleCell row = new SimpleCell(SimpleCell.ROW);

            ApplyBordersColors(row, attributes, styleattributes);
            String width = null;

            if (attributes != null)
            {
                width = attributes[MarkupTags.HTML_ATTR_WIDTH];
            }
            if (width == null)
            {
                width = styleattributes[MarkupTags.HTML_ATTR_WIDTH];
            }
            if (width != null)
            {
                if (width.EndsWith("%"))
                {
                    row.Widthpercentage = ParseLength(width);
                }
                else
                {
                    row.Width = ParseLength(width);
                }
            }
            String margin = styleattributes[MarkupTags.CSS_KEY_MARGIN];
            float  f;

            if (margin != null)
            {
                f           = ParseLength(margin);
                row.Spacing = f;
            }
            margin = styleattributes[MarkupTags.CSS_KEY_MARGINLEFT];
            if (margin != null)
            {
                f = ParseLength(margin);
                row.Spacing_left = f;
            }
            margin = styleattributes[MarkupTags.CSS_KEY_MARGINRIGHT];
            if (margin != null)
            {
                f = ParseLength(margin);
                row.Spacing_right = f;
            }
            margin = styleattributes[MarkupTags.CSS_KEY_MARGINTOP];
            if (margin != null)
            {
                f = ParseLength(margin);
                row.Spacing_top = f;
            }
            margin = styleattributes[MarkupTags.CSS_KEY_MARGINBOTTOM];
            if (margin != null)
            {
                f = ParseLength(margin);
                row.Spacing_bottom = f;
            }
            String padding = styleattributes[MarkupTags.CSS_KEY_PADDING];

            if (padding != null)
            {
                f           = ParseLength(padding);
                row.Padding = f;
            }
            padding = styleattributes[MarkupTags.CSS_KEY_PADDINGLEFT];
            if (padding != null)
            {
                f = ParseLength(padding);
                row.Spacing_left = f;
            }
            padding = styleattributes[MarkupTags.CSS_KEY_PADDINGRIGHT];
            if (padding != null)
            {
                f = ParseLength(padding);
                row.Spacing_right = f;
            }
            padding = styleattributes[MarkupTags.CSS_KEY_PADDINGTOP];
            if (padding != null)
            {
                f = ParseLength(padding);
                row.Spacing_top = f;
            }
            padding = styleattributes[MarkupTags.CSS_KEY_PADDINGBOTTOM];
            if (padding != null)
            {
                f = ParseLength(padding);
                row.Spacing_bottom = f;
            }
            return(row);
        }
Exemple #9
0
        public TimeSpan Duration()
        {
            TitleTime         tt          = new TitleTime();
            TimeSpan          duration    = TimeSpan.Zero;
            List <SimpleCell> SortedCells = new List <SimpleCell>();

            int pgc_num = ifoGetNumPGCI(Handle);

            for (int i = 0; i < pgc_num; i++)
            {
                int    num_cells = ifoGetPGCIInfo(Handle, i, ref tt);
                IntPtr ptr_cells = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(t_vs_vobcellid)) * num_cells);
                if (ptr_cells != IntPtr.Zero)
                {
                    try
                    {
                        if (ifoGetPGCICells(Handle, i, ptr_cells))
                        {
                            IntPtr ptr_cell = ptr_cells;
                            for (int k = 0; k < num_cells; k++)
                            {
                                t_vs_vobcellid cell = (t_vs_vobcellid)Marshal.PtrToStructure(ptr_cell, typeof(t_vs_vobcellid));
                                ptr_cell = new IntPtr(ptr_cell.ToInt64() + Marshal.SizeOf(typeof(t_vs_vobcellid))); //ptr += offset

                                //Сохраняем инфу от cell, если у нас такой еще нет (берутся только start\end_lba и time)
                                SimpleCell obj = new SimpleCell()
                                {
                                    start = cell.start_lba, end = cell.end_lba, time = cell.time
                                };
                                if (!SortedCells.Contains(obj))
                                {
                                    SortedCells.Add(obj);
                                }
                            }
                        }
                    }
                    finally
                    {
                        Marshal.FreeHGlobal(ptr_cells);
                    }
                }
            }

            foreach (SimpleCell cell in SortedCells)
            {
                #region frames bits

                /*
                 * 1 0 0 1 0 0 1 0  (73)
                 * 1 0 0 1 0 0 0 0  (9, & 0x3f) 25fps
                 * 0 0 0 0 0 0 1 0  (64, & ~0x3f) 25fps
                 *
                 * 0 1 0 1 0 0 0 0  (10, & 0x3f) 29fps
                 * 0 0 0 0 0 0 1 1  (192, & ~0x3f) 29fps
                 */
                #endregion

                duration += TimeSpan.FromHours(cell.time.hours) +
                            TimeSpan.FromMinutes(cell.time.minutes) +
                            TimeSpan.FromSeconds(cell.time.seconds) +
                            TimeSpan.FromMilliseconds((cell.time.frames & 0x3f) * //Перевод кадров в ms
                                                      (((cell.time.frames & (1 << 7)) != 0) ? 1000.0 / (30000.0 / 1001.0) : 40.0));
            }

            return(duration);
        }