コード例 #1
0
 public virtual void AddRange(IEnumerable <Block3D> collection)
 {
     if (collection != null)
     {
         Blocks.AddRange(collection);
     }
 }
コード例 #2
0
ファイル: ItemsElement.cs プロジェクト: zwq00000/waf
        private void UpdateContent()
        {
            if (ItemsSource != null)
            {
                if (ItemTemplate == null)
                {
                    throw new InvalidOperationException("When ItemsSource is used then the ItemTemplate must not be null.");
                }

                List <Block> blocks = new List <Block>();
                foreach (object item in ItemsSource)
                {
                    Block          block          = null;
                    ContentElement contentElement = ItemTemplate.LoadContent() as ContentElement;
                    if (contentElement != null)
                    {
                        block = contentElement.Content as Block;
                    }

                    if (block == null)
                    {
                        throw new InvalidOperationException("The ItemTemplate must define: DataTemplate > ContentElement > Block element.");
                    }
                    block.DataContext = item;
                    blocks.Add(block);
                }

                Blocks.AddRange(blocks);
            }
        }
コード例 #3
0
        /// <summary>
        /// Method <c>GameTimer_Tick()</c>
        /// Represents the that should happen every timer tick.
        /// Ex: the _shape should move down if it can, if not a new shape
        /// is generated at the top.
        /// Checks for game over condition and calls the method that clears full
        /// rows.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void GameTimer_Tick(object sender, EventArgs e)
        {
            _shape.MoveDown();

            if (!_shape.ValidMoveDown() && !_gameOver)
            {
                _shape.MarkPosition();
                _shape = _nextShape;
                _shape.CenterShape();
                NextBlock.Clear();
                _nextShape = _shapeFactory.BuildRandomShape();

                NextBlock.AddRange(_nextShape.ShapeBlocks);

                Blocks.AddRange(_shape.ShapeBlocks);
                if (GameOverCondition())
                {
                    _gameOver = true;
                    _timer.Stop();
                    GameOver gameOverWindow = new GameOver();
                    gameOverWindow.ShowDialog();
                }
                CheckForPoints();
            }
        }
コード例 #4
0
        /// <summary>
        /// Method <c> RestartGame</c> Restarts the game, setting all state to default,
        /// and clears all items that would be bound to the gui.
        /// </summary>

        public void RestartGame()
        {
            // reset game variables
            _timeInterval = 500;
            _gameOver     = false;
            _paused       = false;
            PauseMessage  = "";
            Score         = 0;
            Level         = 1;

            // clear collections
            Blocks.Clear();
            NextBlock.Clear();
            HeldBlock.Clear();
            GameBoard.ClearGrid();

            _timer.Interval = new TimeSpan(0, 0, 0, 0, _timeInterval);

            // create shapes
            _shape     = _shapeFactory.BuildRandomShape();
            _nextShape = _shapeFactory.BuildRandomShape();
            NextBlock.AddRange(_nextShape.ShapeBlocks);
            Blocks.AddRange(_shape.ShapeBlocks);

            _timer.Start();
        }
コード例 #5
0
ファイル: Chunk.cs プロジェクト: nkast/Bawx
        public void BuildChunk(Block[] data, int?activeCount = null, bool rebuild = false)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }
            if (data.Length > TotalSize)
            {
                throw new ArgumentException("Too much data for this chunk.", nameof(data));
            }
            if (Renderer.Initialized && !rebuild)
            {
                throw new InvalidOperationException("Chunk is already built, to override set the rebuild flag.");
            }
            if (activeCount < 0 || activeCount > data.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(activeCount));
            }

            Blocks.AddRange(data);
            BlockCount = data.Length;

            Renderer.Initialize(this, data, activeCount ?? data.Length);
            // TODO store the blocks in a more manageable format (octree probably) for physics!
        }
コード例 #6
0
 public BasicBlocksList(IEnumerable <BasicBlock> blocks)
 {
     Blocks.AddRange(blocks);
     foreach (var block in Blocks)
     {
         BlockByID[block.BlockId] = block;
     }
 }
コード例 #7
0
ファイル: Board.cs プロジェクト: bmjoy/Tomino
        public void AddPiece()
        {
            piece = pieceProvider.GetPiece();

            var offsetRow = top - piece.Top;
            var offsetCol = (width - piece.Width) / 2;

            foreach (var block in piece.blocks)
            {
                block.MoveBy(offsetRow, offsetCol);
            }

            Blocks.AddRange(piece.blocks);
        }
コード例 #8
0
        public void AddPiece()
        {
            Piece     = NextPiece;
            NextPiece = PiecesCreator.GetPiece();

            var offsetRow = _topEdge - Piece.Top;
            var offsetCol = (Width - Piece.Width) / 2;

            foreach (var block in Piece.Blocks)
            {
                block.MoveByOffset(offsetRow, offsetCol);
            }

            Blocks.AddRange(Piece.Blocks);
        }
コード例 #9
0
ファイル: LogFilter.cs プロジェクト: taquinil-selei/omnius
        public void Fill(DBEntities context)
        {
            Levels.Add(new SelectListItem {
                Value = "-1", Text = "All"
            });
            foreach (OmniusLogLevel level in Enum.GetValues(typeof(OmniusLogLevel)))
            {
                Levels.Add(new SelectListItem {
                    Value = ((int)level).ToString(), Text = level.ToString(), Selected = ((int)level == LevelId)
                });
            }

            Sources.Add(new SelectListItem {
                Value = "-1", Text = "All"
            });
            foreach (OmniusLogSource source in Enum.GetValues(typeof(OmniusLogSource)))
            {
                Sources.Add(new SelectListItem {
                    Value = ((int)source).ToString(), Text = source.ToString(), Selected = ((int)source == SourceId)
                });
            }

            Users.Add(new User {
                UserName = "******", DisplayName = "All"
            });
            Users.AddRange(context.Users.OrderBy(u => u.UserName).ToList());

            Servers.Add("All");
            Servers.AddRange(context.LogItems.Select(i => i.Server).OrderBy(s => s).Distinct().ToList());

            Applications.Add(new Application {
                Name = "All", DisplayName = "All"
            });
            Applications.AddRange(context.Applications.OrderBy(a => a.Name).ToList());

            Blocks.Add(new Block {
                Name = "All", DisplayName = "All"
            });
            if (ApplicationName != null)
            {
                Blocks.AddRange(context.Blocks.Where(b => b.WorkFlow.Application.Name == ApplicationName).OrderBy(b => b.DisplayName).ToList());
            }

            Actions.Add("All");
            Actions.AddRange(Modules.Tapestry.Action.All.Select(a => a.Value.Name).OrderBy(a => a));
        }
コード例 #10
0
        public void LoadFromRoot()
        {
            Blocks.Clear();
            if (RootTreeNode != null)
            {
                /*
                 * LoadFromRootAction action = new LoadFromRootAction();
                 * bool wasCancelled;
                 * ProgressWindow.ExecuteProgressAction(action, out wasCancelled);
                 * if (wasCancelled)
                 * {
                 *  Shutdown(-1);
                 *  return;
                 * }
                 */

                HtmlBlockExtractionVisitor blockVisitor = new HtmlBlockExtractionVisitor(TextChannel);
                RootTreeNode.AcceptDepthFirst(blockVisitor);
                Blocks.AddRange(blockVisitor.ExtractedBlocks);
            }
        }
コード例 #11
0
        /// <summary>
        /// Method <c>HoldBlock()</c>
        /// sets the heldBlock to the current block, and then sets the current block to
        /// the next block.
        /// </summary>
        public void HoldBlock()
        {
            if (HeldBlock.Count == 0)
            {
                _heldShape = _shapeFactory.BuildShape(_shape);

                for (int i = 0; i < 4; i++)
                {
                    Blocks.Remove(x => x.GridX == _shape.ShapeBlocks[i].GridX &&
                                  x.GridY == _shape.ShapeBlocks[i].GridY);
                }

                _shape = _nextShape;
                _shape.CenterShape();

                Blocks.AddRange(_shape.ShapeBlocks);
                _nextShape = _shapeFactory.BuildRandomShape();
                NextBlock.Clear();
                NextBlock.AddRange(_nextShape.ShapeBlocks);
                HeldBlock.AddRange(_heldShape.ShapeBlocks);
            }
            else
            {
                HeldBlock.Clear();
                var tempShape = _heldShape;
                _heldShape = _shapeFactory.BuildShape(_shape);

                for (int i = 0; i < 4; i++)
                {
                    Blocks.Remove(x => x.GridX == _shape.ShapeBlocks[i].GridX &&
                                  x.GridY == _shape.ShapeBlocks[i].GridY);
                }

                _shape = tempShape;
                _shape.CenterShape();
                Blocks.AddRange(_shape.ShapeBlocks);
                HeldBlock.AddRange(_heldShape.ShapeBlocks);
            }
        }
コード例 #12
0
        public void BuildChunk(VertexWithIndex[] data, int?activeCount = null, bool rebuild = false)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }
            if (data.Length > TotalSize)
            {
                throw new ArgumentException("Too much data for this chunk.", nameof(data));
            }
            if (Renderer.IsInitialized() && !rebuild)
            {
                throw new InvalidOperationException("Chunk is already built, to override set the rebuild flag.");
            }
            if (activeCount < 0 || activeCount > data.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(activeCount));
            }

            Blocks.AddRange(data);
            BlockCount = data.Length;

            Renderer.Init(this, data, activeCount ?? data.Length);
        }
コード例 #13
0
 public void Add(IEnumerable <IMyTerminalBlock> blocks)
 {
     Blocks.AddRange(blocks);
 }
コード例 #14
0
 public Returns(List <Block> children)
 {
     Resources.MergedDictionaries.Add(DocumentationResources.BaseResources);
     Blocks.AddRange(children);
 }
コード例 #15
0
        public CollapsibleSection()
        {
            var fontSizeBinding = new Binding(FontSizeProperty.Name)
            {
                Source = this, Converter = new FontSizeConverter(), ConverterParameter = 1.1
            };

            var toggleLinkText = new Run {
                FontWeight = FontWeights.Bold
            };

            toggleLinkText.SetBinding(Run.TextProperty, new Binding(nameof(ToggleLinkText))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            toggleLinkText.SetBinding(FontSizeProperty, fontSizeBinding);

            var toggleLink = new Hyperlink(toggleLinkText)
            {
                TextDecorations = null
            };

            toggleLink.SetBinding(ToolTipProperty, new Binding(nameof(ToggleLinkToolTip))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            toggleLink.SetResourceReference(ForegroundProperty, QuickRefColors.DocumentForegroundBrushKey);
            toggleLink.Click += ToggleLink_Click;

            var space1 = new Run(" ")
            {
                FontWeight = FontWeights.Bold
            };

            space1.SetBinding(FontSizeProperty, fontSizeBinding);

            var headerText = new Run()
            {
                FontWeight = FontWeights.Bold
            };

            headerText.SetBinding(Run.TextProperty, new Binding(nameof(HeaderText))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            headerText.SetBinding(FontSizeProperty, fontSizeBinding);
            headerText.SetResourceReference(ForegroundProperty, QuickRefColors.DocumentForegroundBrushKey);

            var space2 = new Run("    ")
            {
                FontWeight = FontWeights.Bold
            };

            space1.SetBinding(FontSizeProperty, fontSizeBinding);

            var navigateLinkText = new Run("more \u2192");

            // navigateLinkText.SetBinding(FontSizeProperty, new Binding(FontSizeProperty.Name) { Source = this, Converter = new FontSizeConverter(), ConverterParameter = 0.85 });

            m_navigateLink = new Hyperlink(navigateLinkText)
            {
                TextDecorations = null
            };
            m_navigateLink.SetBinding(Hyperlink.NavigateUriProperty, new Binding(nameof(HeaderUri))
            {
                Source = this
            });
            m_navigateLink.SetResourceReference(ForegroundProperty, QuickRefColors.HyperlinkForegroundBrushKey);
            m_navigateLink.RequestNavigate += NavigateLink_RequestNavigate;
            m_navigateLink.MouseEnter      += NavigateLink_MouseEnter;
            m_navigateLink.MouseLeave      += NavigateLink_MouseLeave;

            m_header = new Paragraph()
            {
                TextIndent = 0
            };
            m_header.Inlines.AddRange(new Inline[] { toggleLink, space1, headerText, space2, m_navigateLink });
            // header.SetBinding(Run.FontSizeProperty, new Binding(FontSizeProperty.Name) { Source = this, Converter = new FontSizeConverter(), ConverterParameter = 1.1 });

            m_innerSection = new Section();

            Blocks.AddRange(new Block[] { m_header, m_innerSection });

            CoerceToggleLink();
        }