private Dictionary <string, IndexBlock> GetIndexDict(FileStream fileStream, TableBlock tableBlock)
        {
            Dictionary <string, IndexBlock> indexDict = new Dictionary <string, IndexBlock>();

            long       indexBlockHeadPos = tableBlock.IndexBlockHeadPos;
            IndexBlock currentIndexBlock = fileStream.ReadBlock <IndexBlock>(indexBlockHeadPos);

            tableBlock.IndexBlockHead = currentIndexBlock;

            currentIndexBlock.TryLoadNextObj(fileStream);// 此时的currentIndexBlock是索引块的头结点。
            while (currentIndexBlock.NextObj != null)
            {
                SkipListNodeBlock[] headNodes = GetHeadNodesOfSkipListNodeBlock(fileStream, currentIndexBlock.NextObj);
                currentIndexBlock.NextObj.SkipListHeadNodes = headNodes;
                SkipListNodeBlock tailNode = GetTailNodeOfSkipListNodeBlock(fileStream, currentIndexBlock.NextObj);
                currentIndexBlock.NextObj.SkipListTailNode = tailNode;
                foreach (SkipListNodeBlock headNode in currentIndexBlock.NextObj.SkipListHeadNodes)
                {
                    if (headNode.RightPos == tailNode.ThisPos)
                    {
                        headNode.RightObj = tailNode;
                    }
                }

                currentIndexBlock.NextObj.TryLoadNextObj(fileStream);

                indexDict.Add(currentIndexBlock.NextObj.BindMember, currentIndexBlock.NextObj);

                currentIndexBlock = currentIndexBlock.NextObj;
            }
            return(indexDict);
        }
示例#2
0
 void OnDataVisibilityChanged(TableBlock block)
 {
     if (DataVisibilityChanged != null)
     {
         DataVisibilityChanged(block);
     }
 }
示例#3
0
 void OnSelectionChanged(TableBlock block, bool toggle)
 {
     if (SelectionChanged != null)
     {
         SelectionChanged(block, toggle);
     }
 }
示例#4
0
 void DefaultEditor_DataVisibilityChanged(TableBlock block)
 {
     if (_systemEditor != null)
     {
         _systemEditor.SetVisibility(block);
     }
 }
示例#5
0
        //static readonly Brush tableBrush = new LinearGradientBrush(new Rectangle(0, 0, Consts.tableBlockLength, bmpHeight), Color.LightBlue, Color.DarkBlue, 0f);

        private static void DrawTables(FileDBContext db, FileStream fs, Bitmap[] bmps)
        {
            TableBlock tableBlockHead = db.GetTableBlockHeadNode();
            TableBlock previousTable  = tableBlockHead;

            {
                long     index    = previousTable.ThisPos.PagePos() / Consts.pageSize;
                Bitmap   bmp      = bmps[index];
                Graphics g        = Graphics.FromImage(bmp);
                int      length   = previousTable.ToBytes().Length;
                int      startPos = (int)(previousTable.ThisPos - Consts.pageSize * index);
                Brush    brush    = new LinearGradientBrush(new Point(startPos, 0), new Point(startPos + length), Color.DarkOrange, Color.OrangeRed);
                g.FillRectangle(brush, startPos, 1, length, bmpHeight - 1);
                g.DrawRectangle(boundPen, startPos, 1, length, bmpHeight - 1);
                g.Dispose();
            }
            while (previousTable.NextPos != 0)
            {
                previousTable.TryLoadNextObj(fs);
                TableBlock table = previousTable.NextObj;

                long     index    = table.ThisPos.PagePos() / Consts.pageSize;
                Bitmap   bmp      = bmps[index];
                Graphics g        = Graphics.FromImage(bmp);
                int      length   = table.ToBytes().Length;
                int      startPos = (int)(table.ThisPos - Consts.pageSize * index);
                Brush    brush    = new LinearGradientBrush(new Point(startPos, 0), new Point(startPos + length, 0), Color.DarkOrange, Color.OrangeRed);
                g.FillRectangle(brush, startPos, 1, length, bmpHeight - 1);
                g.DrawRectangle(boundPen, startPos, 1, length, bmpHeight - 1);
                g.Dispose();

                previousTable = table;
            }
        }
示例#6
0
        public void A_Table_Is_Formatted_With_Results()
        {
            var mockStyle = new MockStylist
            {
            };

            var table = new Table();

            table.HeaderRow = new TableRow(new[] { "Col1", "Col2" });
            table.DataRows  = new System.Collections.Generic.List <ObjectModel.TableRow>();
            AddRowWithResult(table, new[] { "Col1Row1", "Col2Row1" }, TestResult.Passed);
            AddRowWithResult(table, new[] { "Col1Row2", "Col2Row2" }, TestResult.Failed);
            AddRowWithResult(table, new[] { "Col1Row3", "Col2Row3" }, TestResult.Inconclusive);
            AddRowWithResult(table, new[] { "Col1Row4", "Col2Row4" }, TestResult.NotProvided);

            var tableBlock   = new TableBlock(table, mockStyle, true);
            var actualString = tableBlock.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.AreEqual("> | Col1 | Col2 | Result |", actualString[0]);
            Assert.AreEqual("> | --- | --- | --- |", actualString[1]);
            Assert.AreEqual("> | Col1Row1 | Col2Row1 | ![Passed](pass.png) |", actualString[2]);
            Assert.AreEqual("> | Col1Row2 | Col2Row2 | ![Failed](fail.png) |", actualString[3]);
            Assert.AreEqual("> | Col1Row3 | Col2Row3 | ![Inconclusive](inconclusive.png) |", actualString[4]);
            Assert.AreEqual("> | Col1Row4 | Col2Row4 |  |", actualString[5]);
            Assert.AreEqual(7, actualString.Length);
        }
示例#7
0
 void OnDataManipulated(TableBlock newBlock, TableBlock oldBlock)
 {
     if (DataManipulated != null)
     {
         DataManipulated(newBlock, oldBlock);
     }
 }
        /// <summary>
        /// Parse the document in order to proceed to the alimentation of all blocks into the given container.
        /// </summary>
        /// <param name="container">Container to build.</param>
        public virtual void ParseDocument(OpenXmlPartContainer container)
        {
            IList <BlockItem> blocks = GetBlocks(container);

            foreach (BlockItem block in blocks)
            {
                BlockConfiguration config = GetBlockConfiguration(block);
                try
                {
                    if (TextBlock.IsMatching(config.Type))
                    {
                        TextBlock.BuildContent(ReportData, container, block, config.Name, config.Options);
                    }
                    else if (TableBlock.IsMatching(config.Type))
                    {
                        TableBlock.BuildContent(ReportData, container, block, config.Name, config.Options);
                    }
                    else if (GraphBlock.IsMatching(config.Type))
                    {
                        GraphBlock.BuildContent(ReportData, Package, block, config.Name, config.Options);
                    }
                    else
                    {
                        LogHelper.Instance.LogWarnFormat("Block type '{0}' not found.", config.Type);
                    }
                }
                catch (Exception exception)
                {
                    string logMessage = $"Exception thrown during document parsing (BlockType : {(null != config ? config.Type : string.Empty)}, BlockName : {(null != config ? config.Name : string.Empty)})";
                    LogHelper.Instance.LogError(logMessage, exception);
                }
            }
        }
示例#9
0
 public static void SetUniverseObjectType(TableBlock block)
 {
     if (block.Block.Name.Equals("system", StringComparison.OrdinalIgnoreCase))
     {
         block.ObjectType = ContentType.System;
     }
 }
示例#10
0
    public void CreateNewBlock(int slotIndex)
    {
        TableBlock new_block = blockManager.CreateNewBlock(slotIndex);

        if (action_create_blocks != null)
        {
            action_create_blocks(slotIndex, new_block);
        }
    }
示例#11
0
        void systemEditor_SelectionChanged(TableBlock block, bool toggle)
        {
            frmTableEditor tableEditor = dockPanel1.ActiveDocument as frmTableEditor;

            if (tableEditor != null)
            {
                tableEditor.Select(block, toggle);
            }
        }
        /// <summary>
        /// 删除数据库文件里的某个表及其所有索引、数据。
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public bool DeleteTable <T>() where T : Table
        {
            Type type = typeof(T);

            if (!this.tableBlockDict.ContainsKey(type))
            {
                return(false);
            }

            // 删除表、索引和数据。
            FileStream  fs = this.fileStream;
            Transaction ts = this.transaction;

            ts.Begin();

            try
            {
                TableBlock table = this.tableBlockDict[type];
                ts.Delete(table);

                long       currentIndexPos = table.IndexBlockHeadPos;
                IndexBlock IndexHead       = fs.ReadBlock <IndexBlock>(currentIndexPos);// 此时指向IndexBlock头结点
                ts.Delete(IndexHead);
                // 删除数据块。
                {
                    IndexHead.TryLoadNextObj(fs);
                    IndexBlock currentIndex = IndexHead.NextObj;// 此时指向PK
                    ts.Delete(currentIndex);
                    DeleteDataBlocks(currentIndex, fs, ts);
                }
                // 删除索引块和skip list node块。
                {
                    IndexBlock currentIndex = IndexHead;
                    while (currentIndex.NextPos != 0)
                    {
                        currentIndex.TryLoadNextObj(fs);
                        ts.Delete(currentIndex.NextObj);

                        DeleteSkipListNodes(currentIndex, fs, ts);

                        currentIndex = currentIndex.NextObj;
                    }
                }

                this.tableBlockDict.Remove(type);
                this.tableIndexBlockDict.Remove(type);

                ts.Commit();

                return(true);
            }
            catch (Exception ex)
            {
                ts.Rollback();
                throw ex;
            }
        }
示例#13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reportData"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            bool isDisplayShortHeader = (options != null && options.ContainsKey("HEADER") && "SHORT" == options["HEADER"]);

            List <string> rowData = new List <string>();

            rowData.AddRange(isDisplayShortHeader
                ? new[] { " ", Labels.TQICur, Labels.TQIPrev, Labels.Var }
                : new[] { " ", Labels.TQICurrent, Labels.TQIPrevious, Labels.Variation });

            var resultCurrentSnapshot  = BusinessCriteriaUtility.GetBusinessCriteriaGradesModules(reportData.CurrentSnapshot, false);
            var resultPreviousSnapshot = BusinessCriteriaUtility.GetBusinessCriteriaGradesModules(reportData.PreviousSnapshot, false);

            int count = 0;

            if (resultCurrentSnapshot != null)
            {
                if (resultPreviousSnapshot == null)
                {
                    resultPreviousSnapshot = new List <BusinessCriteriaDTO>();
                }

                var results = from current in resultCurrentSnapshot
                              join prev in resultPreviousSnapshot on current.Name equals prev.Name
                              into g
                              from subset in g.DefaultIfEmpty()
                              select new
                {
                    Name             = current.Name,
                    TqiCurrent       = current.TQI.HasValue ? current.TQI : (double?)null,
                    TqiPrevious      = subset != null ? subset.TQI : (double?)null,
                    PercentVariation = subset != null?MathUtility.GetVariationPercent(current.TQI, subset.TQI) : null
                };


                foreach (var result in results.OrderBy(_ => _.Name))
                {
                    rowData.AddRange(new[] {
                        result.Name,
                        result.TqiCurrent.HasValue  ? result.TqiCurrent.Value.ToString(_MetricFormat) : CastReporting.Domain.Constants.No_Value,
                        result.TqiPrevious.HasValue ? result.TqiPrevious.Value.ToString(_MetricFormat) : CastReporting.Domain.Constants.No_Value,
                        result.PercentVariation.HasValue ? TableBlock.FormatPercent(result.PercentVariation):CastReporting.Domain.Constants.No_Value,
                    });
                    count++;
                }
            }

            var resultTable = new TableDefinition {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = count + 1,
                NbColumns        = 4,
                Data             = rowData
            };

            return(resultTable);
        }
示例#14
0
        public void GetRootElementReturnsCorrectElementInRootElementDefinedBlock()
        {
            WebDriverWait wait        = new WebDriverWait(this.Driver, TimeSpan.FromSeconds(5));
            IWebElement   rootElement = wait.Until(
                driver => driver.FindElement(By.CssSelector(TableBlock.CustomerTableRootElementCssSelector)));
            TableBlock tableBlock = new TableBlock(rootElement, this.Driver);

            tableBlock.GetRootElement().Should().Be(rootElement);
        }
示例#15
0
        public static void SetModelPreviewObjectType(TableBlock block)
        {
            ArchetypeInfo info = GetModelPreviewInfo(block.Block);

            if (info != null)
            {
                block.Archetype  = info;
                block.ObjectType = info.Type;
            }
        }
示例#16
0
        public static void SetSolarArchetypeObjectType(TableBlock block)
        {
            KeyValuePair <string, ArchetypeInfo> info = GetArchetypeInfo(block.Block);

            if (info.Key != null)
            {
                block.Archetype  = info.Value;
                block.ObjectType = info.Value.Type;
            }
        }
示例#17
0
    public bool IsEnablePutBlock(int slotIndex)
    {
        TableBlock block = blockManager.GetBlockByNumber(slotIndex);

        if (block == null)
        {
            return(false);
        }

        return(mapManager.IsSetAnyBlock(block.tile));
    }
示例#18
0
        private string GetTextFromTable(TableBlock tableBlock)
        {
            StringBuilder sb = new StringBuilder();

            foreach (TableCell c in tableBlock.Cells)
            {
                sb.Append(GetTextFromBlock(c.Block));
            }

            return(sb.ToString());
        }
示例#19
0
        private static void DrawDataBlocks(FileDBContext db, FileStream fs, Bitmap[] bmps)
        {
            TableBlock tableBlockHead = db.GetTableBlockHeadNode();
            TableBlock previousTable  = tableBlockHead;

            while (previousTable.NextPos != 0)
            {
                TableBlock table = previousTable.NextObj;

                IndexBlock currentIndex = table.IndexBlockHead;
                while (currentIndex.NextObj != null)
                {
                    SkipListNodeBlock currentNode = currentIndex.NextObj.SkipListHeadNodes[0];
                    while (currentNode != null)
                    {
                        if (currentNode.KeyPos != 0)
                        {
                            currentNode.TryLoadProperties(fs, SkipListNodeBlockLoadOptions.Key | SkipListNodeBlockLoadOptions.Value);
                            {
                                long     index    = currentNode.Key.ThisPos.PagePos() / Consts.pageSize;
                                Bitmap   bmp      = bmps[index];
                                Graphics g        = Graphics.FromImage(bmp);
                                int      startPos = (int)(currentNode.Key.ThisPos - Consts.pageSize * index);
                                int      length   = currentNode.Key.ToBytes().Length;
                                Brush    brush    = new LinearGradientBrush(new Point(startPos, 0), new Point(startPos + length, 0), Color.DarkGoldenrod, Color.LightGoldenrodYellow);
                                g.FillRectangle(brush, startPos, 1, length, bmpHeight - 1);
                                g.DrawRectangle(boundPen, startPos, 1, length, bmpHeight - 1);
                                g.Dispose();
                            }
                            foreach (var dataBlock in currentNode.Value)
                            {
                                long     index    = dataBlock.ThisPos.PagePos() / Consts.pageSize;
                                Bitmap   bmp      = bmps[index];
                                Graphics g        = Graphics.FromImage(bmp);
                                int      startPos = (int)(dataBlock.ThisPos - Consts.pageSize * index);
                                int      length   = dataBlock.ToBytes().Length;
                                Brush    brush    = new LinearGradientBrush(new Point(startPos, 0), new Point(startPos + length, 0), Color.DarkGoldenrod, Color.LightGoldenrodYellow);
                                g.FillRectangle(brush, startPos, 1, length, bmpHeight - 1);
                                g.DrawRectangle(boundPen, startPos, 1, length, bmpHeight - 1);
                                g.Dispose();
                            }
                        }

                        currentNode.TryLoadProperties(fs, SkipListNodeBlockLoadOptions.RightObj);
                        currentNode = currentNode.RightObj;
                    }

                    currentIndex = currentIndex.NextObj;
                }

                previousTable = table;
            }
        }
示例#20
0
        void systemEditor_DataManipulated(TableBlock newBlock, TableBlock oldBlock)
        {
            frmTableEditor tableEditor = dockPanel1.ActiveDocument as frmTableEditor;

            if (tableEditor != null)
            {
                tableEditor.ChangeBlocks(new List <TableBlock> {
                    newBlock
                }, new List <TableBlock> {
                    oldBlock
                });
            }
        }
        public static void Make(this TableBlock block, Document document)
        {
            var table = new Table
            {
                Style = "table"
            };

            table.Format.Alignment    = ParagraphAlignment.Center;
            table.Format.SpaceAfter   = new Unit(1, UnitType.Centimeter);
            table.Format.WidowControl = true;

            //table.BottomPadding = new Unit(1, UnitType.Centimeter);

            table.Borders.Width = 0.75;

            for (var i = 0; i < block.ColumnDefinitions.Count; i++)
            {
                var column = table.AddColumn();

                column.Format.Alignment = block.ColumnDefinitions[i].Alignment switch
                {
                    ColumnAlignment.Center => ParagraphAlignment.Center,
                    ColumnAlignment.Right => ParagraphAlignment.Right,
                    _ => ParagraphAlignment.Left,
                };
            }



            for (var i = 0; i < block.Rows.Count; i++)
            {
                var row = table.AddRow();
                row.Height     = 1;
                row.HeightRule = RowHeightRule.AtLeast;
                var originalRow = block.Rows[i].Cells;

                for (int j = 0; j < originalRow.Count; j++)
                {
                    var cell = row.Cells[j];

                    var p = cell.AddParagraph();
                    p.Style = "NoSpacing";
                    originalRow[j].Inlines.FillInlines(p);
                }
            }


            table.SetEdge(0, 0, block.ColumnDefinitions.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 1.5, Colors.Black);

            document.LastSection.Add(table);
        }
示例#22
0
        private static void PrintSkipLists(FileDBContext db, StringBuilder builder, FileStream fs)
        {
            TableBlock tableHead         = db.GetTableBlockHeadNode();// fs.ReadBlock<TableBlock>(fs.Position);
            TableBlock currentTableBlock = tableHead;

            while (currentTableBlock.NextPos != 0)// 依次Print各个表
            {
                TableBlock tableBlock = fs.ReadBlock <TableBlock>(currentTableBlock.NextPos);
                builder.Append("Table:"); builder.AppendLine(tableBlock.TableType.ToString());
                IndexBlock indexBlockHead    = fs.ReadBlock <IndexBlock>(tableBlock.IndexBlockHeadPos);
                IndexBlock currentIndexBlock = indexBlockHead;
                IndexBlock indexBlock        = fs.ReadBlock <IndexBlock>(currentIndexBlock.NextPos);

                SkipListNodeBlock currentHeadNode = fs.ReadBlock <SkipListNodeBlock>(indexBlock.SkipListHeadNodePos);
                int level = db.GetDBHeaderBlock().MaxLevelOfSkipList - 1;
                SkipListNodeBlock current = currentHeadNode;
                while (current != null)// 依次Print表的PK Index
                {
                    StringBuilder levelBuilder = new StringBuilder();
                    levelBuilder.AppendLine(string.Format("level {0}", level--));
                    string str = Print(current);
                    levelBuilder.AppendLine(str);
                    int count = 1;
                    while (current.RightPos != 0)//依次Print PK Index的Level
                    {
                        current = fs.ReadBlock <SkipListNodeBlock>(current.RightPos);
                        str     = Print(current);
                        levelBuilder.AppendLine(str);
                        count++;
                    }

                    if (count > 2)
                    {
                        builder.AppendLine(levelBuilder.ToString());
                    }

                    if (currentHeadNode.DownPos != 0)
                    {
                        currentHeadNode = fs.ReadBlock <SkipListNodeBlock>(currentHeadNode.DownPos);
                    }
                    else
                    {
                        currentHeadNode = null;
                    }
                    current = currentHeadNode;
                }

                currentTableBlock = tableBlock;
            }
        }
示例#23
0
        public void GetRootElementReturnsCorrectElementInCssSelectorDefinedBlock()
        {
            By rootElementBy = By.CssSelector(TableBlock.CustomerTableRootElementCssSelector);

            WebDriverWait wait = new WebDriverWait(this.Driver, TimeSpan.FromSeconds(5));
            IWebElement   expectedRootElement = wait.Until(
                driver => driver.FindElement(rootElementBy));

            // TableBlock(IWebDriver.....) constructor calls the BlockController(string rootCssSelector....) constructor
            TableBlock tableBlock =
                new TableBlock(this.Driver);

            tableBlock.GetRootElement().Should().Be(expectedRootElement);
        }
示例#24
0
        /// <summary>
        /// Renders a table element.
        /// </summary>
        private void RenderTable(TableBlock element, UIElementCollection blockUIElementCollection, RenderContext context)
        {
            var table = new MarkdownTable(element.ColumnDefinitions.Count, element.Rows.Count, TableBorderThickness,
                                          TableBorderBrush)
            {
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin = TableMargin
            };

            // Add each row.
            for (int rowIndex = 0; rowIndex < element.Rows.Count; rowIndex++)
            {
                var row = element.Rows[rowIndex];

                // Add each cell.
                for (int cellIndex = 0; cellIndex < Math.Min(element.ColumnDefinitions.Count, row.Cells.Count); cellIndex++)
                {
                    var cell = row.Cells[cellIndex];

                    // Cell content.
                    var cellContent = CreateOrReuseRichTextBlock(null, context);
                    cellContent.Margin = TableCellPadding;
                    Grid.SetRow(cellContent, rowIndex);
                    Grid.SetColumn(cellContent, cellIndex);
                    switch (element.ColumnDefinitions[cellIndex].Alignment)
                    {
                    case ColumnAlignment.Center:
                        cellContent.TextAlignment = TextAlignment.Center;
                        break;

                    case ColumnAlignment.Right:
                        cellContent.TextAlignment = TextAlignment.Right;
                        break;
                    }

                    if (rowIndex == 0)
                    {
                        cellContent.FontWeight = FontWeights.Bold;
                    }

                    var paragraph = new Paragraph();
                    context.TrimLeadingWhitespace = true;
                    RenderInlineChildren(paragraph.Inlines, cell.Inlines, paragraph, context);
                    cellContent.Blocks.Add(paragraph);
                    table.Children.Add(cellContent);
                }
            }

            blockUIElementCollection.Add(table);
        }
        public void Select(TableBlock block)
        {
            // return if object is already selected

            /*if (this.presenter.SelectedContent != null && this.presenter.SelectedContent.Block.Id == block.Id)
             * {
             *  return;
             * }*/

            if (block.Visibility)
            {
                bool isModelPreview = this.presenter.ViewerType == ViewerType.SolarArchetype || this.presenter.ViewerType == ViewerType.ModelPreview;
                if (isModelPreview)
                {
                    ContentBaseList.ClearAll(this.presenter);
                    this.presenter.ClearDisplay(false);
                    this.presenter.Add(block);
                }

                // select object
                ContentBase content = this.presenter.FindContent(block);
                if (content != null)
                {
                    ContentBaseList.AddItem(this.presenter, content);

                    if (isModelPreview)
                    {
                        // focus and zoom into object
                        this.presenter.LookAtAndZoom(content, 1.25, false);
                    }

                    return;
                }
            }
            else
            {
                // show selection box for invisible objects
                ContentBase content = Presenter.CreateContent(block.ObjectType);
                if (content != null)
                {
                    SystemParser.SetValues(content, block, false);
                    ContentBaseList.AddItem(this.presenter, content);
                    return;
                }
            }

            // deselect currect selection if nothing could be selected
            this.Deselect();
        }
示例#26
0
 public void SetVisibility(TableBlock block)
 {
     if (block.Visibility)
     {
         _presenter.Add(block);
     }
     else
     {
         ContentBase content = _presenter.FindContent(block);
         if (content != null)
         {
             _presenter.Delete(content);
         }
     }
 }
示例#27
0
        void SetArchtype(TableBlock block, ArchtypeManager archtypeManager)
        {
            switch (block.Block.Name.ToLower())
            {
            case "lightsource":
                block.ObjectType = FreelancerModStudio.SystemPresenter.ContentType.LightSource;
                break;

            case "zone":
                block.ObjectType = FreelancerModStudio.SystemPresenter.ContentType.Zone;
                break;

            case "object":

                bool hasArchtype = false;

                //get type of object based on archtype
                foreach (EditorINIOption option in block.Block.Options)
                {
                    if (option.Name.ToLower() == "archetype")
                    {
                        if (option.Values.Count > 0)
                        {
                            block.Archtype = archtypeManager.TypeOf(option.Values[0].Value.ToString());
                            if (block.Archtype != null)
                            {
                                block.ObjectType = block.Archtype.Type;
                                hasArchtype      = true;
                            }

                            break;
                        }
                    }
                }

                if (!hasArchtype)
                {
                    block.ObjectType = FreelancerModStudio.SystemPresenter.ContentType.None;
                }

                break;
            }

            if (block.ObjectType != FreelancerModStudio.SystemPresenter.ContentType.None)
            {
                block.Visibility = true;
            }
        }
示例#28
0
        private static void PrintIndexBlock(TableBlock table, IndexBlock index, string dir, string prefix, FileDBContext db)
        {
            List <List <SkipListNodeBlock> >     skipList;
            Dictionary <long, DataBlock>         keyDict;
            Dictionary <long, DataBlock>         valueDict;
            Dictionary <long, SkipListNodeBlock> skipListNodeDict;

            GetSkipListInfo(index, db, out skipList, out keyDict, out valueDict, out skipListNodeDict);

            if (keyDict.Count != valueDict.Count)
            {
                throw new Exception();
            }

            SaveToImage(table, index, skipList, keyDict, valueDict, skipListNodeDict, dir, prefix, db);
        }
        ContentBase GetContent(TableBlock block)
        {
            ContentBase content = GetContentFromType(block.ObjectType);

            if (content == null)
            {
                return(null);
            }

            content.Visibility = block.Visibility;
            content.ID         = block.ID;
            SetValues(content, block);

            content.Block = block;
            return(content);
        }
示例#30
0
        static bool SetBlock(ContentBase content, TableBlock block, bool animate)
        {
            // update the model if the object type or the archetype was changed
            bool modelChanged =
                content.Block == null ||
                content.Block.ObjectType != block.ObjectType ||
                content.Block.Archetype != block.Archetype;

            // set reference to block (this one is different than the one passed in the argument because a new copy was create in the undomanager)
            content.Block = block;

            // update transform after block was set
            content.UpdateTransform(animate);

            return(modelChanged);
        }
示例#31
0
        static bool tb_probe_(int side, int epsq, ref int dtm)
        {
            int idx = currentPctoi();

              int offset = 0;
              int remainder = 0;
              split_index(entries_per_block, idx, ref offset, ref remainder);

              int tableIndex = FindBlockIndex(offset, side);

              if(tableIndex==-1)
              {
            TableBlock t = new TableBlock(currentFilename, side, offset);

            zipStream.Seek(0, SeekOrigin.Begin);
            packStream.Seek(0, SeekOrigin.Begin);

            int block = egtb_block_getnumber(side, idx);
            int n = egtb_block_getsize(idx);
            int z = egtb_block_getsize_zipped(block);

            egtb_block_park(block);

            currentStream.Read(Buffer_zipped, 0, z);

            z=z-(LZMA86_HEADER_SIZE+1);
            Array.Copy(Buffer_zipped, LZMA86_HEADER_SIZE+1, Buffer_zipped, 0, z);

            decoder.Code(zipStream, packStream, (long)z, (long)n, null);

            egtb_block_unpack(side, n, Buffer_packed, ref t.pcache);

            blockCache.Add(t);
            if(blockCache.Count>256)
              blockCache.RemoveAt(0);

            dtm=t.pcache[remainder];
              }
              else
              {
            dtm=blockCache[tableIndex].pcache[remainder];
              }

              return true;
        }
示例#32
0
 private bool Equals(TableBlock other)
 {
     return (key==other.key)&&(side==other.side)&&(offset==other.offset);
 }