示例#1
0
        /// <summary>Preenche os controlos relativos a um recurso</summary>
        private void fillResource( string resource, Control control, Chronos.Core.Planet planet)
        {
            Label quantity = (Label) control.FindControl(resource + "Quantity");
            if( quantity != null ) {
                quantity.EnableViewState = false;
                int val = planet.getResourceCount(resource);
                quantity.Text = val.ToString();
                if( val < 0 ) {
                    quantity.CssClass = "error";
                }
            }

            Label ratio = (Label) control.FindControl(resource + "Ratio");
            if( ratio != null ) {
                ratio.EnableViewState = false;
                int val = planet.getRatio(resource);
                if( val > 0 ) {
                    ratio.Text = val.ToString() + "%";
                } else {
                    ratio.Text = "-";
                }
            }

            Label perTurn = (Label) control.FindControl(resource + "PerTurn");
            if( perTurn != null ) {
                perTurn.EnableViewState = false;
                int val = planet.getPerTurn("Intrinsic",resource);
                string str = val.ToString();

                if( val > 0 ) {
                    str = "+" + str;
                    perTurn.Text = str;
                } else if( val == 0 ) {
                    perTurn.Text = "-";
                } else {
                    perTurn.CssClass = "error";
                    perTurn.Text = str;
                }
            }
        }