예제 #1
0
    private void CraftingInventoryLeftClick()
    {
        if (CopyOfItem == null)
        {
            if (Player.PStatus.SurvivalInv[ButtonID].BlockID != 0)
            {
                CopyOfItem = Player.PStatus.SurvivalInv[ButtonID];
                Player.PStatus.SurvivalInv[ButtonID] = new BlockItem();
            }
        }
        else
        {
            if (Player.PStatus.SurvivalInv[ButtonID].BlockID != 0)
            {
                BlockItem tmp = Player.PStatus.SurvivalInv[ButtonID];
                Player.PStatus.SurvivalInv[ButtonID] = CopyOfItem;
                CopyOfItem = tmp;
            }
            else
            {
                Player.PStatus.SurvivalInv[ButtonID] = CopyOfItem;
                CopyOfItem = null;
            }
        }

        PlayerGUI.UpdateCraftingInv();
        SetTextTemp3();
    }
예제 #2
0
    private void CraftingTableINLeftClick()
    {
        if (CopyOfItem == null)
        {
            if (GameManager._Instance.CraftTableData.B[ButtonID].BlockID != 0)
            {
                CopyOfItem = GameManager._Instance.CraftTableData.B[ButtonID];
                GameManager._Instance.CraftTableData.B[ButtonID] = new BlockItem();
            }
        }
        else
        {
            if (GameManager._Instance.CraftTableData.B[ButtonID].BlockID != 0)
            {
                BlockItem tmp = GameManager._Instance.CraftTableData.B[ButtonID];
                GameManager._Instance.CraftTableData.B[ButtonID] = CopyOfItem;
                CopyOfItem = tmp;
            }
            else
            {
                GameManager._Instance.CraftTableData.B[ButtonID] = CopyOfItem;
                CopyOfItem = null;
            }
        }

        PlayerCrafting.DoCrafting(false);
        PlayerGUI.UpdateCraftingTable();
        SetTextTemp3();
    }
예제 #3
0
    private void SurvivalInventoryToolbarLeftClick()
    {
        if (CopyOfItem == null)
        {
            if (Player.PStatus.ToolBox9[ButtonID].BlockID != 0)
            {
                CopyOfItem = Player.PStatus.ToolBox9[ButtonID];
                Player.PStatus.ToolBox9[ButtonID] = new BlockItem();
            }
        }
        else
        {
            if (Player.PStatus.ToolBox9[ButtonID].BlockID != 0)
            {
                BlockItem tmp = Player.PStatus.ToolBox9[ButtonID];
                Player.PStatus.ToolBox9[ButtonID] = CopyOfItem;
                CopyOfItem = tmp;
            }
            else
            {
                Player.PStatus.ToolBox9[ButtonID] = CopyOfItem;
                CopyOfItem = null;
            }
        }

        PlayerGUI.UpdateToolbar();
        SetTextTemp2();
    }
예제 #4
0
    private void MiniCraftingTableINLeftClick()
    {
        if (CopyOfItem == null)
        {
            if (GameManager._Instance.MCTGameObjs.B[ButtonID].BlockID != 0)
            {
                CopyOfItem = GameManager._Instance.MCTGameObjs.B[ButtonID];
                GameManager._Instance.MCTGameObjs.B[ButtonID] = new BlockItem();
            }
        }
        else
        {
            if (GameManager._Instance.MCTGameObjs.B[ButtonID].BlockID != 0)
            {
                BlockItem tmp = GameManager._Instance.MCTGameObjs.B[ButtonID];
                GameManager._Instance.MCTGameObjs.B[ButtonID] = CopyOfItem;
                CopyOfItem = tmp;
            }
            else
            {
                GameManager._Instance.MCTGameObjs.B[ButtonID] = CopyOfItem;
                CopyOfItem = null;
            }
        }

        PlayerMiniCrafting.DoMiniCrafting(false);
        PlayerGUI.UpdateMiniCraftingTable();
        SetTextTemp2();
    }
예제 #5
0
 public BlockItem(BlockItem a)
 {
     BlockID     = a.BlockID;
     Count       = a.Count;
     Level       = a.Level;
     isLevelType = a.isLevelType;
 }
예제 #6
0
        /// <summary>
        /// Reads an if statement from the input.
        /// </summary>
        /// <param name="input">Where to read input from.</param>
        /// <returns>The object that was read.</returns>
        protected virtual IParseStatement _readIf(Lexer input)
        {
            Token debug = input.Expect(TokenType.If);

            var exp = _readExp(input, out _);

            input.Expect(TokenType.Then);
            var block = _readBlock(input);

            var elseIfs = new List <IfItem.ElseInfo>();

            while (input.ReadIfType(TokenType.ElseIf))
            {
                IParseExp elseExp = _readExp(input, out _);
                input.Expect(TokenType.Then);
                BlockItem elseIfBlock = _readBlock(input);
                elseIfs.Add(new IfItem.ElseInfo(elseExp, elseIfBlock));
            }

            BlockItem elseBlock = null;

            if (input.ReadIfType(TokenType.Else))
            {
                elseBlock = _readBlock(input);
            }
            input.Expect(TokenType.End);
            return(new IfItem(exp, block, elseIfs.ToArray(), elseBlock)
            {
                Debug = debug
            });
        }
예제 #7
0
        private ByteBuffer[] GetBlockSendBuffer2(BlockItem item)
        {
            int start = item.StartAddress;
            int size  = item.EndAddress - start;
            var cc    = ServiceLocator.Locator.Resolve <IRealTagConsumer>() as RealEnginer;

            if (start >= cc.Memory.Length)
            {
                return(null);
            }

            //var re = Unpooled.Buffer(10);

            //re.WriteByte(ApiFunConst.RealDataPushFun);
            var re = Parent.Allocate(ApiFunConst.RealDataPushFun, 9);

            re.Write(RealDataBlockPush);
            re.Write(start);
            re.Write(size);

            var data = Parent.MemoryPool.GetBuffer();

            data.ReInit(cc.MemoryHandle + start, size);
            data.WriteIndex = size;

            return(new ByteBuffer[] { data, re });

            //return Unpooled.CompositeBuffer().AddComponents(true,re, Unpooled.WrappedBuffer(cc.Memory, start, size));

            // Buffer.BlockCopy(cc.Memory, start, re.Array, re.ArrayOffset + re.WriterIndex, size);
            // re.SetWriterIndex(re.WriterIndex + size);
            // return re;
        }
예제 #8
0
 public void SetSelected(BlockItem block)
 {
     if (Blocks != null)
     {
         Blocks.SelectedItem = block;
     }
 }
예제 #9
0
    // Add item to the inventory. Increase it's amount if it already exists
    public InventoryItem AddInventory(string itemName, double amount, ItemType itemType)
    {
        // Fetch Item from the Inventory
        InventoryItem item = GetInventoryItem(itemName, itemType);

        // Check if that Item exist
        if (item == null)
        {
            switch (itemType)
            {
            case ItemType.Block:
                item = new BlockItem(int.Parse(itemName), amount);
                FetchToBlockInventoryUi(item as BlockItem);
                break;
            }

            inventoryList.Add(item);
        }
        else
        {
            item.amount += amount;
        }

        RefreshInventory();

        return(item);
    }
예제 #10
0
        public void Count_votes_with_repeated()
        {
            var questionId = Guid.NewGuid();

            var pendings = new BlockItem[]
            {
                new Vote {
                    QuestionId = questionId, ChoiceId = juanId
                },
                new Vote {
                    QuestionId = questionId, ChoiceId = joseId
                },
                new Vote {
                    QuestionId = questionId, ChoiceId = juanId
                },
            };

            signer.Sign(pendings[0], alicia);
            signer.Sign(pendings[1], roberto);
            signer.Sign(pendings[2], alicia);

            Assert.IsFalse(pendings[0].PublicKey.SequenceEqual(pendings[1].PublicKey));
            Assert.IsTrue(pendings[0].PublicKey.SequenceEqual(pendings[2].PublicKey));

            blockchain.MineNextBlock(pendings);

            var counter = new Counter(blockchain);

            Assert.AreEqual(1, counter.TotalFor(juanId));
            Assert.AreEqual(1, counter.TotalFor(joseId));
        }
예제 #11
0
 private void BlockChanged(Vector3i pos)
 {
     if (entry.GetLinker() != null)
     {
         Vector3i startPosition = Position3i + Vector3i.Up * 3;
         for (int i = -1; i <= 1; i++)
         {
             for (int j = -1; j <= 1; j++)
             {
                 if (pos == startPosition + new Vector3i(i, 0, j))
                 {
                     Type blockType = World.GetBlock(pos).GetType();
                     if (blockType == typeof(EmptyBlock))
                     {
                         continue;
                     }
                     BlockItem       item = BlockItem.CreatingItem(blockType);
                     ConnectorObject obj  = entry.GetLinker().GetFirstValidOutput(this, item.GetType());
                     if (obj == null)
                     {
                         continue;
                     }
                     obj.Output.GetComponent <PublicStorageComponent>().Inventory.TryAddItem(item);
                     World.DeleteBlock(pos);
                 }
             }
         }
     }
 }
        public void Vote_Add()
        {
            Members_Register();
            var question = blockchain.Trunk.SelectMany(c => c.Questions).First();

            var pendings = new BlockItem[]
            {
                new Vote {
                    QuestionId = question.Id, ChoiceId = question.Choices[0].Id
                },
                new Vote {
                    QuestionId = question.Id, ChoiceId = question.Choices[1].Id
                },
                new Vote {
                    QuestionId = question.Id, ChoiceId = question.Choices[0].Id
                },
            };

            signer.Sign(pendings[0], alicia);
            signer.Sign(pendings[1], roberto);
            signer.Sign(pendings[2], camila);

            var block = blockchain.MineNextBlock(pendings);

            Assert.IsNotNull(block);
            Assert.AreEqual(3, block.Votes.Count);
            Assert.AreEqual(5, blockchain.Trunk.Count());

            var previousBlock = blockchain.GetBlock(3);

            Assert.IsTrue(block.PreviousHash.SequenceEqual(previousBlock.Hash));
            Assert.IsTrue(block.IsValid());
        }
예제 #13
0
        internal override void Receive()
        {
            if (!Config.IsSinglePlayer)
            {
                lock (TcpClient)
                {
                    base.Receive();
                    var bytes = ReadStream(DataLength);
                    Coords   = new Coords(bytes, 0);
                    Velocity = new Vector3(BitConverter.ToSingle(bytes, sizeof(float) * 5),
                                           BitConverter.ToSingle(bytes, sizeof(float) * 6),
                                           BitConverter.ToSingle(bytes, sizeof(float) * 7));
                    BlockType    = (Block.BlockType)BitConverter.ToUInt16(bytes, Coords.SIZE + Vector3.SizeInBytes);
                    GameObjectId = BitConverter.ToInt32(bytes, Coords.SIZE + Vector3.SizeInBytes + sizeof(ushort));
                }
            }

            //add the new block item to the chunk game items (note: constructor adds the item to the collection)
            var newBlockItem = new BlockItem(ref Coords, BlockType, Velocity, GameObjectId);

            if (Config.IsServer)
            {
                foreach (var player in Server.Controller.Players.Values)
                {
                    new AddBlockItem(ref newBlockItem.Coords, ref newBlockItem.Velocity, newBlockItem.BlockType, newBlockItem.Id)
                    {
                        ConnectedPlayer = player
                    }.Send();
                }
            }
        }
예제 #14
0
파일: FunctionItem.cs 프로젝트: mortend/uno
        public FunctionItem(Function function)
        {
            Function = function;

            if (!function.IsConstructor && !function.ReturnType.IsVoid)
            {
                Suffix = function.ReturnType.ToString();
            }

            if (function is Method && (function as Method).IsGenericDefinition)
            {
                AddChild(new ParameterizationCollection((function as Method).GenericParameterizations));
            }

            if (function is Method && (function as Method).DrawBlocks.Count > 0)
            {
                foreach (var d in (function as Method).DrawBlocks)
                {
                    var di = new BlockItem(d);
                    AddChild(di);

                    if (d.Drawables != null)
                    {
                        foreach (var p in d.Drawables)
                        {
                            if (p != null)
                            {
                                di.AddChild(new DrawItem(p));
                            }
                        }
                    }
                }
            }
        }
예제 #15
0
        private void dgvBadBlocks_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                try
                {
                    BlockItem item = _blocks[dgvBadBlocks.SelectedCells[0].RowIndex];
                    if (item != null)
                    {
                        //comboBoxItems.DisplayMember = "ToString";
                        comboBoxItems.SelectedIndex = comboBoxItems.FindStringExact(item.ToString());
                    }
                }
                catch { }

                if (e.RowIndex != -1 && e.ColumnIndex != -1)
                {
                    dgvBadBlocks[e.ColumnIndex, e.RowIndex].Selected = true;
                    dgvBadBlocks.BeginEdit(true);
                }
            }
            catch
            {
            }
        }
예제 #16
0
    public void ApplyOldBlock(BlockItem blockItem, int sprite, int valueStar)
    {
        blockItem.SetNoStar();
        HasItem  = true;
        CurBlock = blockItem;
        int  index = 0;
        bool star;

        for (int i = 0; i < GameController.Instance.BlockItemSprites.Count; i++)
        {
            if (sprite.ToString() == GameController.Instance.BlockItemSprites[i].name)
            {
                index = i;
            }
        }
        blockItem.SetDefaulSprite(GameController.Instance.BlockItemSprites[index]);
        Preview.sprite = null;
        Preview.DOKill();
        if (valueStar == 1)
        {
            star = true;
        }
        else
        {
            star = false;
        }
        _star.SetActive(star);
        HasStar = star;
    }
예제 #17
0
        /// <summary>
        /// Returns the block configuration of the block item given in parameter.
        /// </summary>
        /// <param name="block">Block where the block configuration parameters will be found.</param>
        /// <returns>The block configuration of the block item given in parameter.</returns>
        protected override BlockConfiguration GetBlockConfiguration(BlockItem block)
        {
            string alias    = null;
            string tag      = null;
            var    xElement = block.OxpBlock.Descendants <SdtProperties>().FirstOrDefault();

            if (xElement != null)
            {
                var aliasElement = xElement.Descendants <SdtAlias>().FirstOrDefault();
                if (aliasElement != null)
                {
                    alias = aliasElement.Val.Value;
                }
                var tagElement = xElement.Descendants <Tag>().FirstOrDefault();
                if (tagElement != null)
                {
                    tag = tagElement.Val.Value;
                }
            }
            else
            {
                var elt = block.OxpBlock
                          .Descendants <DocProperties>()
                          .FirstOrDefault(_ => !string.IsNullOrWhiteSpace(_.Description));
                if (null != elt)
                {
                    tag = elt.Description;
                }
            }
            return(GetBlockConfiguration(alias, tag));
        }
예제 #18
0
        private bool CheckGround()
        {
            bool x = true;

            foreach (Vector3i blockpos in positionstocheck)
            {
                BlockItem blockItem = BlockItem.CreatingItem(World.GetBlock(blockpos).GetType());
                if (blockItem != null)
                {
                    //ChatManager.ServerMessageToAllAlreadyLocalized(blockItem.UILinkAndNumber(1), false);
                    if (blockItem != neededBlockItem)
                    {
                        x = false;
                        //ChatManager.ServerMessageToAllAlreadyLocalized("Not the needed Block! Needs " + neededBlockItem.UILinkAndNumber(1),false);
                    }
                }
                else
                {
                    //ChatManager.ServerMessageToAllAlreadyLocalized("No Blockitem", false);
                    x = false;
                }
            }
            //ChatManager.ServerMessageToAllAlreadyLocalized(x? "Check passed" : "Check NOT passed" , false);
            return(x);
        }
예제 #19
0
        public void Count_3_votes()
        {
            var questionId = Guid.NewGuid();

            var pendings = new BlockItem[]
            {
                new Vote {
                    QuestionId = questionId, ChoiceId = juanId
                },
                new Vote {
                    QuestionId = questionId, ChoiceId = joseId
                },
                new Vote {
                    QuestionId = questionId, ChoiceId = juanId
                },
            };

            signer.Sign(pendings[0], alicia);
            signer.Sign(pendings[1], roberto);
            signer.Sign(pendings[2], camila);

            blockchain.MineNextBlock(pendings);

            var counter = new Counter(blockchain);

            Assert.AreEqual(2, counter.TotalFor(juanId));
            Assert.AreEqual(1, counter.TotalFor(joseId));
        }
예제 #20
0
        // Parses all required block data to send to client
        private ProspectItemData ProspectBlock(Vector3i position)
        {
            // Unpack block from position, block position won't be null
            var block = World.GetBlock(position);

            // Get resulting item from block
            var typeId = -1;

            if (block is IRepresentsItem item)
            {
                typeId = Item.Get(item)?.TypeID ?? -1;
            }
            if (typeId == -1)
            {
                typeId = BlockItem.CreatingItem(block.GetType())?.TypeID ?? -1;
            }
            if (World.GetBlock(position).Is <Impenetrable>() || position.y <= 0)
            {
                typeId = -2;
            }

            // Calculate prospect speed, based on skills, and hardness (gives 0.5s by default)
            var blockProspectSpeed = (block.Get <Minable>()?.Hardness ?? 1 * BlockHardnessModifier) / this.ProspectSpeed;

            var res = new ProspectItemData()
            {
                ItemTypeId      = typeId,
                Position        = position,
                ProspectSeconds = blockProspectSpeed,
            };

            return(res);
        }
예제 #21
0
        static void SetBlockMenuData()
        {
            if (_blocksTypes.Count == 0)
            {
                return;
            }

            string blockType = _blocksTypes[_blockMenuIndex];

            if (!_blocksDic.ContainsKey(blockType))
            {
                List <BlockItem> ls         = new List <BlockItem>();
                string[]         blockPaths = _blockPathsDic[blockType];
                for (int i = 0; i < blockPaths.Length; i++)
                {
                    string     path   = EditorUtiliTool.WinAbs2UnityPath(blockPaths[i]);
                    GameObject prefab = AssetDatabase.LoadAssetAtPath <GameObject>(path);
                    BlockItem  item   = new BlockItem();
                    item.prefab  = prefab;
                    item.texture = GeneratePreview(prefab);
                    ls.Add(item);
                }
                _blockPage.AddRange(ls);
                _blocksDic.Add(blockType, ls);
            }
            else
            {
                _blockPage.AddRange(_blocksDic[blockType]);
            }
        }
예제 #22
0
        public List <BlockItem> GetChain(int chain_id, bool store)
        {
            List <BlockItem> blocks = new List <BlockItem>();

            try
            {
                MySqlConnection conn = new MySqlConnection(connString);
                //Console.WriteLine("Connecting to MySQL...");
                conn.Open();

                // Perform database operations
                String query = "SELECT u.first_name as fname, u.last_name as lname, b.*, bcu.chain_id " +
                               "FROM `blocks` AS b " +
                               "INNER JOIN users AS u ON b.created_by=u.id " +
                               "INNER JOIN block_chain_user AS bcu ON bcu.block_id=b.id " +
                               "WHERE chain_id=" + chain_id.ToString() + ";";
                MySqlCommand    command = new MySqlCommand(query, conn);
                MySqlDataReader reader  = command.ExecuteReader();

                while (reader.Read())
                {
                    BlockItem block = new BlockItem();
                    block.id            = (int)reader[2];
                    block.previous_hash = (String)reader[3];
                    DateTime tempTimestamp = (DateTime)reader[4];
                    block.timestamp  = tempTimestamp.ToString();
                    block.created_by = (int)reader[5];
                    block.user_name  = (String)reader[0] + " " + (String)reader[1];
                    block.data       = (int)reader[6];
                    block.hash       = (String)reader[7];
                    block.nonce      = (int)reader[8];
                    if (reader[9] != System.DBNull.Value)
                    {
                        ulong tempValid = (ulong)reader[9];
                        block.isValid = Convert.ToInt32(tempValid);
                    }
                    blocks.Add(block);
                }
                reader.Close();
                conn.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            List <BlockItem> trim = new List <BlockItem>();

            if (blocks.Count < 5)
            {
                trim = blocks;
            }
            else
            {
                trim = blocks.GetRange(blocks.Count - 5, 5);
            }

            return(store ? trim : blocks);
        }
        public bool Verify(BlockItem record)
        {
            var data      = record.GetData();
            var publicKey = record.PublicKey;
            var signature = record.Signature;

            return(Verify(data, publicKey, signature));
        }
예제 #24
0
 public void Initialize(Type blockitem, int grid = 1) //"grid" isnt used yet, it is planned to make it possible to require more than a 3x3 grind (or also only a single block)
 {
     status           = Parent.GetComponent <StatusComponent>().CreateStatusElement();
     positionstocheck = World.BlockBelow(Parent.Position3i).XZFullNeighborsAndSelf;
     neededBlockItem  = Item.Get(blockitem) as BlockItem;
     ismet            = CheckGround();
     status.SetStatusMessage(Enabled, "Ground Requirements met", "Ground Requirements not met!");
 }
예제 #25
0
        /// <summary>
        /// Reads a do statement from the input.
        /// </summary>
        /// <param name="input">Where to read input from.</param>
        /// <returns>The object that was read.</returns>
        protected virtual IParseStatement _readDo(Lexer input)
        {
            input.Expect(TokenType.Do);
            BlockItem ret = _readBlock(input);

            input.Expect(TokenType.End);
            return(ret);
        }
예제 #26
0
 private string GetOutFileName(string fname, BlockItem item, string extName)
 {
     if (fname.Contains("{0}"))
     {
         return(string.Format(fname, item.ToString() + extName));
     }
     return(Path.Combine(Path.GetDirectoryName(fname), Path.GetFileNameWithoutExtension(fname) + item.ToString() + extName));
 }
예제 #27
0
 public void Create(string fileName, double sourceWidth, double sourceHeight, BlockItem blockItem)
 {
     using (var document = new PdfDocument())
     {
         CreatePage(document, sourceWidth, sourceHeight, blockItem);
         document.Save(fileName);
     }
 }
예제 #28
0
 public void Initialize(Type blockitem, int grid = 1)
 {
     this.status      = this.Parent.GetComponent <StatusComponent>().CreateStatusElement();
     positionstocheck = World.BlockBelow(this.Parent.Position3i).XZFullNeighborsAndSelf;
     neededBlockItem  = Item.Get(blockitem) as BlockItem;
     this.ismet       = CheckGround();
     status.SetStatusMessage(this.Enabled, "Ground Requirements met", "Ground Requirements not met!");
 }
예제 #29
0
 private void DrawBlock(XGraphics gfx, BlockItem block)
 {
     DrawLines(gfx, block.Lines);
     DrawRectangles(gfx, block.Rectangles);
     DrawEllipses(gfx, block.Ellipses);
     DrawTexts(gfx, block.Texts);
     DrawBlocks(gfx, block.Blocks);
 }
예제 #30
0
 public TimerTile(BlockItem item, int X = 0, int Y = 0, bool flip = false)
     : base(item, X, Y, flip)
 {
     Time     = 1;
     Length   = 1;
     Waiting  = true;
     WaitTime = 0;
 }
예제 #31
0
 public void AddItem(BlockButton bb)
 {
     BlockItem bi = blockItems[bb.id];
     BlockItem newBi = Instantiate(bi);
     newBi.id = bb.id;
     newBi.transform.SetParent(container.transform);
     draggingBlockItem = newBi;
     draggingBlockItem.transform.localScale = Vector3.one;
 }
예제 #32
0
 public BlockItem[] GetItems()
 {
     ElementList nl = SelectElements(typeof (BlockItem));
     int i = 0;
     var result = new BlockItem[nl.Count];
     foreach (BlockItem ri in nl)
     {
         result[i] = ri;
         i++;
     }
     return result;
 }
예제 #33
0
        ///<summary>Normalizes all URLs in a CSS parse tree to be relative to the specified directory.</summary>
        ///<param name="tree">The CSS parse tree to read.</param>
        ///<param name="targetFile">The new filename to make URLs relative to.</param>
        ///<param name="oldBasePath">The previous filename to resolve existing relative paths from.  If null, relative paths will be left unchanged.</param>
        ///<returns>The rewritten CSS source.</returns>
        ///<remarks>
        /// This is used to combine CSS files from different folders into a single
        /// bundle and to fix absolute URLs from the hacked browser LESS compiler.
        /// Fully absolute paths (starting with a drive letter) will be changed to
        /// relative URLs using targetFile (fix for LESS compiler).
        /// Host-relative paths (starting with a /) will be unchanged.
        /// Normal relative paths (starting with . or a name) will be re-resolved.
        ///</remarks>
        public static string NormalizeUrls(BlockItem tree, string targetFile, string oldBasePath)
        {
            var normalizer = new CssUrlNormalizer(targetFile, oldBasePath);
            tree.Accept(normalizer);

            var retVal = new StringBuilder(tree.Text);
            for (int i = normalizer.replacements.Count - 1; i >= 0; i--)
            {
                var range = normalizer.replacements[i].Item1;
                var url = normalizer.replacements[i].Item2;

                retVal.Remove(range.Start, range.Length);
                retVal.Insert(range.Start, HttpUtility.UrlPathEncode(url));
            }
            return retVal.ToString();
        }
예제 #34
0
 public void AddBlockItem(BlockItem r)
 {
     ChildNodes.Add(r);
 }
예제 #35
0
 private static TreeNode AddNewBlockItem(TreeNode selectedNode, BlockItem blockItem)
 {
     if (selectedNode.Tag is CodeItem)
     {
         var parentNode = selectedNode.Parent;
         var newNode = parentNode.Nodes.Add(blockItem.ToString());
         newNode.Tag = blockItem;
         return newNode;
     }
     if (selectedNode.Tag is BlockItem)
     {
         var newNode = selectedNode.Nodes.Add(blockItem.ToString());
         newNode.Tag = blockItem;
         return newNode;
     }
     return null;
 }
예제 #36
0
 private static void BuildFromXmlBlock(TreeNode node, XmlBlock xmlBlock)
 {
     if (xmlBlock.CodeSnippets != null && xmlBlock.CodeSnippets.Length > 0)
         foreach (var xmlChildCode in xmlBlock.CodeSnippets)
         {
             var childCodeItem = new CodeItem(xmlChildCode);
             var childCodeNode = node.Nodes.Add(childCodeItem.ToString());
             childCodeNode.Tag = childCodeItem;
         }
     if (xmlBlock.Blocks != null && xmlBlock.Blocks.Length > 0)
         foreach (var xmlChildBlock in xmlBlock.Blocks)
         {
             var childBlockItem = new BlockItem(xmlChildBlock);
             var childBlockNode = node.Nodes.Add(childBlockItem.ToString());
             childBlockNode.Tag = childBlockItem;
             BuildFromXmlBlock(childBlockNode, xmlChildBlock);
         }
 }
예제 #37
0
 private void BuildFromXmlBlock(XmlBlock xmlBlock)
 {
     try
     {
         LockLayout = true;
         IsModified = false;
         treeView.Nodes.Clear();
         var blockItem = new BlockItem(xmlBlock);
         var rootNode = treeView.Nodes.Add(blockItem.ToString());
         rootNode.Tag = blockItem;
         BuildFromXmlBlock(rootNode, xmlBlock);
         treeView.SelectedNode = rootNode;
         LockLayout = false;
     }
     catch (Exception exception)
     {
         ErrorReport.Report(exception);
         NewDocument();
     }
 }
예제 #38
0
 private void NewDocument()
 {
     LockLayout = true;
     FileName = null;
     IsModified = false;
     treeView.Nodes.Clear();
     var blockItem = new BlockItem
         {
             Name = RootBlockName
         };
     var rootNode = treeView.Nodes.Add(blockItem.ToString());
     rootNode.Tag = blockItem;
     treeView.SelectedNode = rootNode;
     LockLayout = false;
 }
예제 #39
0
 // Use this for initialization
 void Start()
 {
     this.blockParent = this.GetComponentInParent<BlockItem> ();
 }
예제 #40
0
    void Update()
    {
        if (Input.anyKeyDown)
        {
            if (draggingBlockItem != null && draggingBlockItem.inputField != null)
            {
                if (Input.GetKeyDown(KeyCode.Backspace) && draggingBlockItem.inputField.text.Length>0)
                draggingBlockItem.inputField.text = draggingBlockItem.inputField.text.Remove(draggingBlockItem.inputField.text.Length - 1);
                else draggingBlockItem.inputField.text += Input.inputString;
            }
            RaycastHit2D hit = Physics2D.Raycast(Input.mousePosition, Vector2.zero);
            if (hit.collider != null)
            {
                BlockButton bb = hit.collider.gameObject.GetComponent<BlockButton>();
                if (bb != null)
                {
                    AddItem(bb);
                }
                else
                {
                    BlockItem bi = hit.collider.gameObject.GetComponent<BlockItem>();
                    if (bi != null)
                        draggingBlockItem = bi;
                }
            }
            else draggingBlockItem = null;
        }
        if (Input.anyKey)
        {
            if (draggingBlockItem != null)
            {
                draggingBlockItem.transform.position = Input.mousePosition;
            }
        }
        if (draggingBlockItem)
        {
            if (draggingBlockItem.transform.position.x > UnityEngine.Screen.width/2)
            {

                Destroy(draggingBlockItem.gameObject);
            }
        }
    }