Exemplo n.º 1
0
        //--------------------------------------------------------------------------------------------
        // ----------------Local ML, PL and Refining Calculation Functions----------------

        /// <summary>Used to calculate Production Level from avalable in-form info</summary>
        private void CalculatePL()
        {
            lvPLResults.Items.Clear();  //Clear PL Results list
            // -Define local variables
            double PL = 0;
            double CurrentTime = 0, LastTime = 0;
            double RawNumber     = 0;
            double BaseTime      = m_TotalSeconds;
            double IndustrySkill = cbInustrySkill.SelectedIndex;

            // ---Calculate first PL  (PL = 0)
            RawNumber  = (1 - (PL / (PL + 1) * 0.2));                                  //PL Effect
            RawNumber *= (1 - (IndustrySkill * 0.04));                                 //Industry Skill Effect
            RawNumber *= BaseTime;                                                     //Base Time in Seconds

            lvPLResults.BeginUpdate();                                                 // State that we're begining an update

            LastTime = Math.Truncate(RawNumber);                                       //Store PL 0 as LastTime
            ListViewItem lvItem = new ListViewItem(PL.ToString("#,##0"));              // Create a new ListViewItem, add PL

            lvItem.SubItems.Add(TimeFormats.SecondsToTime((uint)LastTime).ToString()); // Add sub item Time
            lvPLResults.Items.Add(lvItem);                                             // Add ListVeiwItem to PL Results

            // ---PL Caluclation Loop for MaxPLLoops
            for (PL = 1; PL < MaxPLLoops; PL++)
            {
                RawNumber  = (1 - (PL / (PL + 1) * 0.2));  //PL Effect
                RawNumber *= (1 - (IndustrySkill * 0.04)); //Industry Skill Effect
                RawNumber *= BaseTime;                     //Base Time in Seconds

                CurrentTime = Math.Truncate(RawNumber);    //Store current PL as CurrentTime
                if (CurrentTime < LastTime)
                {
                    // ---If CurrentTime is less than LastTime, Store results in PL Results and update LastTime
                    lvItem = new ListViewItem(PL.ToString("#,##0"));                              // Create a new ListViewItem, add PL
                    lvItem.SubItems.Add(TimeFormats.SecondsToTime((uint)CurrentTime).ToString()); // Add sub item Time
                    lvPLResults.Items.Add(lvItem);                                                // Add ListVeiwItem to PL Results

                    LastTime = CurrentTime;
                }
            } // ---End PL Calculation Loop

            chPLValue.Width = 55;  // Resize PL column header Width

            // ---Check what column width to set (Content or Minimum Header Width: 35)
            chPLTime.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            int ColumnContentWidth = chPLTime.Width;
            int HeaderSize         = 40;

            if (ColumnContentWidth > HeaderSize)
            {
                chPLTime.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            }
            else
            {
                chPLTime.Width = HeaderSize;
            }

            lvPLResults.EndUpdate();  // Update over, unlock the control
        }