Пример #1
0
        /// <summary>Determine the density limits</summary>
        private void CalculateDensity(GameConstants consts, Random rnd)
        {
            // Factors influency density:
            // -Bigger molar mass = higher density
            // -Stronger bonds = higher density
            // -More Ionic = higher density
            // -Smaller atomic radii = higher density
            var norm_ionicity = Math_.Frac(consts.MinElectronegativity, Ionicity, consts.MaxElectronegativity);

            var mass_adj     = Math_.Frac(1, MolarMass / (Count1 + Count2), consts.MaxMolarMass); // normalised average molar mass
            var ionicity_adj = 1.0 + 0.5 * Math.Pow(norm_ionicity, 8);                            // no significant ionicity until about 0.7
            //var bond_adj = dominant_bond.Strength;
            //var radii = Elem1.ValenceOrbitalRadius + Elem2.ValenceOrbitalRadius;

            var scaler = mass_adj * ionicity_adj;

            Debug.Assert(scaler >= 0 && scaler < 10);
            m_solid_density = Math_.Lerp(consts.MinSolidMaterialDensity, consts.MaxSolidMaterialDensity, scaler);


            // The liquid_density0 value can only be lower than the solid density when
            // the Compound is strongly ionic such that it forms a crystals
            var ionicity_solid_density_scaler = 0.1 * Math_.Max(0, norm_ionicity - 0.75);

            m_liquid_density0 = m_solid_density * rnd.Double(1.0, 1.0 - ionicity_solid_density_scaler);
            m_liquid_density1 = m_liquid_density0 * rnd.DoubleC(0.8, 0.0);            // at boiling point, density is roughly 20% less
        }
Пример #2
0
 public Candle(long timestamp, double open, double high, double low, double close, double median, double volume)
 {
     Timestamp = timestamp;
     Open      = open;
     High      = Math_.Max(high, open, close);
     Low       = Math_.Min(low, open, close);
     Close     = close;
     Median    = median;
     Volume    = volume;
 }
Пример #3
0
        protected override void OnShown(EventArgs e)
        {
            // Get the input control
            var ctrl =
                Mode == EMode.ValueInput ? m_tb_value :
                Mode == EMode.OptionSelect ? m_cb_value :
                (Control)null;

            if (ctrl != null)
            {
                // Set the initial size
                using (this.SuspendLayout(true))
                    using (var gfx = CreateGraphics())
                    {
                        // Get the scaling due to DPI
                        var cr      = ClientRectangle;
                        var scale_x = gfx.DpiX / 96f;
                        var scale_y = gfx.DpiY / 96f;
                        var x_10px  = (int)(10 * scale_x);
                        var y_10px  = (int)(10 * scale_y);

                        // Minimum client size
                        var sz_client = RectangleToClient(RectangleToScreen(new Rectangle(Point.Empty, MinimumSize)));

                        // Minimum size needed for buttons
                        var btns   = Controls.OfType <Button>().ToArray();
                        var w_btns = btns.Sum(x => x.Width) + (btns.Length - 1) * x_10px;

                        // Minimum size needed for the text label
                        var sz_info = m_lbl_info.PreferredSize;

                        var w = Math_.Max(sz_client.Width, 2 * x_10px + w_btns, 2 * x_10px + sz_info.Width);
                        var h = Math_.Max(sz_client.Height, y_10px + sz_info.Height + y_10px + ctrl.Height + y_10px + btns[0].Height + y_10px);
                        ClientSize = new Size(w, h);
                    }

                ctrl.Focus();
            }
            base.OnShown(e);
        }