public UserDisplay(Windows.UI.Xaml.Controls.StackPanel p, User theUser) { this.theUser = theUser; //set colors SolidColorBrush color1 = new SolidColorBrush(Color.FromArgb(179, 100, 130, 200)); SolidColorBrush color2 = new SolidColorBrush(Color.FromArgb(255, 45, 63, 104)); //parent -> display this.display = new StackPanel(); p.Children.Add(this.display); this.display.Background = color1; this.display.Height = 200; this.display.Width = p.Width; // set width to parent's width this.display.Orientation = Orientation.Horizontal; //parent -> display -> borderName DisplayNameBox borderName = new DisplayNameBox(display, color2); TextBlock rowName = (TextBlock)borderName.rowName; rowName.Text = "Personal Data"; //parent -> display -> scroller ScrollViewer scroller = new ScrollViewer(); this.display.Children.Add(scroller); scroller.VerticalScrollMode = ScrollMode.Disabled; scroller.ZoomMode = ZoomMode.Disabled; scroller.Width = this.display.Width - 260; scroller.Height = this.display.Height; scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden; scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled; //parent -> display -> scroller -> dataStack StackPanel dataStack = new StackPanel(); scroller.Content = dataStack; dataStack.Height = 200; dataStack.Orientation = Orientation.Horizontal; dataStack.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left; //parent -> display -> scroller -> dataStack -> milesStack DisplaySliderStack milesStack = new DisplaySliderStack(dataStack, "How many miles do you drive a year?", "What percent are city miles (vs highway)?", User.MinMiles, User.MaxMiles, ((int)(User.MinMiles / 1000)).ToString() + "k", ((int)(User.MaxMiles / 1000)).ToString() + "k", (int)(User.MinPercentCity * 100), (int)(User.MaxPercentCity * 100), ((int)(User.MinPercentCity * 100)).ToString() + "%", ((int)(User.MaxPercentCity * 100)).ToString() + "%", color1, color2); UIElementCollection milesStackChildren = ((StackPanel)(milesStack.stackP).Children[1]).Children; ((Slider)milesStackChildren[1]).ValueChanged += updateMilesPerYear; milesStackChildren = ((StackPanel)(milesStack.stackP).Children[3]).Children; ((Slider)milesStackChildren[1]).ValueChanged += updatePercentCityMiles; //parent -> display -> scroller -> dataStack -> gasStack DisplaySoloSliderStack gasStack = new DisplaySoloSliderStack(dataStack, "How much does a gallon of gas cost?", (int)User.MinPriceFuel, (int)User.MaxPriceFuel, "$" + User.MinPriceFuel.ToString("F"), "$" + User.MaxPriceFuel.ToString("F"), color1, color2); UIElementCollection gasStackChildren = ((StackPanel)(gasStack.stackP).Children[1]).Children; ((Slider)gasStackChildren[1]).ValueChanged += updateGasPrice; //parent -> display -> scroller -> dataStack -> interestTaxStack DisplaySliderStack interestTaxStack = new DisplaySliderStack(dataStack, "What is your interest rate?", "What is your sales tax rate?", (int)User.MinInterest, (int)User.MaxInterest, ((int)(User.MinInterest)).ToString() + "%", ((int)(User.MaxInterest)).ToString() + "%", (int)User.MinTax, (int)User.MaxTax, ((int)(User.MinTax)).ToString() + "%", ((int)(User.MaxTax)).ToString() + "%", color1, color2); UIElementCollection interestTaxStackChildren = ((StackPanel)(interestTaxStack.stackP).Children[1]).Children; ((Slider)interestTaxStackChildren[1]).ValueChanged += updateInterest; interestTaxStackChildren = ((StackPanel)(interestTaxStack.stackP).Children[3]).Children; ((Slider)interestTaxStackChildren[1]).ValueChanged += updateTax; //parent -> display -> scroller -> dataStack -> deleteStack DisplayDeleteButton displayDeleteButton = new DisplayDeleteButton(dataStack, "Reset User Data", color2); Button deleteButton = displayDeleteButton.deleteB; deleteButton.Tapped += clearData; //parent -> memoBar this.memoBar = new StackPanel(); p.Children.Add(this.memoBar); this.memoBar.Width = p.Width; // set width to parent's width this.memoBar.Height = 64; this.memoBar.Orientation = Orientation.Horizontal; //parent -> memoBar -> memoScroll -> memoStack -> elements DisplayMemoScroll memoScroll = new DisplayMemoScroll(this.memoBar); StackPanel memoStack = (StackPanel)memoScroll.memoScroll.Content; DisplayMemoTextBlock milesLabel = new DisplayMemoTextBlock(memoStack, "Annual Miles:"); DisplayMemoTextBox miles = new DisplayMemoTextBox(memoStack, (0.ToString()), color1); DisplayMemoTextBlock percentCityLabel = new DisplayMemoTextBlock(memoStack, "Percent City Miles:"); DisplayMemoTextBox percentCity = new DisplayMemoTextBox(memoStack, (0.ToString()) + "%", color1); DisplayMemoTextBlock fuelCostLabel = new DisplayMemoTextBlock(memoStack, "Fuel Cost:"); DisplayMemoTextBox fuelCost = new DisplayMemoTextBox(memoStack, "$" + (0.ToString("F")), color1); DisplayMemoTextBlock interestLabel = new DisplayMemoTextBlock(memoStack, "Interest Rate:"); DisplayMemoTextBox interest = new DisplayMemoTextBox(memoStack, (0.ToString("F")) + "%", color1); DisplayMemoTextBlock taxLabel = new DisplayMemoTextBlock(memoStack, "Tax Rate:"); DisplayMemoTextBox tax = new DisplayMemoTextBox(memoStack, (0.ToString("F")) + "%", color1); }
public VehicleDisplay(Windows.UI.Xaml.Controls.StackPanel p, VehicleWrapper theVehicle, int numVehicles) { this.theVehicle = theVehicle; //set colors SolidColorBrush color1, color2; switch (numVehicles % 4) { case 0: //red color1 = new SolidColorBrush(Color.FromArgb(179, 212, 107, 61)); color2 = new SolidColorBrush(Color.FromArgb(255, 118, 42, 9)); break; case 1: //green color1 = new SolidColorBrush(Color.FromArgb(179, 31, 166, 71)); color2 = new SolidColorBrush(Color.FromArgb(255, 21, 83, 39)); break; case 2: //purple color1 = new SolidColorBrush(Color.FromArgb(179, 128, 74, 133)); color2 = new SolidColorBrush(Color.FromArgb(255, 83, 19, 89)); break; //color1 = new SolidColorBrush(Color.FromArgb(255, 155, 22, 168)); break; default: //orange color1 = new SolidColorBrush(Color.FromArgb(179, 228, 184, 67)); color2 = new SolidColorBrush(Color.FromArgb(255, 220, 171, 40)); break; } //parent -> display this.display = new StackPanel(); p.Children.Add(this.display); this.display.Background = color1; this.display.Height = 200; this.display.Width = p.Width; // set width to parent's width this.display.Orientation = Orientation.Horizontal; //parent -> display -> borderName DisplayNameBox borderName = new DisplayNameBox(display, color2); updateName("New Vehicle " + (numVehicles + 1).ToString()); //parent -> display -> scroller ScrollViewer scroller = new ScrollViewer(); this.display.Children.Add(scroller); scroller.VerticalScrollMode = ScrollMode.Disabled; scroller.ZoomMode = ZoomMode.Disabled; scroller.Width = this.display.Width - 260; scroller.Height = this.display.Height; scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden; scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled; //parent -> display -> scroller -> dataStack StackPanel dataStack = new StackPanel(); scroller.Content = dataStack; dataStack.Height = 200; dataStack.Orientation = Orientation.Horizontal; dataStack.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left; //parent -> display -> scroller -> dataStack -> descStack1 DisplayTextBlockStack descStack1 = new DisplayTextBlockStack(dataStack, "Year:", "Make:", "Model:", "Source:"); //parent -> display -> scroller -> dataStack -> descStack2 DisplayTextBoxStack descStack2 = new DisplayTextBoxStack(dataStack); UIElementCollection textBoxes = descStack2.stackP.Children; ((TextBox)textBoxes[0]).TextChanged += new TextChangedEventHandler(updateYear); ((TextBox)textBoxes[1]).TextChanged += new TextChangedEventHandler(updateMake); ((TextBox)textBoxes[2]).TextChanged += new TextChangedEventHandler(updateModel); ((TextBox)textBoxes[3]).TextChanged += new TextChangedEventHandler(updateSource); //parent -> display -> scroller -> dataStack -> priceStack DisplaySliderStack priceStack = new DisplaySliderStack(dataStack, "Price", "Cost to Repair", VehicleWrapper.MinPrice, VehicleWrapper.MaxPrice, "$" + VehicleWrapper.MinPrice.ToString(), "$" + VehicleWrapper.MaxPrice.ToString(), VehicleWrapper.MinRepairCost, VehicleWrapper.MaxRepairCost, "$" + VehicleWrapper.MinRepairCost.ToString(), "$" + VehicleWrapper.MaxRepairCost.ToString(), color1, color2); UIElementCollection priceStackChildren = ((StackPanel)(priceStack.stackP).Children[1]).Children; ((Slider)priceStackChildren[1]).ValueChanged += updatePrice; // price priceStackChildren = ((StackPanel)(priceStack.stackP).Children[3]).Children; ((Slider)priceStackChildren[1]).ValueChanged += updateRepairCost; // repair //parent -> display -> scroller -> dataStack -> mileageStack DisplaySliderStack mileageStack = new DisplaySliderStack(dataStack, "Initial Mileage", "Estimated Final Mileage", VehicleWrapper.MinInitialMileage, VehicleWrapper.MaxInitialMileage, ((int)(VehicleWrapper.MinInitialMileage / 1000)).ToString() + "k", ((int)(VehicleWrapper.MaxInitialMileage / 1000)).ToString() + "k", theVehicle.MinFinalMileage, VehicleWrapper.MaxFinalMileage, ((int)(theVehicle.MinFinalMileage / 1000)).ToString() + "k", ((int)(VehicleWrapper.MaxFinalMileage / 1000)).ToString() + "k", color1, color2); UIElementCollection mileageStackChildren = ((StackPanel)(mileageStack.stackP).Children[1]).Children; ((Slider)mileageStackChildren[1]).ValueChanged += updateInitialMileage; // initial mileage mileageStackChildren = ((StackPanel)(mileageStack.stackP).Children[3]).Children; ((Slider)mileageStackChildren[1]).ValueChanged += updateFinalMileage; //parent -> display -> scroller -> dataStack -> mpgStack DisplaySliderStack mpgStack = new DisplaySliderStack(dataStack, "City MPG", "Highway MPG", VehicleWrapper.MinCityMPG, VehicleWrapper.MaxCityMPG, ((int)(VehicleWrapper.MinCityMPG)).ToString(), ((int)(VehicleWrapper.MaxCityMPG)).ToString(), VehicleWrapper.MinHighwayMPG, VehicleWrapper.MaxHighwayMPG, ((int)(VehicleWrapper.MinHighwayMPG)).ToString(), ((int)(VehicleWrapper.MaxHighwayMPG)).ToString(), color1, color2); UIElementCollection mpgStackChildren = ((StackPanel)(mpgStack.stackP).Children[1]).Children; ((Slider)mpgStackChildren[1]).ValueChanged += updateCityMPG; mpgStackChildren = ((StackPanel)(mpgStack.stackP).Children[3]).Children; ((Slider)mpgStackChildren[1]).ValueChanged += updateHighwayMPG; //parent -> display -> scroller -> dataStack -> notesStack DisplayNotesStack notesStack = new DisplayNotesStack(dataStack, "Notes:", "Insert any notes about your vehicle here."); UIElementCollection notesStackChildren = notesStack.stackP.Children; ((TextBox)notesStackChildren[1]).TextChanged += updateNotes; //parent -> display -> scroller -> dataStack -> deleteStack DisplayDeleteButton displayDeleteButton = new DisplayDeleteButton(dataStack, "Delete Vehicle", color2); Button deleteButton = displayDeleteButton.deleteB; deleteButton.Tapped += deleteVehicle; //parent -> memoBar this.memoBar = new StackPanel(); p.Children.Add(this.memoBar); this.memoBar.Width = p.Width; // set width to parent's width this.memoBar.Height = 64; this.memoBar.Orientation = Orientation.Horizontal; //parent -> memoBar -> memoScroll -> memoStack -> elements DisplayMemoScroll memoScroll = new DisplayMemoScroll(this.memoBar); StackPanel memoStack = (StackPanel)memoScroll.memoScroll.Content; DisplayMemoTextBox cpm = new DisplayMemoTextBox(memoStack, (0.ToString("F") + "¢ per mile"), color1); cpm.memoText.FontSize += 13; // make cents per mile display bigger cpm.memoText.FontWeight = Windows.UI.Text.FontWeights.Thin; cpm.memoText.CharacterSpacing = 75; cpm.memoText.Margin = new Windows.UI.Xaml.Thickness(0, 0, 0, 0); cpm.memoText.Width = 225; DisplayMemoTextBlock totalCostLabel = new DisplayMemoTextBlock(memoStack, "Total Cost:"); DisplayMemoTextBox totalCost = new DisplayMemoTextBox(memoStack, "$" + (0.ToString()), color1); DisplayMemoTextBlock lifeSpanLabel = new DisplayMemoTextBlock(memoStack, "Life Span:"); DisplayMemoTextBox lifeSpan = new DisplayMemoTextBox(memoStack, (0.ToString("F") + " years"), color1); DisplayMemoTextBlock avgMPGLabel = new DisplayMemoTextBlock(memoStack, "Average MPG:"); DisplayMemoTextBox aveMPG = new DisplayMemoTextBox(memoStack, (1.ToString("F")), color1); DisplayMemoTextBlock maintenanceLabel = new DisplayMemoTextBlock(memoStack, "Maintenance:"); DisplayMemoTextBox maintenance = new DisplayMemoTextBox(memoStack, "$" + (0.ToString()), color1); DisplayMemoTextBlock resellLabel = new DisplayMemoTextBlock(memoStack, "Resell:"); DisplayMemoTextBox resell = new DisplayMemoTextBox(memoStack, "$" + (0.ToString()), color1); }