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


C# StringBuilder.AppendDecimal方法代码示例

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


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

示例1: UpdateStatText

			private void UpdateStatText(float newValue, float oldValue, object statChangeData)
			{
				m_progressBar.Value = m_stat.CurrentRatio;
				if (m_statValueLabel != null)
				{
					StringBuilder statText = new StringBuilder();
					statText.AppendDecimal((int)m_stat.Value, 0);
					statText.Append("/");
					statText.AppendDecimal(m_stat.MaxValue, 0);
					m_statValueLabel.Text = statText.ToString();
				}
			}
开发者ID:martejj,项目名称:SpaceEngineers,代码行数:12,代码来源:MyGuiControlStats.cs

示例2: FillListBoxFromID

        private void FillListBoxFromID(MyGuiControlListbox listbox, int id, bool canBeMoved = true)
        {
            MyInventoryItem inventoryItem = m_itemsRepository.GetItem(id);
            StringBuilder description = null;
            if (inventoryItem.Icon == null)
            {
                description = inventoryItem.MultiLineDescription;
            }

            MyGuiControlListboxItem listboxItem = new MyGuiControlListboxItem(id, description, inventoryItem.Icon, GetListboxItemTooltip(listbox, id), MyGuiConstants.LABEL_TEXT_SCALE);
            listboxItem.IconTexts = new MyIconTexts();

            // add amount icon's text
            if (inventoryItem.Amount != 0f || inventoryItem.Amount != inventoryItem.MaxAmount)            
            {
                StringBuilder amount = new StringBuilder();
                if (inventoryItem.Amount > (int)inventoryItem.Amount)
                {
                    float fixedAmount = Math.Max(0.01f, inventoryItem.Amount);  // prevent items with zero amount, for visualization 0.01 is the minimum value
                    amount.AppendDecimal(fixedAmount, 2);
                }
                else 
                {
                    amount.AppendInt32((int)inventoryItem.Amount);                    
                }
                //amount.Append(inventoryItem.Amount.ToString());
                MyGuiDrawAlignEnum align;
                Vector2 offset;

                //All amounts alignet to right bottom position from now
                /*
                if (inventoryItem.AmountTextAlign == MyInventoryAmountTextAlign.MiddleRight)
                {
                    align = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
                    offset = new Vector2(-0.004f, 0.0038f);
                }
                 
                else if (inventoryItem.AmountTextAlign == MyInventoryAmountTextAlign.BottomRight)
                {
                 * */
                align = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
                offset = new Vector2(-0.013f, -0.01f);

                /*}
                    else
                    {
                        throw new MyMwcExceptionApplicationShouldNotGetHere();
                    }
                 * */

                listboxItem.IconTexts[align] = new MyColoredText(amount, Color.White, Color.White, MyGuiManager.GetFontMinerWarsBlue(), 0.6f, offset);
            }
            bool enabled = inventoryItem.CanBeMoved && canBeMoved;
            if (m_tradeForMoney)
            {
                enabled &= inventoryItem.CanBeTraded;                
            }
            listboxItem.Enabled = enabled;
            //if (!inventoryItem.CanBeMoved) 
            //{
            //    listboxItem.Enabled = false;
            //}
            listbox.AddItem(listboxItem);
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:64,代码来源:MyGuiScreenInventory.cs

示例3: RecreateControls

			public void RecreateControls()
			{
				Elements.Clear();

				var guiTextScale = (float)Math.Pow(1.2f, m_stat.StatDefinition.GuiDef.HeightMultiplier - 1.0f);
				var guiArrowScale = (float)Math.Pow(1.3f, m_stat.StatDefinition.GuiDef.HeightMultiplier - 1.0f) / m_stat.StatDefinition.GuiDef.HeightMultiplier;
				var textScale = MyGuiConstants.HUD_TEXT_SCALE*0.6f*guiTextScale;
				var barLength = 0.0875f;
				var arrowIconSize = new Vector2(Size.Y * 1.5f, Size.Y) * 0.5f * guiArrowScale;
				var leftTextWidth = 0.16f;
				var textHeightOffset = -0.1f;

				var leftTextOffset = -1.0f / 2.0f + leftTextWidth;
				var barOffset = leftTextOffset + 0.025f;
				var arrowIconOffset = barOffset + barLength/Size.X + 0.05f;
				var rightTextOffset = arrowIconOffset + arrowIconSize.X + 0.035f;

				m_statNameLabel = new MyGuiControlLabel(position: Size * new Vector2(leftTextOffset, textHeightOffset),
														text: m_stat.StatId.ToString(),
														textScale: textScale,
														size: new Vector2(leftTextWidth*Size.X, 1.0f),
														originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER);
				Elements.Add(m_statNameLabel);

				var vecColor = m_stat.StatDefinition.GuiDef.Color;
				var barColor = new Color(vecColor.X, vecColor.Y, vecColor.Z);

				m_progressBar = new MyGuiControlProgressBar(position: Size * new Vector2(barOffset, 0.0f),
															originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
															size: new Vector2(barLength, Size.Y),
															backgroundTexture: new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_STAT_BAR_BG.Texture),
															progressBarColor: barColor);
				if (m_stat != null)
					m_progressBar.Value = m_stat.CurrentRatio;
				Elements.Add(m_progressBar);

				m_effectArrow = new MyGuiControlPanel(	position: Size * new Vector2(arrowIconOffset, 0.0f),
														originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
														size: arrowIconSize,
														texture: MyGuiConstants.TEXTURE_HUD_STAT_EFFECT_ARROW_UP.Texture);
				Elements.Add(m_effectArrow);

				StringBuilder statText = new StringBuilder();
				statText.AppendDecimal((int)m_stat.Value, 0);
				statText.Append("/");
				statText.AppendDecimal(m_stat.MaxValue, 0);
				m_statValueLabel = new MyGuiControlLabel(position: Size * new Vector2(rightTextOffset, textHeightOffset),
														text: statText.ToString(),
														textScale: textScale,
														originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
				Elements.Add(m_statValueLabel);
			}
开发者ID:martejj,项目名称:SpaceEngineers,代码行数:52,代码来源:MyGuiControlStats.cs

示例4: UpdateStatControl

			private void UpdateStatControl(float newValue, float oldValue, object statChangeData)
			{
				m_progressBar.Value = m_stat.CurrentRatio;
				if (m_statValueLabel != null)	// Update the text
				{
					StringBuilder statText = new StringBuilder();
					statText.AppendDecimal((int)m_stat.Value, 0);
					statText.Append("/");
					statText.AppendDecimal(m_stat.MaxValue, 0);
					m_statValueLabel.Text = statText.ToString();
				}
				m_recalculatePotential = true;
			}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:13,代码来源:MyGuiControlStats.cs

示例5: GetActualJoystickState

        public void GetActualJoystickState(StringBuilder text)
        {
            if (m_joystick.IsConnected == false)
            {
                text.Append("No joystick detected.");
                return;
            }


            XB1Interface.XB1Interface.GamepadState gamepad = m_actualJoystickState;

            

            text.Append("Supported axes: ");
            if (IsJoystickAxisSupported(MyJoystickAxesEnum.Xpos)) text.Append("X ");
            if (IsJoystickAxisSupported(MyJoystickAxesEnum.Ypos)) text.Append("Y ");
            if (IsJoystickAxisSupported(MyJoystickAxesEnum.Zpos)) text.Append("Z ");
            if (IsJoystickAxisSupported(MyJoystickAxesEnum.RotationXpos)) text.Append("Rx ");
            if (IsJoystickAxisSupported(MyJoystickAxesEnum.RotationYpos)) text.Append("Ry ");
            if (IsJoystickAxisSupported(MyJoystickAxesEnum.RotationZpos)) text.Append("Rz ");
            if (IsJoystickAxisSupported(MyJoystickAxesEnum.Slider1pos)) text.Append("S1 ");
            if (IsJoystickAxisSupported(MyJoystickAxesEnum.Slider2pos)) text.Append("S2 ");
            text.AppendLine();

            text.Append("rotX: "); text.AppendDecimal(gamepad.rx, 4); text.AppendLine();
            text.Append("rotY: "); text.AppendDecimal(gamepad.ry, 4); text.AppendLine();
            text.Append("X: "); text.AppendDecimal(gamepad.lx, 4); text.AppendLine();
            text.Append("Y: "); text.AppendDecimal(gamepad.ly, 4); text.AppendLine();
            text.AppendLine();
            text.Append("Buttons: ");
            foreach (JoystickHelper.XInputGamepadButtonFlags i in Enum.GetValues(typeof(JoystickHelper.XInputGamepadButtonFlags)))
            {
                text.Append( (( (uint)(i) & gamepad.Buttons) != 0) ? "#" : "_");
                text.Append(" ");
            } text.AppendLine();
            
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:37,代码来源:MyXInputInput.cs

示例6: AppendCustomTimers

            public void AppendCustomTimers(StringBuilder builder, bool reset = true)
            {
                foreach (var custom in m_customTimers)
                {
                    builder.Append(custom.Key);
                    builder.Append(": ");
                    builder.AppendDecimal((float)TicksToMs(custom.Value.Runtime), 3);
                    builder.Append(" ms");
                    builder.AppendLine();
                }

                if (reset)
                {
                    m_keys.Clear();
                    foreach (var custom in m_customTimers)
                    {
                        m_keys.Add(custom.Key);
                    }
                    foreach (var key in m_keys)
                    {
                        m_customTimers[key] = Timer.Empty;
                    }
                }
            }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:24,代码来源:MyPerformanceCounter.cs


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