当前位置: 首页>>代码示例>>C#>>正文


C# ICodeBlock.Else方法代码示例

本文整理汇总了C#中ICodeBlock.Else方法的典型用法代码示例。如果您正苦于以下问题:C# ICodeBlock.Else方法的具体用法?C# ICodeBlock.Else怎么用?C# ICodeBlock.Else使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICodeBlock的用法示例。


在下文中一共展示了ICodeBlock.Else方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateAdditionalMethods

        public override ICodeBlock GenerateAdditionalMethods(ICodeBlock codeBlock, IElement element)
        {
            if (element is EntitySave)
            {
                EntitySave entitySave = (EntitySave)element;
                if (entitySave.IsScrollableEntityList && !string.IsNullOrEmpty(entitySave.ItemType))
                {
                    string itemTypeWithoutPath = FileManager.RemovePath(entitySave.ItemType);

                    string visibleSettingLine = "";

                    if (entitySave.ImplementsIVisible)
                    {
                        visibleSettingLine = "newItem.Visible = this.Visible;";
                    }
                    #region AddItemToTop

                    codeBlock
                        .Function("void", "AddItemToTop", "")
                            .Line(string.Format("{0} newItem = Factories.{0}Factory.CreateNew(LayerProvidedByContainer);", itemTypeWithoutPath))
                            .Line(visibleSettingLine)
                            .Line("mLastCreatedScrollableItem = newItem;")
                            .Line("newItem.AttachTo(mScrollableHandle, false);")
                            .If("mScrollableItems.Count > 0")
                                .Line("newItem.RelativeY = mScrollableItems[0].RelativeY + mScrollableSpacing;")
                            .End()
                            .Line("newItem.ForceUpdateDependencies();")

                            .Line("mScrollableFirstIndex--;")
                            .Line("mScrollableItems.Insert(0, newItem);")

                            .If("ScrollItemModified != null")
                                .Line("ScrollItemModified(newItem);")
                            .End()
                            .Line("mLastCreatedScrollableItem = null;")
                        .End()
                    #endregion

                    #region AddItemToBottom

                    .Function("void", "AddItemToBottom", "")
                            .Line(string.Format("{0} newItem = Factories.{0}Factory.CreateNew(LayerProvidedByContainer);", itemTypeWithoutPath))
                            .Line("mLastCreatedScrollableItem = newItem;")
                            .Line("newItem.AttachTo(mScrollableHandle, false);")

                            .If("mScrollableItems.Count > 0")
                                .Line("newItem.RelativeY = mScrollableItems.Last.RelativeY - mScrollableSpacing;")
                            .End()
                            .Else()
                                .Line("newItem.RelativeY = 0;")
                            .End()
                            .Line("newItem.ForceUpdateDependencies();")

                            .Line("mScrollableItems.Add(newItem);")

                            .If("ScrollItemModified != null")
                                .Line("ScrollItemModified(newItem);")
                            .End()
                            .Line("mLastCreatedScrollableItem = null;")
                        .End();
                    #endregion

                    codeBlock = codeBlock.Function("void", "ScrollableListActivity", "");
                        
                    var curBlock = codeBlock
                        .If("ListShowing != null")
                            .Line("FlatRedBall.Gui.Cursor cursor = FlatRedBall.Gui.GuiManager.Cursor;");

                    if (entitySave.ImplementsIClickable || entitySave.ImplementsIWindow || entitySave.GetInheritsFromIWindowOrIClickable())
                    {
                        curBlock = curBlock.If("cursor.PrimaryDown && HasCursorOver(GuiManager.Cursor)");
                    }
                    else
                    {
                        curBlock = curBlock.If("cursor.PrimaryDown");
                    }

                    curBlock = curBlock
                        .Line("mScrollableHandle.RelativeY += FlatRedBall.Gui.GuiManager.Cursor.WorldYChangeAt(this.Z, LayerProvidedByContainer);")
                        .Line("FixScrollableHandleRelativeY();")
                        .Line("mScrollableHandle.ForceUpdateDependenciesDeep();")
                        .End();

                    curBlock
                        .Line("PerformScrollableItemAdditionLogic();")

                        .Line("// remove from top")
                        .While("mScrollableItems.Count > 2 && mScrollableItems[1].Y > mScrollableTopBoundary")
                            .Line("RemoveItemFromTop();")
                        .End()

                        .Line("// remove from bottom")
                        .While("mScrollableItems.Count > 2 && mScrollableItems[mScrollableItems.Count - 2].Y < mScrollableBottomBoundary")
                            .Line("RemoveItemFromBottom();")
                        .End()

                        .Line("bool shouldRefreshAll = false;")
                        .While("ListShowing.Count < mScrollableItems.Count")
                            .Line("RemoveItemFromBottom();")
                            .Line("shouldRefreshAll = true;")
//.........这里部分代码省略.........
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:101,代码来源:ScrollableListCodeGenerator.cs


注:本文中的ICodeBlock.Else方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。