Example #1
0
 private static void Postfix(ref List <ElementLoader.ElementEntry> __result)
 {
     PipLib.Logger.Info("Loading elements...");
     foreach (var mod in PipLib.Mods)
     {
         ElementManager.CollectElements(System.IO.Path.Combine(PLUtil.GetAssemblyDir(mod.GetType()), PLUtil.DIR_ELEMENTS), __result);
     }
     ElementManager.RegisterSubstances();
     Debug.Log("Ignore any messages below about \"missing substance for element\"!");
 }
Example #2
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     for (int i = 1; i < 6; ++i)
     {
         if (mRdos[i].Checked)
         {
             PLCriteria = PLUtil.GetPLCriteria(i);
             break;
         }
     }
 }
        private void RefreshData3(int year, int period)
        {
            int display_year = year;
            int display_month;

            PLUtil.Period2MonthYear(mModel.Accountant, period, ref display_year, out display_month);

            tgvPLStatement.Nodes.Clear();
            tgvPLStatement.Columns.Clear();

            tgvPLStatement.Columns.Add(new TreeGridColumn());
            tgvPLStatement.Columns.Add(new DataGridViewTextBoxColumn());
            tgvPLStatement.Columns.Add(new DataGridViewTextBoxColumn());
            tgvPLStatement.Columns.Add(new DataGridViewTextBoxColumn());

            tgvPLStatement.Columns[0].Width      = 300;
            tgvPLStatement.Columns[0].HeaderText =
                string.Format("{0} ({1}-{2})", Title, display_year, PLUtil.Month2String(display_month));

            tgvPLStatement.Columns[1].Width      = 80;
            tgvPLStatement.Columns[1].HeaderText = "This Year";

            tgvPLStatement.Columns[2].Width      = 80;
            tgvPLStatement.Columns[2].HeaderText = "Last Year";

            tgvPLStatement.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            tgvPLStatement.Columns[3].HeaderText   = "Difference";

            mBoldFont = new Font(tgvPLStatement.DefaultCellStyle.Font, FontStyle.Bold);

            TreeNode <Account> PLStatement         = mModel.PLStatement;
            TreeNode <Account> node_income         = null;
            TreeNode <Account> node_cos            = null;
            TreeNode <Account> node_expenses       = null;
            TreeNode <Account> node_other_income   = null;
            TreeNode <Account> node_other_expenses = null;

            foreach (TreeNode <Account> child_node in PLStatement.Children)
            {
                string accountName = child_node.DataSource.AccountName;
                if (accountName.Equals("Income"))
                {
                    node_income = child_node;
                }
                else if (accountName.Equals("Cost Of Sales"))
                {
                    node_cos = child_node;
                }
                else if (accountName.Equals("Expenses"))
                {
                    node_expenses = child_node;
                }
                else if (accountName.Equals("Other Income"))
                {
                    node_other_income = child_node;
                }
                else if (accountName.Equals("Other Expenses"))
                {
                    node_other_expenses = child_node;
                }
            }

            PopulateTreeGridView3(tgvPLStatement, node_income, year, period);
            PopulateTreeGridView3(tgvPLStatement, node_cos, year, period);

            double gross_profit = 0, gross_profit2 = 0;

            if (node_income != null && node_cos != null)
            {
                double income = node_income.DataSource.GetAmountByPeriod(year, period, false);
                double cos    = node_cos.DataSource.GetAmountByPeriod(year, period, false);
                gross_profit = income - cos;
                string gross_profit_formatted = PLStatement.DataSource.Currency.Format(gross_profit);

                income        = node_income.DataSource.GetAmountByPeriod(year - 1, period, false);
                cos           = node_cos.DataSource.GetAmountByPeriod(year - 1, period, false);
                gross_profit2 = income - cos;
                string gross_profit_formatted2 = PLStatement.DataSource.Currency.Format(gross_profit2);

                string difference = PLStatement.DataSource.Currency.Format(
                    gross_profit - gross_profit2);

                PopulateTreeGridView(tgvPLStatement, "Gross Profit", gross_profit_formatted, gross_profit_formatted2, difference);
            }

            PopulateTreeGridView3(tgvPLStatement, node_expenses, year, period);

            double operating_profit = 0, operating_profit2 = 0;

            if (node_expenses != null)
            {
                double expenses = node_expenses.DataSource.GetAmountByPeriod(year, period, false);
                operating_profit = gross_profit - expenses;
                string operating_profit_formatted = PLStatement.DataSource.Currency.Format(operating_profit);

                expenses          = node_expenses.DataSource.GetAmountByPeriod(year - 1, period, false);
                operating_profit2 = gross_profit2 - expenses;
                string operating_profit_formatted2 = PLStatement.DataSource.Currency.Format(operating_profit2);

                string difference = PLStatement.DataSource.Currency.Format(
                    operating_profit - operating_profit2);

                PopulateTreeGridView(tgvPLStatement, "Operating Profit", operating_profit_formatted, operating_profit_formatted2, difference);
            }

            PopulateTreeGridView2(tgvPLStatement, node_other_income, year, period);
            PopulateTreeGridView2(tgvPLStatement, node_other_expenses, year, period);

            TreeGridNode tgnode_total = tgvPLStatement.Nodes.Add(string.Format("{0}", PLStatement.DataSource.AccountName),
                                                                 PLStatement.DataSource.GetAmountDescriptionByPeriod(year, period, false),
                                                                 PLStatement.DataSource.GetAmountDescriptionByPeriod(year - 1, period, false),
                                                                 PLStatement.DataSource.Currency.Format(
                                                                     PLStatement.DataSource.GetAmountByPeriod(year, period, false)
                                                                     - PLStatement.DataSource.GetAmountByPeriod(year - 1, period, false)
                                                                     )
                                                                 );

            tgnode_total.Cells[0].Style.Font = mBoldFont;
        }
Example #4
0
 internal static KMod.Mod GetKMod(IPipMod mod)
 {
     return(Global.Instance.modManager.mods.Find(m => m.label.id == System.IO.Path.GetFileName(PLUtil.GetAssemblyDir(mod.GetType()))));
 }
Example #5
0
 /// <summary>
 /// Adds tags to the given element
 /// </summary>
 /// <param name="element">The element to add the tag to</param>
 /// <param name="tags">The tags to add</param>
 public static void AddTag(Element element, params Tag[] tags)
 {
     element.oreTags = PLUtil.ArrayConcat(element.oreTags, tags);
 }