Example #1
0
        private void calculateinterest(DateTime?from, DateTime?to)
        {
            //Converting parameters to DateTime structure
            var _from = Convert.ToDateTime(from);
            var _to   = Convert.ToDateTime(to);
            //Creating a list with Record type items, this is the list with the different interests and their date bounds
            List <Record>    list  = Record.Recordlist();
            Page2            page2 = new Page2(); //Creatting a page2 item
            NumberFormatInfo nfi   = new CultureInfo("fr-FR", false).NumberFormat;

            nfi.CurrencyGroupSeparator   = ",";
            nfi.CurrencyDecimalSeparator = ".";
            NumberStyles styles = NumberStyles.Currency;

            //Getting access to list of interests
            foreach (Record record in list)
            {
                //Calling checking methods to  compare user's from and to inputs with date bounds of each interest
                checktimespan1(_from, _to, record, page2);
                checktimespan2(_from, _to, record, page2);
                checktimespan3(_from, _to, record, page2);
                checktimespan4(_from, _to, record, page2);
            }
            double amount = double.Parse(textbox1.Text);          //Parsing textbox1 text (amount of money) to double

            page2.laworigamount.Text = amount.ToString("C", nfi); //Assigning textbox1 value to textblock in currency format with euro symbol
            double lawinterests = 0;

            foreach (Page2.MyItem item in page2.listView.Items)
            {
                item.Lawfulamount = item.Lawfulamount.Replace(",", String.Empty);
                lawinterests     += Double.Parse(item.Lawfulamount, styles);       //Summing the amount of money gained of each lawful interest
            }
            page2.lawinterests.Text = lawinterests.ToString("C", nfi);             //Assigning the sum to textblock in currency format with euro symbol
            page2.lawtotal.Text     = (amount + lawinterests).ToString("C", nfi);; //Assigning the user's amount of money with the sum of lawful interests to textblock in currency format with euro symbol

            amount = double.Parse(textbox1.Text);                                  //Parsing textbox1 text (amount of money) to double
            page2.defaultorigamount.Text = amount.ToString("C", nfi);              //Assigning textbox1 value to textblock in currency format with euro symbol
            double defaultinterests = 0;

            foreach (Page2.MyItem item in page2.listView.Items)
            {
                item.Defaultamount = item.Defaultamount.Replace(",", String.Empty);
                defaultinterests  += Double.Parse(item.Defaultamount, styles);             //Summing the amount of money gained of each default interest
            }
            page2.defaultinterests.Text = defaultinterests.ToString("C", nfi);             //Assigning the sum to textblock in currency format with euro symbol
            page2.defaulttotal.Text     = (amount + defaultinterests).ToString("C", nfi);; //Assigning the user's amount of money with the sum of default interests to textblock in currency format with euro symbol
            this.NavigationService.Navigate(page2);                                        //Navigate to Page2
        }
Example #2
0
        private void checktimespan1(DateTime _from, DateTime _to, Record record, Page2 page2)
        {
            NumberFormatInfo nfi = new CultureInfo("fr-FR", false).NumberFormat;

            nfi.CurrencyGroupSeparator   = ",";
            nfi.CurrencyDecimalSeparator = ".";
            if (_from > record.Startdate && _to < record.Enddate) //Checking if from and to inputs are inside the date bounds of an inerest
            {
                if (combobox1.SelectedIndex == 0)                 //Calendar year selected
                {
                    var    tempfrom = _from;                      //temporary from date
                    double result   = 0;
                    double result2  = 0;
                    while (tempfrom.Year <= _to.Year)                         //Calculating each year interests
                    {
                        var daysofyear = Iscommon(tempfrom.Year) ? 365 : 366; //Check if temporary year is common or leap
                        if (tempfrom.Year == _to.Year)
                        {
                            result  += double.Parse(textbox1.Text) * ((_to - tempfrom).TotalDays + 1) * record.Lawfulinterest / daysofyear;    //Counting the amount of money of lawful interest for this timespan
                            result2 += double.Parse(textbox1.Text) * ((_to - tempfrom).TotalDays + 1) * record.Defaultinterest / daysofyear;   //Counting the amount of money of default interest for this timespan
                            break;
                        }
                        var tempto = new DateTime(tempfrom.Year, 12, 31);                                                                   // temporary to is equal to the last day of a year
                        result  += double.Parse(textbox1.Text) * ((tempto - tempfrom).TotalDays + 1) * record.Lawfulinterest / daysofyear;  //Counting the amount of money of lawful interest for this timespan
                        result2 += double.Parse(textbox1.Text) * ((tempto - tempfrom).TotalDays + 1) * record.Defaultinterest / daysofyear; //Counting the amount of money of default interest for this timespan
                        tempfrom = tempto.AddDays(1);                                                                                       //temporary from is equal to next day of temporary to
                    }

                    //Insert user's from and to inputs, timespan of them, lawful interest precantage, amount of money of lawful interest, default interest precantage, amount of money of default interest
                    page2.listView.Items.Add(new Page2.MyItem {
                        From = _from, To = _to, Days = ((_to - _from).TotalDays + 1), Lawfulinterest = record.Lawfulinterest.ToString("P"), Lawfulamount = result.ToString("C", nfi), Defaultinterest = record.Defaultinterest.ToString("P"), Defaultamount = result2.ToString("C", nfi)
                    });
                }
                else if (combobox1.SelectedIndex == 1)                                                                        //360 days year selected
                {
                    var result  = double.Parse(textbox1.Text) * ((_to - _from).TotalDays + 1) * record.Lawfulinterest / 360;  //Counting the amount of money of lawful interest for this timespan
                    var result2 = double.Parse(textbox1.Text) * ((_to - _from).TotalDays + 1) * record.Defaultinterest / 360; //Counting the amount of money of default interest for this timespan
                    //Insert user's from and to inputs, timespan of them, lawful interest precantage, amount of money of lawful interest, default interest precantage, amount of money of default interest
                    page2.listView.Items.Add(new Page2.MyItem {
                        From = _from, To = _to, Days = ((_to - _from).TotalDays + 1), Lawfulinterest = record.Lawfulinterest.ToString("P"), Lawfulamount = result.ToString("C", nfi), Defaultinterest = record.Defaultinterest.ToString("P"), Defaultamount = result2.ToString("C", nfi)
                    });
                }
            }
        }
Example #3
0
        private void checktimespan4(DateTime _from, DateTime _to, Record record, Page2 page2)
        {
            NumberFormatInfo nfi = new CultureInfo("fr-FR", false).NumberFormat;

            nfi.CurrencyGroupSeparator   = ",";
            nfi.CurrencyDecimalSeparator = ".";
            if (_from <= record.Startdate && _to >= record.Enddate)
            {
                if (combobox1.SelectedIndex == 0)
                {
                    var    tempfrom = record.Startdate;
                    double result   = 0;
                    double result2  = 0;
                    while (tempfrom.Year <= record.Enddate.Year)
                    {
                        var daysofyear = Iscommon(tempfrom.Year) ? 365 : 366;
                        if (tempfrom.Year == record.Enddate.Year)
                        {
                            result  += double.Parse(textbox1.Text) * ((record.Enddate - tempfrom).TotalDays + 1) * record.Lawfulinterest / daysofyear;
                            result2 += double.Parse(textbox1.Text) * ((record.Enddate - tempfrom).TotalDays + 1) * record.Defaultinterest / daysofyear;
                            break;
                        }
                        var tempto = new DateTime(tempfrom.Year, 12, 31);
                        result  += double.Parse(textbox1.Text) * ((tempto - tempfrom).TotalDays + 1) * record.Lawfulinterest / daysofyear;
                        result2 += double.Parse(textbox1.Text) * ((tempto - tempfrom).TotalDays + 1) * record.Defaultinterest / daysofyear;
                        tempfrom = tempto.AddDays(1);
                    }

                    page2.listView.Items.Add(new Page2.MyItem {
                        From = record.Startdate, To = record.Enddate, Days = ((record.Enddate - record.Startdate).TotalDays + 1), Lawfulinterest = record.Lawfulinterest.ToString("P"), Lawfulamount = result.ToString("C", nfi), Defaultinterest = record.Defaultinterest.ToString("P"), Defaultamount = result2.ToString("C", nfi)
                    });
                }
                else if (combobox1.SelectedIndex == 1)
                {
                    var result  = double.Parse(textbox1.Text) * ((record.Enddate - record.Startdate).TotalDays + 1) * record.Lawfulinterest / 360;
                    var result2 = double.Parse(textbox1.Text) * ((record.Enddate - record.Startdate).TotalDays + 1) * record.Defaultinterest / 360;
                    page2.listView.Items.Add(new Page2.MyItem {
                        From = record.Startdate, To = record.Enddate, Days = ((record.Enddate - record.Startdate).TotalDays + 1), Lawfulinterest = record.Lawfulinterest.ToString("P"), Lawfulamount = result.ToString("C", nfi), Defaultinterest = record.Defaultinterest.ToString("P"), Defaultamount = result2.ToString("C", nfi)
                    });
                }
            }
        }
Example #4
0
        public virtual void processSkeletonFramePage2(Skeleton skeleton, Canvas canvas, Page2 page, Canvas basCanvas)
        {
            Joint leftHand = skeleton.Joints[JointType.HandLeft].ScaleTo(1366, 768, window.k_xMaxJointScale, window.k_yMaxJointScale);
            Joint rightHand = skeleton.Joints[JointType.HandRight].ScaleTo(1366, 768, window.k_xMaxJointScale, window.k_yMaxJointScale);
            bool shouldExitForLoop = false;

            if (userIsSelectingCharacter)
            {
                //User is moving the character
                Console.WriteLine("Z-value-diff: " + Math.Abs(rightHand.Position.Z - lastZPosition));
                Console.WriteLine("Selected Char Name: " + selectedCharacterName);
                if (usingRightHand && rightHand.Position.Z - lastZPosition <= -Z_SELECTION_THRESHOLD)
                {
                    moveCharacter(rightHand);
                }
                else if (!usingRightHand && leftHand.Position.Z - lastZPosition <= -Z_SELECTION_THRESHOLD)
                {
                    moveCharacter(leftHand);
                }
                else if (!eitherHandIsOverImage(characterToReposition, canvas, leftHand, rightHand))
                {
                    userIsSelectingCharacter = false;
                    lastZPosition = 0;
                }
            }
            else
            {
                foreach (object uiElm in canvas.Children)
                {
                  
                    if (uiElm is System.Windows.Shapes.Rectangle)
                    {
                        if (eitherHandIsOverRectangle((System.Windows.Shapes.Rectangle)uiElm, canvas, leftHand, rightHand))
                        {
                            if (String.Compare(((System.Windows.Shapes.Rectangle)uiElm).Name, "backbutton") == 0)
                            {
                                frameCount++;
                                if (frameCount >= TIMER * FRAME_PER_SEC)
                                {
                                    del.removeCurrentScene();
                                    Frame recordAScene = new Frame();
                                    recordAScene.Source = new Uri("WpfApplication2;component/Page1.xaml", UriKind.Relative);
                                    recordAScene.NavigationService.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(MainWindow.NavigationService_LoadCompleted);
                                    Application.Current.MainWindow.Content = recordAScene;
                                    frameCount = 0;
                                    break;
                                }
                            }
                            else if (String.Compare(((System.Windows.Shapes.Rectangle)uiElm).Name, "record") == 0)
                            {
                                frameCount++;
                                if (frameCount >= TIMER * FRAME_PER_SEC)
                                {
                                    foreach (object obj in canvas.Children)
                                    {
                                        if (obj is Label && String.Compare(((Label)obj).Name, "mode") == 0)
                                        {
                                            ((Label)obj).Content = "Record";
                                            shouldExitForLoop = true;
                                            frameCount = 0;
                                            break;
                                        }
                                    }
                                }
                            }
                            else if (String.Compare(((System.Windows.Shapes.Rectangle)uiElm).Name, "pause") == 0)
                            {
                                frameCount++;
                                if (frameCount >= TIMER * FRAME_PER_SEC)
                                {
                                    foreach (object obj in canvas.Children)
                                    {
                                        if (obj is Label && String.Compare(((Label)obj).Name, "mode") == 0)
                                        {
                                            ((Label)obj).Content = "Paused";
                                            shouldExitForLoop = true;
                                            frameCount = 0;
                                            break;
                                        }
                                    }
                                }
                            }
                            else if (String.Compare(((System.Windows.Shapes.Rectangle)uiElm).Name, "forwardButton") == 0)
                            {
                                frameCount++;
                                if (frameCount >= TIMER * FRAME_PER_SEC)
                                {
                                    frameCount = 0;
                                    if (del.getCurrentScene() == 2)
                                    {
                                        //done page
                                        //reset everything 
                                        Frame recordAScene = new Frame();
                                        recordAScene.Source = new Uri("Page6.xaml", UriKind.Relative);
                                        recordAScene.NavigationService.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(MainWindow.NavigationService_LoadCompleted);
                                        Application.Current.MainWindow.Content = recordAScene;
                                        break;
                                    }
                                    else
                                    {
                                        Frame recordAScene = new Frame();
                                        if(del.getAssitanceMode() == true)
                                            recordAScene.Source = new Uri("WpfApplication2;component/Page9.xaml", UriKind.Relative);
                                        else
                                            recordAScene.Source = new Uri("WpfApplication2;component/Page1.xaml", UriKind.Relative);
                                        recordAScene.NavigationService.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(MainWindow.NavigationService_LoadCompleted);
                                        Application.Current.MainWindow.Content = recordAScene;
                                        break;
                                    }
                                }
                            }
                            else if (String.Compare(((System.Windows.Shapes.Rectangle)uiElm).Name, "toyBox") == 0)
                            {
                                frameCount++;
                                if (frameCount >= TIMER * FRAME_PER_SEC)
                                {
                                    Frame recordAScene = new Frame();
                                    recordAScene.Source = new Uri("Page3.xaml", UriKind.Relative);
                                    recordAScene.NavigationService.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(MainWindow.NavigationService_LoadCompleted);
                                    Application.Current.MainWindow.Content = recordAScene;
                                    frameCount = 0;
                                }
                            }
                            else if (String.Compare(((System.Windows.Shapes.Rectangle)uiElm).Name, "switchMode") == 0)
                            {
                                frameCount++;
                                if (frameCount >+ TIMER * FRAME_PER_SEC)
                                {
                                    frameCount = 0;
                                    lastFrame = (Frame)Application.Current.MainWindow.Content;
                                    Frame recordAScene = new Frame();
                                    recordAScene.Source = new Uri("Page4.xaml", UriKind.Relative);
                                    recordAScene.NavigationService.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(MainWindow.NavigationService_LoadCompleted);
                                    Application.Current.MainWindow.Content = recordAScene;
                                    del.setSelectedCharacter(selectedCharacterName);
                                }
                            }

                            else if (String.Compare(((System.Windows.Shapes.Rectangle)uiElm).Name, "Delete") == 0)
                            {
                                frameCount++;
                                if (frameCount >= TIMER * FRAME_PER_SEC)
                                {
                                    frameCount = 0;
                                    if (characterToReposition != null)
                                    {
                                        String indexStr = characterToReposition.Name;
                                        int i = indexStr.IndexOf("character") -1;
                                        indexStr = indexStr.Substring(1, i);
                                        int index = Convert.ToInt32(indexStr);
                                        
                                        basCanvas.Children.Remove(characterToReposition);
                                        del.setSelectedCharacter("");
                                        del.removeCharacter(index);
                                        characterToReposition = null;
                                    }
                                }
                                // Frame recordAScene = new Frame();
                                // recordAScene.Source = new Uri("Page3.xaml", UriKind.Relative);
                                //recordAScene.NavigationService.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(MainWindow.NavigationService_LoadCompleted);
                                //Application.Current.MainWindow.Content = recordAScene;

                            }
                            else
                            {
                                frameCount = 0;
                            }

                            if (shouldExitForLoop) break;
                        }
                    }
                    else if (uiElm is Canvas)
                    {
                        foreach (object child in ((Canvas)uiElm).Children)
                        {
                            if (child is System.Windows.Controls.Image)
                            {
                                if (handIsOverImage((System.Windows.Controls.Image)child, canvas, rightHand))
                                {
                                    //Console.WriteLine("Right Hand Z" + rightHand.Position.Z);
                                    String imgName = ((System.Windows.Controls.Image)child).Name;
                                    if (imgName.Contains("Meatwad"))
                                    {
                                        characterToReposition = (System.Windows.Controls.Image)child;
                                        selectedCharacterName = "Meatwad";
                                        userIsSelectingCharacter = true;
                                        usingRightHand = true;
                                        lastZPosition = rightHand.Position.Z;
                                    }
                                    else if (imgName.Contains("Optimus"))
                                    {
                                        characterToReposition = (System.Windows.Controls.Image)child;
                                        selectedCharacterName = "OptimusPrime";
                                        userIsSelectingCharacter = true;
                                        Console.WriteLine("Selected Char Name: " + selectedCharacterName);
                                        usingRightHand = true;
                                        lastZPosition = rightHand.Position.Z;
                                    }
                                    else if (imgName.Contains("Sailor"))
                                    {
                                        characterToReposition = (System.Windows.Controls.Image)child;
                                        selectedCharacterName = "SailorMoon";
                                        userIsSelectingCharacter = true;
                                        usingRightHand = true;
                                        lastZPosition = rightHand.Position.Z;
                                    }
                                    
                                    //Console.WriteLine("Last Hand Z" + lastZPosition);
                                }
                                else if (handIsOverImage((System.Windows.Controls.Image)child, canvas, leftHand))
                                {

                                    String imgName = ((System.Windows.Controls.Image)child).Name;
                                    if (imgName.Contains("Meatwad"))
                                    {
                                        characterToReposition = (System.Windows.Controls.Image)child;
                                        selectedCharacterName = "Meatwad";
                                        userIsSelectingCharacter = true;
                                        usingRightHand = false;
                                        lastZPosition = leftHand.Position.Z;
                                    }
                                    else if (imgName.Contains("Optimus"))
                                    {
                                        characterToReposition = (System.Windows.Controls.Image)child;
                                        selectedCharacterName = "OptimusPrime";
                                        userIsSelectingCharacter = true;
                                        Console.WriteLine("Selected Char Name: " + selectedCharacterName);
                                        usingRightHand = false;
                                        lastZPosition = leftHand.Position.Z;
                                    }
                                    else if (imgName.Contains("Sailor"))
                                    {
                                        characterToReposition = (System.Windows.Controls.Image)child;
                                        selectedCharacterName = "SailorMoon";
                                        userIsSelectingCharacter = true;
                                        usingRightHand = false;
                                        lastZPosition = leftHand.Position.Z;
                                    }
                                    
                                }
                                /*else
                                {
                                    userIsSelectingCharacter = false;
                                    lastZPosition = 0;
                                }*/

                            }
                        }
                    }
                }
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Page2 p = new Page2(this.PeopleList.SelectedItem);

            this.NavigationService.Navigate(p);
        }