Ejemplo n.º 1
0
        public static bool askToSave(ref bool dirty, SaveFunction saveToFile, ReturnComboBoxIndexFunction returnCbLevelIndex)
        {
            if (!dirty)
            {
                return(true);
            }
            DialogResult dr = MessageBox.Show("Level was changed. Do you want to save current level?", "Save", MessageBoxButtons.YesNoCancel);

            if (dr == DialogResult.Cancel)
            {
                returnCbLevelIndex?.Invoke();
                return(false);
            }
            else if (dr == DialogResult.Yes)
            {
                if (!saveToFile())
                {
                    returnCbLevelIndex?.Invoke();
                    return(false);
                }
                return(true);
            }
            else
            {
                dirty = false;
                return(true);
            }
        }
Ejemplo n.º 2
0
 public static bool askToSave(ref bool dirty, SaveFunction saveToFile, ReturnComboBoxIndexFunction returnCbLevelIndex)
 {
     if (!dirty)
         return true;
     DialogResult dr = MessageBox.Show("Level was changed. Do you want to save current level?", "Save", MessageBoxButtons.YesNoCancel);
     if (dr == DialogResult.Cancel)
     {
         if (returnCbLevelIndex != null)
             returnCbLevelIndex();
         return false;
     }
     else if (dr == DialogResult.Yes)
     {
         if (!saveToFile())
         {
             if (returnCbLevelIndex != null)
                 returnCbLevelIndex();
             return false;
         }
         return true;
     }
     else
     {
         dirty = false;
         return true;
     }
 }
Ejemplo n.º 3
0
 public void Load()
 {
     background.enabled = true;
     titleText.text     = "Load Game";
     saveFunction       = SaveFunction.Load;
     isSaving           = false;
     savePanel.SetActive(true);
 }
Ejemplo n.º 4
0
 public void Delete()
 {
     background.enabled = true;
     titleText.text     = "Delete Saved Game";
     saveFunction       = SaveFunction.Delete;
     savePanel.SetActive(true);
     onUpdateMenuFunction?.Invoke();
 }
Ejemplo n.º 5
0
 public void Save()
 {
     background.enabled = true;
     titleText.text     = "Save Game";
     saveFunction       = SaveFunction.Save;
     isSaving           = true;
     savePanel.SetActive(true);
 }
        public IHttpActionResult GetLoans()
        {
            var loans = SaveFunction.GetLoans();

            if (loans == null)
            {
                return(BadRequest("Unable to retrieve loans"));
            }

            return(Ok(loans));
        }
        public IHttpActionResult DeleteLoans([FromBody] List <int> loans)
        {
            var id = SaveFunction.DeleteLoans(loans);

            if (0 < id)
            {
                return(Ok(id));
            }
            else
            {
                return(BadRequest("Unable delete loans"));
            }
        }
        public IHttpActionResult AddLoan([FromBody] Loan loanInput)
        {
            var id = SaveFunction.AddLoan(loanInput);

            if (0 < id)
            {
                return(Ok(id));
            }
            else
            {
                return(BadRequest("Unable to save loan"));
            }
        }
Ejemplo n.º 9
0
 public void CancelDelete()
 {
     if (isSaving)
     {
         titleText.text = "Save Game";
         saveFunction   = SaveFunction.Save;
     }
     else
     {
         titleText.text = "Load Game";
         saveFunction   = SaveFunction.Load;
     }
     onUpdateMenuFunction?.Invoke();
 }
        /// <summary>
        /// Saves if user wants to
        /// </summary>
        /// <param name="somethingChanged">bool indicating if something has changed</param>
        /// <param name="saveFunc">The function that will perform the actual saving.</param>
        /// <returns>True if something was saved</returns>
        public static DialogResult SaveCheck(bool somethingChanged, SaveFunction saveFunc)
        {
            var saveOr = DialogResult.None;
            if (somethingChanged)
            {
                saveOr = MessageBox.Show("Läget ej sparat! Spara nu?", "Spara?", MessageBoxButtons.YesNoCancel);

                    // Cancel
                if (saveOr == DialogResult.Yes)
                {
                    saveFunc();
                }
            }

            return saveOr;
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            int indication = 1;
            List <List <CashflowRow> > fullList = new List <List <CashflowRow> >();


            while (indication > 0)
            {
                Loan loan = new Loan();
                Console.Write("Please enter in your loan amount: ");
                string amount1 = Console.ReadLine();
                loan.Amount = decimal.Parse(amount1);

                Console.Write("Please enter in your loan duration: ");
                string duration1 = Console.ReadLine();
                loan.Duration = Int32.Parse(duration1);

                Console.Write("Please enter in your interest rate: ");
                string r1 = Console.ReadLine();
                loan.Rate = decimal.Parse(r1);

                SaveFunction.AddLoan(loan);
                List <CashflowRow> flowList = Calculator.CalculateCashflow(loan);
                fullList.Add(flowList);

                int length = flowList.Count;
                Console.WriteLine("Month\t\tInterest\tPrincipal\tRemaining Balance");
                for (int i = 0; i < length; i++)
                {
                    Console.WriteLine(flowList[i].Month + "\t\t" + Math.Round(flowList[i].InterestPayment, 2) + "\t\t" +
                                      Math.Round(flowList[i].PrincipalPayment, 2) + "\t\t" + Math.Round(flowList[i].RemainingBalance, 2));
                }

                Console.Write("Would you want to enter anoother one? yes(1)/no(0)");
                indication = int.Parse(Console.ReadLine());
            }


            int maxMonth            = fullList.Max(x => x.Count);
            List <CashflowRow> pool = new List <CashflowRow>();

            for (var i = 0; i < maxMonth; ++i)
            {
                CashflowRow cashflowRow = new CashflowRow();
                cashflowRow.Month = i + 1;
                foreach (var cashflow in fullList)
                {
                    int cashflowMonths = cashflow.Count;
                    cashflowRow.InterestPayment  += cashflowMonths > i ? cashflow[i].InterestPayment : 0;
                    cashflowRow.PrincipalPayment += cashflowMonths > i ? cashflow[i].PrincipalPayment : 0;
                    cashflowRow.RemainingBalance += cashflowMonths > i ? cashflow[i].RemainingBalance : 0;
                }
                pool.Add(cashflowRow);
            }
            Console.WriteLine("Month\t\tInterest\tPrincipal\tRemaining Balance");
            for (int i = 0; i < pool.Count; i++)
            {
                Console.WriteLine(pool[i].Month + "\t\t" + Math.Round(pool[i].InterestPayment, 2) + "\t\t" +
                                  Math.Round(pool[i].PrincipalPayment, 2) + "\t\t" + Math.Round(pool[i].RemainingBalance, 2));
            }
        }
Ejemplo n.º 12
0
 public void SaveChangesInFakeContext(Mock <FakeContext> mock, CancellationToken token, SaveFunction SaveFunc, params IDbSetMock[] items)
 {
     mock.Setup(c => c.SaveChangesAsync(token)).Returns(() => Task.Run(() => { SaveFunc(items); return(1); })).Verifiable();
     mock.Setup(c => c.SaveChanges()).Returns(() => { SaveFunc(items); return(1); }).Verifiable();
 }
Ejemplo n.º 13
0
 private void OnDestroy()
 {
     saveFunction = null;
 }
Ejemplo n.º 14
0
        public static EditorTextEntryWindow Create(string windowTitle, string existingText, SaveFunction saveFunction)
        {
            var createdWin = CreateInstance <EditorTextEntryWindow>();

            if (existingText != null)
            {
                createdWin.enteredText = existingText;
            }

            createdWin.saveFunction = saveFunction;

            createdWin.minSize = createdWin.winSize;
            createdWin.maxSize = createdWin.winSize;
            createdWin.SetWindowTitle(windowTitle);

            return(createdWin);
        }