コード例 #1
0
ファイル: Window2.xaml.cs プロジェクト: james276657/code
        private void createDigitalGauges()
        {
            MPHModel mphM = MPHModel.Instance;
            RPMModel rpmM = RPMModel.Instance;
            ODOModel odoM = ODOModel.Instance;
            TEMPModel tempM = TEMPModel.Instance;
            FUELModel fuelM = FUELModel.Instance;
            OILModel oilM = OILModel.Instance;
            TRIPModel tripM = TRIPModel.Instance;
            BATModel batM = BATModel.Instance;
            TimeModel timeM = TimeModel.Instance;
            GEARModel gearM = GEARModel.Instance;

            SolidColorBrush brush1 = new SolidColorBrush(Colors.Black);
            SolidColorBrush brush2 = new SolidColorBrush(Colors.LightSteelBlue);

            DigitalMPH digitalmph = new DigitalMPH(mphM, canvasMPH, brush1, 90, 75, 25, 20,2,true);
            DigitalRPM digitalrpm = new DigitalRPM(rpmM, canvasRPM, brush1, 9, 75, 25, 20, 2, true);
            DigitalFUEL digitalfuel = new DigitalFUEL(fuelM, canvasFuel, brush1, 20, 61, 12, 12, 1, false);
            DigitalOIL digitaloil = new DigitalOIL(oilM, canvasOil, brush1, 25, 12, 12, 12, 1, false);
            DigitalBAT digitalbat = new DigitalBAT(batM, canvasBat, brush1, 20, 12, 12, 12, 1, false);
            DigitalTEMP digitaltemp = new DigitalTEMP(tempM, canvasTemperature, brush1, 22, 61, 12, 12, 1, false);
            DigitalClock digitalclock = new DigitalClock(timeM, canvasTime, brush1, 0, 28, 12, 12, 1, false, true);
            DigitalOdometer odo = new DigitalOdometer(odoM, canvasODO, brush2, 20, 10, 7, 7, 1, false);
            DigitalTripometer trip = new DigitalTripometer(tripM, canvasTRIP, brush2, 20, 10, 7, 7, 1, false);

            //Note values are negative to trick the gauge into working backwards.

            GearIndicator gearLight = new GearIndicator();
            gearLight.addGearIndicator(gearPark, 0);
            gearLight.addGearIndicator(gearReverse, 1);
            gearLight.addGearIndicator(gearNeutral, 2);
            gearLight.addGearIndicator(gearDrive, 3);
            gearLight.addGearIndicator(gearThird, 4);
            gearLight.addGearIndicator(gearSecond, 5);
            gearM.RegisterObserver(gearLight);

            //            gaugeMPH.update(15);
            //            gaugeRPM.update(3.75);
            //            gaugeFuel.update(80);
            //            gaugeTemperature.update((-1 * 200));
            //            gaugeOil.update(70);
            //            gaugeBat.update((-1 * 67));

            //              mphM.RegisterObserver(digitalmph);
            //            rpmM.RegisterObserver(gaugeRPM);
            //            tempM.RegisterObserver(gaugeTemperature);
            //            fuelM.RegisterObserver(gaugeFuel);
            //            oilM.RegisterObserver(gaugeOil);
            //            batM.RegisterObserver(gaugeBat);
            //            timeM.RegisterObserver(gaugeTimeHour);
            //            timeM.RegisterObserver(gaugeTimeMinute);
            //            gearM.RegisterObserver(gearLight);
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: james276657/code
        private void createAnalogGauges()
        {
            MPHModel mphM = MPHModel.Instance;
            RPMModel rpmM = RPMModel.Instance;
            ODOModel odoM = ODOModel.Instance;
            TEMPModel tempM = TEMPModel.Instance;
            FUELModel fuelM = FUELModel.Instance;
            OILModel oilM = OILModel.Instance;
            TRIPModel tripM = TRIPModel.Instance;
            BATModel batM = BATModel.Instance;
            TimeModel timeM = TimeModel.Instance;
            GEARModel gearM = GEARModel.Instance;

            AnalogGauge gaugeMPH = new AnalogGauge(canvasMPH, 75, (Math.PI / 4), 0, 120, 12, true, true);
            AnalogGauge gaugeKMPH = new AnalogGauge(canvasKMPH, 70, (Math.PI / 4), 0, 180, 9, true, false);
            AnalogGauge gaugeRPM = new AnalogGauge(canvasRPM, 75, (Math.PI / 4), 0, 9, 9, true, true, RPMEllipse1,6, 7, 7, 10, Colors.White, Colors.Lime, Colors.OrangeRed);
            AnalogGauge gaugeFuel = new AnalogGauge(canvasFuel, 25, (Math.PI / 4), 0, 15, 2, false, true, fuelEllipse1, 0, .25, 5, 15, Colors.White, Colors.Orange, Colors.LightYellow);
            AnalogGauge gaugeOil = new AnalogGauge(canvasOil, 25, (Math.PI / 4), 0, 100, 2, false, true, oilEllipse1, 0, 20, 80, 100, Colors.White, Colors.OrangeRed, Colors.OrangeRed);
            AnalogGauge gaugeTimeHour = new AnalogGauge(canvasTime, 100, (-Math.PI / 2), 0, 12, 12, true, true);
            AnalogGauge gaugeTimeMinute = new AnalogGauge(canvasTime, 100, (-Math.PI / 2), 0, 60, 0, false, false);

            //Note values are negative to trick the gauge into working backwards.
            AnalogGauge gaugeTemperature = new AnalogGauge(canvasTemperature, 25, ((5 * Math.PI) / 4), -250, -100, 2, false, true, temperatureEllipse1, -120, -100, -250, -200, Colors.White, Colors.LightBlue, Colors.OrangeRed);
            AnalogGauge gaugeBat = new AnalogGauge(canvasBat, 25, ((5 * Math.PI) / 4), -26, 0, 1, false, false);

            DigitalOdometer odo = new DigitalOdometer(odoM, canvasODO);
            DigitalTripometer trip = new DigitalTripometer(tripM, canvasTRIP);

            GearIndicator gearLight = new GearIndicator();
            gearLight.addGearIndicator(gearPark, 0);
            gearLight.addGearIndicator(gearReverse, 1);
            gearLight.addGearIndicator(gearNeutral, 2);
            gearLight.addGearIndicator(gearDrive, 3);
            gearLight.addGearIndicator(gearThird, 4);
            gearLight.addGearIndicator(gearSecond, 5);

            gaugeMPH.update(15);
            gaugeRPM.update(3.75);
            gaugeFuel.update(80);
            gaugeTemperature.update((-1 * 200));
            gaugeOil.update(70);
            gaugeBat.update((-1 * 67));

            mphM.RegisterObserver(gaugeMPH);
            rpmM.RegisterObserver(gaugeRPM);
            tempM.RegisterObserver(gaugeTemperature);
            fuelM.RegisterObserver(gaugeFuel);
            oilM.RegisterObserver(gaugeOil);
            batM.RegisterObserver(gaugeBat);
            timeM.RegisterObserver(gaugeTimeHour);
            timeM.RegisterObserver(gaugeTimeMinute);
            gearM.RegisterObserver(gearLight);
        }