Inheritance: MonoBehaviour, IGameManager
Exemplo n.º 1
0
        static void Main()
        {
            // Create an instance of the GSM class
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-GB");
            Display display = new Display(2.5F, "256K");
            Battery battery = new Battery(950, 35, BatteryType.LiIon);
            GSM gsmTest = new GSM("Samsung Ace", "Samsung Group", 545.00M, "Ivan Ivanov", battery, display);

            //Add few calls
            DateTime date = DateTime.Now;
            gsmTest.AddCallInHistory(date, "0889909988", 65);
            gsmTest.AddCallInHistory(date.AddHours(1), "0889969988", 25);
            gsmTest.AddCallInHistory(date.AddHours(2), "0883909988", 3600);
            gsmTest.AddCallInHistory(date.AddHours(6.5), "0889969988", 1000);

            //Display the information about the calls.
            Console.WriteLine("Print the call hisory of phone {0}", gsmTest.ModelOfGSM);
            Console.WriteLine(gsmTest.PrintCallHistory());

            //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history
            //use readonly modificator about pricePerminute
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Total price of calls is: {0}", gsmTest.CalcucateTotalPrice(0.37M));

            Console.ForegroundColor = ConsoleColor.Gray;
            //Remove the longest call from the history and calculate the total price again.
            gsmTest.RemoveCallByLongestDuration();
            Console.WriteLine(gsmTest.PrintCallHistory());

            //Finally clear the call history and print it.
            gsmTest.ClearCallHistory();
            Console.WriteLine(gsmTest.PrintCallHistory());
        }
Exemplo n.º 2
0
    static void Main()
    {
        DateTime date1 = new DateTime(2013, 5, 24, 11, 11, 30);
        DateTime date2 = new DateTime(2013, 5, 24, 15, 23, 2);
        DateTime date3 = new DateTime(2013, 5, 31, 9, 00, 00);
        DateTime date4 = new DateTime(2013, 5, 31, 18, 12, 20);

        Call call1 = new Call(date1, "0888313233", 850);
        Call call2 = new Call(date2, "0888909090", 95);
        Call call3 = new Call(date3, "0889556677", 213);
        Call call4 = new Call(date4, "0888313233", 37);

        Battery battery = new Battery ("PX8", BatteryType.LiIon, 300, 8);
        Display display = new Display(4, 16000000);
        GSM gsm = new GSM("I900", "Samsung", 500, "Me", battery, display);

        gsm.AddCalls(call1);
        gsm.AddCalls(call2);
        gsm.AddCalls(call3);
        gsm.AddCalls(call4);

        foreach (var call in gsm.CallHistory)
        {
            Console.WriteLine(call);
        }

        Console.WriteLine("Total amount to pay: {0:C}",gsm.TotalCallsPrice);

        gsm.DeleteCalls(call1);
        Console.WriteLine("Total amount to pay: {0:C}", gsm.TotalCallsPrice);

        gsm.ClearHistory();
        Console.WriteLine("Total amount to pay: {0:C}", gsm.TotalCallsPrice);
    }
Exemplo n.º 3
0
 public GSM(string model, string manufacturer, decimal? price, string owner, Battery battery, Display display)
     : this(model, manufacturer, price)
 {
     this.owner = owner;
     this.Battery = battery;
     this.Display = display;
 }
Exemplo n.º 4
0
        public void AddBattery(Battery battery, List<Cart> list)
        {
            var cart = new Cart
            {
                GoodsId = battery.Id,
                GoodsCategory = "Batteries",
                Price = battery.Price,
                Count = 1
            };
            var flg = 1;
            foreach (Cart item in list)
            {
                if (item.GoodsId == battery.Id && item.GoodsCategory == "Batteries")
                {
                    item.Count++;
                    flg = 0;
                    break;

                }
            }
            if (flg == 1)
            {
                list.Add(cart);
            }
        }
        public BatteryData GetCurrentState()
        {
            if (battery == null)
            {
                battery = Battery.GetDefault();
            }

            BatteryData data = new BatteryData();
            data.BatteryLife = battery.RemainingChargePercent;
            TimeSpan dischargeTime = battery.RemainingDischargeTime;

            if (dischargeTime.Days < 1000)
            {
                data.BatteryLifeTime = battery.RemainingDischargeTime;
                data.BatteryState = BatteryState.Discharging;
            }
            else
            {
                // High discharge time means phone is charging.
                data.BatteryState = BatteryState.Charging;
            }

            // Notify only when values changes. GetCurrentState can be called manually.
            if (lastBatteryData == null || data.BatteryLife != lastBatteryData.BatteryLife || data.BatteryLifeTime != lastBatteryData.BatteryLifeTime || data.BatteryState != lastBatteryData.BatteryState)
            {
                BatteryStateChanged?.Invoke(this, new BatteryStateChangedEventArgs(data));
            }

            lastBatteryData = data;

            return data;
        }
Exemplo n.º 6
0
    public Laptop(string model,string manufacturer, string processor,
        int ram, string graphicCard, string hdd, double price, string batteryType, string batteryLife)
    {
        if (model == "" || manufacturer == "" ||
            processor == "" || graphicCard == "" || hdd == "")
        {
            throw new ArgumentException("Some empty laptop value except battery");
        }
        else if (ram < 0 || price < 0)
        {
            throw new ArgumentException("HDD space or price can't be negative");
        }
        else
        {
            this.model = model;
            this.manufacturer = manufacturer;
            this.processor = processor;
            this.ram = ram;
            this.graphicCard = graphicCard;
            this.hdd = hdd;
            this.price = price;

            this.battery = new Battery();
            this.battery.BatteryType = batteryType;
            this.battery.BatteryLife = batteryLife;
        }
    }
Exemplo n.º 7
0
        static void Main()
        {
            GSM[] mobilePhones = new GSM[3];

            GSM nokia = new GSM("3310", "Nokia");

            nokia.AddHistory(DateTime.Now, 0998080907, 1.08);
            nokia.AddHistory(DateTime.Now, 0998080907, 2132331.08);
            nokia.DeleteHistory(1);

            Battery sonyBattery5511 = new Battery("77ds7", 220, 10, BatteryType.NiMH);
            Display sonyDisplay5511 = new Display(23, 128);
            GSM sony = new GSM("5511", "Sony", 100.77m, "Pesho", sonyBattery5511, sonyDisplay5511);

            GSM samsung = new GSM("4433", "samsung", 50.22m, "Gosho");

            mobilePhones[0] = nokia;
            mobilePhones[1] = sony;
            mobilePhones[2] = samsung;

            //Console.WriteLine(nokia.CalcPriceHistory(2.2m));
            for (int i = 0; i < mobilePhones.Length; i++)
            {
                Console.WriteLine(mobilePhones[i]);
            }
        }
    static void Main()
    {
        Console.OutputEncoding = System.Text.Encoding.UTF8;

        Battery bat = new Battery(48, 49, "bat11");
        Display dis = new Display(48502);
        GSM phone1 = new GSM("5800", "Nokia", 850, null, bat, dis);
        Console.WriteLine(phone1.Battery.HoursTalk);
        Console.WriteLine(phone1.Display.Height);
        Console.WriteLine(phone1.Display.Colors);

        bat.BatteryType = BatteryType.NiCd;
        Console.WriteLine(bat.BatteryType);
        Battery bat2 = new Battery(48, 52, "dada", BatteryType.NiMH);
        Console.WriteLine(bat2.BatteryType);

        Console.WriteLine(phone1);

        Console.WriteLine();
        Console.WriteLine(GSM.Iphone4S);
        GSM phone2 = new GSM("Galaxy", "Samsung");

        GSM[] phones = new GSM[] {
            phone1,
            phone2
        };

        for (int i = 0; i < phones.Length; i++)
        {
            Console.WriteLine(phones[i]);
        }
    }
Exemplo n.º 9
0
 public Laptop(string model, string manufacturer, Battery elements, double price)
 {
     this.Model = model;
     this.Price = price;
     this.Manufacturer = manufacturer;
     this.SetElements(elements);
 }
Exemplo n.º 10
0
    static void Main()
    {
        var battery = new Battery("Li-Ion, 4-cells, 2550 mAh", "4.5 hours");
        var laptop = new Laptop("Lenovo Yoga 2 Pro", "2259.00 lv.", "Intel HD Graphics 4400", "128GB SSD", battery);

        Console.WriteLine(laptop.ToString());
    }
 public RechargeAction(EndeavourFactory factory, RobotController controller, List<Goal> goals, Dictionary<TagEnum, Tag> tagMap, Battery battery)
     : base(factory, controller, goals, tagMap)
 {
     powerStation = getTagOfType<Tag>(TagEnum.PowerStation);
     this.name = "recharge";
     this.battery = battery;
 }
        static void Main(string[] args)
        {
            try
            {
                //Create battery and display for the GSM
                Battery battery = new Battery("BL-5C",360,7,Battery.BatteryType.LithiumLon);
                Display display = new Display(3,65536);
                //Create GSM
                GSM gsm = new GSM("1208", "nokia", 50, "Georgi", battery, display);
                //Console.WriteLine(gsm.ToString()); //Print GSM data

                //Mace some calls and print the history
                gsm.AddCall(new Call(new DateTime(2013, 02, 22, 19, 01, 22), "00359888888888", 200));
                gsm.AddCall(new Call(new DateTime(2013,02,22,20,02,33),"0887888888",302));
                gsm.AddCall(new Call(new DateTime(2013, 02, 22, 20, 30, 19), "0889-88-88-88", 178));
                gsm.PrintCallHistiry();
                //Calculate the price of all calls
                decimal price = 0.37m;
                gsm.CalculateTotalCallsPrice(price);

                //Remove the longest call and calculate the price again
                gsm.DeleteCall(1); //The calls in the list start from 0, so the second call(longest) is 1
                gsm.CalculateTotalCallsPrice(price);

                //Clear the history and print it
                gsm.ClearCallHistory();
                gsm.PrintCallHistiry();

            }
            catch (Exception ex)
            {

                Console.WriteLine("Error!"+ex.Message);
            }
        }
Exemplo n.º 13
0
    static void Main(string[] args)
    {
        GSM[] gsmArray = new GSM[3];

            Battery myBattery = new Battery("Nokia", 50,50, BatteryType.LiIon);
            Display myDisplay = new Display(10, 1000000);
            GSM firstGsm = new GSM("N8", "Nokia", 500, "Me", myBattery, myDisplay);
            gsmArray[0] = firstGsm;

            myBattery = new Battery("Samsung", 60, 60, BatteryType.NiCd);
            myDisplay = new Display(12, 1200000);
            GSM secondGsm = new GSM("Galaxy", "Samsung", 700, "Me", myBattery, myDisplay);
            gsmArray[1] = secondGsm;

            myBattery = new Battery("HTC", 40, 40, BatteryType.NiMH);
            myDisplay = new Display(8, 800000);
            GSM thirdGsm = new GSM("K8", "HTC", 450, "Me", myBattery, myDisplay);
            gsmArray[2] = thirdGsm;

            foreach (var item in gsmArray)
            {
                Console.WriteLine(item);
                Console.WriteLine();
            }
            Console.WriteLine(GSM.IPhone4S);

            GSMCallHistoryTest.Test();
    }
Exemplo n.º 14
0
    private static void Main()
    {
        // Generate some test batteries and displays
        var premiumDisplay = new Display(4.5, Display.ColorDepth._32Bit);
        var mediocreDisplay = new Display(3.5, Display.ColorDepth._16Bit);
        var poorDisplay = new Display(2.5, Display.ColorDepth._8bit);
        var premiumBattery = new Battery("Sanyo-SN532e", 120, 20, Battery.Type.LiPol);
        var mediocreBattery = new Battery("Shanzungmang-2341", 80, 15, Battery.Type.LiIon);
        var poorBattery = new Battery("Mistucura-1224fe", 40, 5, Battery.Type.NiMH);

        // initilize gsms in the array
        var gsmArray = new GSM[4];
        gsmArray[0] = new GSM("One", "HTC", "Kiro", premiumDisplay, premiumBattery, 200);
        gsmArray[1] = new GSM("Blade", "Zte");
        gsmArray[2] = new GSM("Galaxy S4", "Samsung", "Misho", premiumDisplay, mediocreBattery, 1000);
        gsmArray[3] = new GSM("Ascend G600", "Huawei",  "Mtel", premiumDisplay, 
            new Battery("Toshiba-tbsae", 380, 6, Battery.Type.LiPol), 600);

        // print the gsms
        foreach (var phone in gsmArray)
        {
            Console.WriteLine(phone);
        }

        // print the static property Iphone4S
        Console.WriteLine(GSM.Iphone4S);

        // test GsmCallHistory
        GSMCallHistoryTest.Test();
    }
Exemplo n.º 15
0
 static void Main()
 {
     Display testDisplay = new Display(14, 16.5f);
         Battery testBattery = new Battery("test");
         GSM myPhone = new GSM("test", "test", "Owner",1234, testBattery, testDisplay);
         Console.WriteLine(myPhone.display.Size);
 }
        public void CreatingBatterytWithValidDataShouldSetAllPropertiesCorrectly()
        {
            var battery = new Battery("8 cells", 4.5);

            Assert.AreEqual("8 cells", battery.Description, "Battery description name is set wrong");
            Assert.AreEqual(4.5, battery.LifeInHours, "Battery life in hours description is set wrong");
        }
Exemplo n.º 17
0
 public Laptop(string model, string price, string graphicsCard, string hdd, Battery battery)
     : this(model, price)
 {
     this.GraphicsCard = graphicsCard;
     this.HDD = hdd;
     this.Battery = battery;
 }
Exemplo n.º 18
0
    static void Main()
    {
        GSM gsm = new GSM("nokia", "nokiaman");
        GSM gsm1 = new GSM("nokia", "nok", 9.5m);
        Battery bat = new Battery("monbat", 500, 100, BatteryType.NiMH);
        Display dis = new Display(null, 256);

        GSM gsm2 = new GSM("erik", "erik", bat);
        GSM gsm3 = new GSM("koko", "ka", dis);

        Console.WriteLine(gsm.ToString());
        Console.WriteLine("-----");
        Console.WriteLine(gsm1.ToString());
        Console.WriteLine("-----");
        Console.WriteLine(gsm2.ToString());
        Console.WriteLine("-----");
        Console.WriteLine(gsm3.ToString());

        Console.WriteLine("---------------------------");

        GSM p = GSM.IPhone4S;
        p.Owner = "pesho";
        p.Battery = bat;
        Console.WriteLine(p.ToString());

        GSMCallHistoryTest.Test();




    }
Exemplo n.º 19
0
 //initialize the static iPhone GSM
 static GSM()
 {
     DisplaySize iPhoneDisplaySize = new DisplaySize(1136, 640);
     Display iPhoneDisplay = new Display(32000, iPhoneDisplaySize);
     Battery iPhoneBattery = new Battery("Samsung", 24, 24, BatteryType.LiIon);
     iPhone4S = new GSM("4S", "Apple", 1000000, iPhoneDisplay, iPhoneBattery);
 }
Exemplo n.º 20
0
 //full specs without owner
 public GSM(string model, string manufacturer, decimal price, Battery battery, Display display)
     : this(model, manufacturer, price)
 {
     this.Battery = battery;
     this.Display = display;
     this.Owner = null;
 }
        public void updateBatteries()
        {
            //Create a Dictionary to hold the batteries saved in the database
            Dictionary<string, Battery> batteries = new Dictionary<string, Battery>();

            //Create a new connection to the database
            using (SQLiteConnection m_dbConnection = new SQLiteConnection(@"Data Source=database.sqlite;Version=3;"))
            {
                //Open database connection
                m_dbConnection.Open();


                using (SQLiteCommand command = m_dbConnection.CreateCommand())
                {
                    //Select everything from the 'batteries' table
                    SQLiteCommand getBatteries = new SQLiteCommand("SELECT * FROM batteries", m_dbConnection);
                    SQLiteDataReader reader = getBatteries.ExecuteReader();

                    //Read every entry in the batteries table
                    while (reader.Read())
                    {
                        string name = (string)reader["name"];
                        Battery battery = new Battery((string)reader["name"], (int)reader["weight"], (int)reader["capacity"], (string)reader["configuration"], (int)reader["discharge"], (int)reader["peakDischarge"]);
                        //Add the battery into the dictionary using the name as the key and a new Battery object as the value
                        batteries.Add(name, battery);
                    }
                }
                //Close the database connection
                m_dbConnection.Close();
            }
            //Save the updated savedBattery list 
            savedBatteries = batteries;
        }
Exemplo n.º 22
0
    static void Main()
    {
        //creating array of GSM phones, adding info about them
        Console.WriteLine("Mobile phones: ",  Console.ForegroundColor = ConsoleColor.Red);
        GSM[] telephones = new GSM[3];
        Console.ForegroundColor = ConsoleColor.Gray;
        Battery battery = new Battery("helolModel", 1500, 1000, BatteryType.LiIon);
        Display display = new Display("100x85", 256);

        GSM phoneOne = new GSM("s400", "Samsung", 500, "Rosen", battery, display);
        GSM phoneTwo = new GSM("Duos", "Samsung", 500, "Joro", battery, display);
        GSM phoneThree = new GSM("s800", "Samsung", 500, "Tanq", battery, display);

        telephones[0] = phoneOne;
        telephones[1] = phoneTwo;
        telephones[2] = phoneThree;

        //print the info for each phone from the array
        for (int i = 0; i < telephones.Length; i++)
        {
            Console.WriteLine(telephones[i]);
        }

        Console.WriteLine(GSM.IPhone4S.Model);
        Console.WriteLine(GSM.IPhone4S.Manufacturer);
        Console.WriteLine("\nHistory information: \n",
        Console.ForegroundColor = ConsoleColor.Red);
        //go to next Test.cs class
        GSMCallHistoryTest.Main2();
    }
Exemplo n.º 23
0
	// Use this for initialization
	void Start () {

        float x = transform.position.x;
        float y = transform.position.y;

		battery = new Battery (x,y, FindObjectOfType<LevelScript>().Level.Timer);
	}
Exemplo n.º 24
0
 public Battery(Battery battery)
 {
     this.model = battery.model;
     this.hoursTalk = battery.hoursIdle;
     this.hoursTalk = battery.hoursTalk;
     this.batteryType = battery.batteryType;
 }
Exemplo n.º 25
0
        static void Main()
        {
            const decimal PricePerMinute = 0.37m;
            //Array of 5 phones
            GSM[] phones = new GSM[5];
            // Different types of batteries and displays
            Battery battery1 = new Battery(Battery.BatteryType.NiMH, 50, 10);
            Battery battery2 = new Battery(Battery.BatteryType.LiIon, 40, 5);
            Battery battery3 = new Battery(Battery.BatteryType.ZnChl, 100, 40);
            Display display1 = new Display(5.0, 1000000);
            Display display2 = new Display(5.5, 103530050);
            Display display3 = new Display(4, 425324);

            //Some phones created
            phones[0] = new GSM("Samsung Galaxy S4", "Samsung" , 1444.44 , "Pesho Ivanov" , battery: battery1 , display: display1);
            phones[1] = new GSM("iPhone 5", "Apple", 1500, "Bill Gates", battery: battery2, display: display3);
            phones[2] = new GSM("HTC One X", "HTC", 1200, "Someone Else", battery: battery3);
            phones[3] = new GSM("Nokia 3310", "Nokia",null,null,null,display: display2);
            phones[4] = GSM.PIPhone4S;

            //Using the class GSMtest we print all the phones using method
            Console.WriteLine("PHONES:");
            Console.WriteLine();
            GSMTest gsmTestPrint = new GSMTest();
            gsmTestPrint.PrintAllPhones(phones);

            Console.WriteLine("CALLS:");
            Console.WriteLine();
            //For the first phone we create call history
            phones[0].CallHistory = new CallHistory();
            CallHistory history = phones[0].CallHistory;
            //Adding 4 calls with different params
            Call testCall1 = new Call(DateTime.Now.AddHours(2), 450, 532423);
            Call testCall2 = new Call(DateTime.UtcNow, 440, 12532423);
            Call testCall3 = new Call(DateTime.MinValue, 29, 94532423);
            Call testCall4 = new Call(DateTime.MaxValue, 90, 3532423);
            history.AddCall(testCall1);
            history.AddCall(testCall2);
            history.AddCall(testCall3);
            history.AddCall(testCall4);
            //Then we test the history
            GSMCallHistoryTest callHistoryTest = new GSMCallHistoryTest(phones[0].CallHistory);
            //We print the list  and then the first calculated price
            callHistoryTest.PrintList();
            callHistoryTest.PrintCalculatedPrice(PricePerMinute);
            //Then we remove the longest call and print the total price again
            callHistoryTest.RemoveLongestCall();
            callHistoryTest.PrintCalculatedPrice(PricePerMinute);
            //Then we remove a call on position in the list - 1  and print the price we have to pay again
            callHistoryTest.RemoveCallTest(position:1);
            callHistoryTest.PrintCalculatedPrice(PricePerMinute);
            //We print the remaining calls on the list to show it's not empty yet
            Console.WriteLine();
            Console.WriteLine("The remaining items on the call list:");
            callHistoryTest.PrintList();
            //Finally we clear the list and print it
            callHistoryTest.ClearList();
            callHistoryTest.PrintList();
        }
Exemplo n.º 26
0
 public GSM(string model, string manufacturer, decimal? price, Display displayInfo, Battery batteryInfo)
 {
     this.Model = model;
     this.Manufacturer = manufacturer;
     this.Price = price;
     this.DisplayInfo = displayInfo;
     this.BatteryInfo = new Battery(batteryInfo);
 }
 // call the first constructor, did it just to try the syntaxix
 /// <summary>
 /// Initializes a new instance of the GSM class with the given parameters. Model and manufacturer are mandatory.
 /// </summary>
 /// <param name="model"></param>
 /// <param name="manufacturer"></param>
 /// <param name="owner"></param>
 /// <param name="price"></param>
 /// <param name="battery"></param>
 /// <param name="display"></param>
 public GSM(string model, string manufacturer, string owner = null, decimal? price = null, Battery battery = null, Display display = null)
     : this(model, manufacturer)
 {
     this.gsmBattery = battery;
     this.gsmDisplay = display;
     this.Price = price;
     this.Owner = owner;
 }
Exemplo n.º 28
0
 public GSM(Models model, string manufacturer, int price, Battery battery,Display display)
 {
     this.model = model;
     this.manufacturer = manufacturer;
     this.price = price;
     this.battery = battery;
     this.display = display;
 }
Exemplo n.º 29
0
 public RechargeAction(RobotController controller, List<Goal> goals, Label target, Battery battery)
     : base(controller, goals, target.labelHandle)
 {
     powerStation = target;
     this.name = "recharge";
     requiredComponents = new System.Type[] { typeof(HoverJet) };
     this.battery = battery;
 }
Exemplo n.º 30
0
 public GSM(string model, string manufacturer, double? price, string owner, Battery battery, Display display)
 {
     this.Model = model;
     this.Manufacturer = manufacturer;
     this.Price = price;
     this.Owner = owner;
     this.Battery = battery;
     this.Display = display;
 }
Exemplo n.º 31
0
 public SmartWatch(int ID, decimal price, bool isAvailable, Brand brand, int Memory, string CPU, int RAM, string Model, Battery battery, string connectivity, bool ExpandableMemory, double ScreenSize, double Size, bool WaterResistance)
     : base(ID, price, isAvailable, brand, Memory, CPU, RAM, Model, battery, connectivity, ExpandableMemory, ScreenSize)
 {
     this.Size            = Size;
     this.WaterResistance = WaterResistance;
 }
        public void BatteryLifeInHoursShouldBeZeroWhenNotSet()
        {
            var battery = new Battery("8 cells");

            Assert.AreEqual(0, battery.LifeInHours);
        }
 public Phone(string model, string manifactuor, int price, string owner, Battery battery, Display display)
     : this(model, manifactuor, price, owner)
 {
     this.battery = battery;
     this.display = display;
 }
Exemplo n.º 34
0
 public Laptop(string model, double price, string manufacturer, string cpu, string ram, string gpu, string hdd, Battery battery, string screen)
     : this(model, price)
 {
     this.Manufacturer = manufacturer;
     this.CPU          = cpu;
     this.RAM          = ram;
     this.GPU          = gpu;
     this.HDD          = hdd;
     this.Battery      = battery;
     this.Screen       = screen;
 }
Exemplo n.º 35
0
        private void SetCellVoltages(Battery battery, uint voltages)
        {
            uint baseCanId = 0x601;

            CanPacket PCBcanPacket = new CanPacket(baseCanId);

            PCBcanPacket.SetInt16(2, 520);  // PCB Temp
            PCBcanPacket.SetInt16(3, 320);  // PCB Temp

            CanPacket Battery1canPacket1 = new CanPacket(baseCanId + 1);

            Battery1canPacket1.SetUint16(0, voltages);
            Battery1canPacket1.SetUint16(1, voltages);
            Battery1canPacket1.SetUint16(2, voltages);
            Battery1canPacket1.SetUint16(3, voltages);

            CanPacket Battery1canPacket2 = new CanPacket(baseCanId + 2);

            Battery1canPacket2.SetUint16(0, voltages);
            Battery1canPacket2.SetUint16(1, voltages);
            Battery1canPacket2.SetUint16(2, voltages);
            Battery1canPacket2.SetUint16(3, voltages);

            if (battery.GetBMU(0) != null)
            {
                battery.GetBMU(0).GetCMU(0).TestCanPacketReceived(PCBcanPacket);
            }
            if (battery.GetBMU(0) != null)
            {
                battery.GetBMU(0).GetCMU(0).TestCanPacketReceived(Battery1canPacket1);
            }
            if (battery.GetBMU(0) != null)
            {
                battery.GetBMU(0).GetCMU(0).TestCanPacketReceived(Battery1canPacket2);
            }

            baseCanId = 0x201;

            CanPacket PCBcanPacket2 = new CanPacket(baseCanId);

            PCBcanPacket.SetInt16(2, 520);  // PCB Temp
            PCBcanPacket.SetInt16(3, 320);  // PCB Temp

            CanPacket Battery2canPacket1 = new CanPacket(baseCanId + 1);

            Battery2canPacket1.SetUint16(0, voltages);
            Battery2canPacket1.SetUint16(1, voltages);
            Battery2canPacket1.SetUint16(2, voltages);
            Battery2canPacket1.SetUint16(3, voltages);

            CanPacket Battery2canPacket2 = new CanPacket(baseCanId + 2);

            Battery2canPacket2.SetUint16(0, voltages);
            Battery2canPacket2.SetUint16(1, voltages);
            Battery2canPacket2.SetUint16(2, voltages);
            Battery2canPacket2.SetUint16(3, voltages);

            if (battery.GetBMU(1) != null)
            {
                battery.GetBMU(1).GetCMU(0).TestCanPacketReceived(PCBcanPacket2);
            }
            if (battery.GetBMU(1) != null)
            {
                battery.GetBMU(1).GetCMU(0).TestCanPacketReceived(Battery2canPacket1);
            }
            if (battery.GetBMU(1) != null)
            {
                battery.GetBMU(1).GetCMU(0).TestCanPacketReceived(Battery2canPacket2);
            }
        }
Exemplo n.º 36
0
 private BatteryResponse(bool success, string message, Battery battery) : base(success, message)
 {
     Battery = battery;
 }
Exemplo n.º 37
0
 public BatteryDetails(Equipment parentEquipment, string slotName, Battery batteryRef)
 {
     ParentEquipment = parentEquipment;
     SlotName        = slotName;
     BatteryRef      = batteryRef;
 }
    private TemplateContainer GetSelectionAsAsset()
    {
        List <Cell>          list  = new List <Cell>();
        List <Prefab>        list2 = new List <Prefab>();
        List <Prefab>        list3 = new List <Prefab>();
        List <Prefab>        _primaryElementOres = new List <Prefab>();
        List <Prefab>        _otherEntities      = new List <Prefab>();
        HashSet <GameObject> _excludeEntities    = new HashSet <GameObject>();
        float num  = 0f;
        float num2 = 0f;

        foreach (int selectedCell in SelectedCells)
        {
            float    num3     = num;
            Vector2I vector2I = Grid.CellToXY(selectedCell);
            num = num3 + (float)vector2I.x;
            float    num4      = num2;
            Vector2I vector2I2 = Grid.CellToXY(selectedCell);
            num2 = num4 + (float)vector2I2.y;
        }
        float x    = num / (float)SelectedCells.Count;
        float y    = num2 /= (float)SelectedCells.Count;
        int   cell = Grid.PosToCell(new Vector3(x, y, 0f));

        Grid.CellToXY(cell, out int x2, out int y2);
        for (int i = 0; i < SelectedCells.Count; i++)
        {
            int i2 = SelectedCells[i];
            Grid.CellToXY(SelectedCells[i], out int x3, out int y3);
            Element element     = ElementLoader.elements[Grid.ElementIdx[i2]];
            string  diseaseName = (Grid.DiseaseIdx[i2] == 255) ? null : Db.Get().Diseases[Grid.DiseaseIdx[i2]].Id;
            list.Add(new Cell(x3 - x2, y3 - y2, element.id, Grid.Temperature[i2], Grid.Mass[i2], diseaseName, Grid.DiseaseCount[i2], Grid.PreventFogOfWarReveal[SelectedCells[i]]));
        }
        for (int j = 0; j < Components.BuildingCompletes.Count; j++)
        {
            BuildingComplete buildingComplete = Components.BuildingCompletes[j];
            if (!_excludeEntities.Contains(buildingComplete.gameObject))
            {
                Grid.CellToXY(Grid.PosToCell(buildingComplete), out int x4, out int y4);
                if (SaveAllBuildings || SelectedCells.Contains(Grid.PosToCell(buildingComplete)))
                {
                    int[]  placementCells = buildingComplete.PlacementCells;
                    string diseaseName2;
                    foreach (int num5 in placementCells)
                    {
                        Grid.CellToXY(num5, out int x5, out int y5);
                        diseaseName2 = ((Grid.DiseaseIdx[num5] == 255) ? null : Db.Get().Diseases[Grid.DiseaseIdx[num5]].Id);
                        list.Add(new Cell(x5 - x2, y5 - y2, Grid.Element[num5].id, Grid.Temperature[num5], Grid.Mass[num5], diseaseName2, Grid.DiseaseCount[num5], false));
                    }
                    Orientation rotation  = Orientation.Neutral;
                    Rotatable   component = buildingComplete.gameObject.GetComponent <Rotatable>();
                    if ((UnityEngine.Object)component != (UnityEngine.Object)null)
                    {
                        rotation = component.GetOrientation();
                    }
                    SimHashes element2 = SimHashes.Void;
                    float     value    = 280f;
                    diseaseName2 = null;
                    int            disease_count = 0;
                    PrimaryElement component2    = buildingComplete.GetComponent <PrimaryElement>();
                    if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
                    {
                        element2      = component2.ElementID;
                        value         = component2.Temperature;
                        diseaseName2  = ((component2.DiseaseIdx == 255) ? null : Db.Get().Diseases[component2.DiseaseIdx].Id);
                        disease_count = component2.DiseaseCount;
                    }
                    List <Prefab.template_amount_value> list4 = new List <Prefab.template_amount_value>();
                    List <Prefab.template_amount_value> list5 = new List <Prefab.template_amount_value>();
                    foreach (AmountInstance amount in buildingComplete.gameObject.GetAmounts())
                    {
                        list4.Add(new Prefab.template_amount_value(amount.amount.Id, amount.value));
                    }
                    float   num6       = 0f;
                    Battery component3 = buildingComplete.GetComponent <Battery>();
                    if ((UnityEngine.Object)component3 != (UnityEngine.Object)null)
                    {
                        num6 = component3.JoulesAvailable;
                        list5.Add(new Prefab.template_amount_value("joulesAvailable", num6));
                    }
                    float      num7       = 0f;
                    Unsealable component4 = buildingComplete.GetComponent <Unsealable>();
                    if ((UnityEngine.Object)component4 != (UnityEngine.Object)null)
                    {
                        num7 = (float)(component4.facingRight ? 1 : 0);
                        list5.Add(new Prefab.template_amount_value("sealedDoorDirection", num7));
                    }
                    float       num8       = 0f;
                    LogicSwitch component5 = buildingComplete.GetComponent <LogicSwitch>();
                    if ((UnityEngine.Object)component5 != (UnityEngine.Object)null)
                    {
                        num8 = (float)(component5.IsSwitchedOn ? 1 : 0);
                        list5.Add(new Prefab.template_amount_value("switchSetting", num8));
                    }
                    x4   -= x2;
                    y4   -= y2;
                    value = Mathf.Clamp(value, 1f, 99999f);
                    Prefab  prefab     = new Prefab(buildingComplete.PrefabID().Name, Prefab.Type.Building, x4, y4, element2, value, 0f, diseaseName2, disease_count, rotation, list4.ToArray(), list5.ToArray(), 0);
                    Storage component6 = buildingComplete.gameObject.GetComponent <Storage>();
                    if ((UnityEngine.Object)component6 != (UnityEngine.Object)null)
                    {
                        foreach (GameObject item2 in component6.items)
                        {
                            float          units          = 0f;
                            SimHashes      element3       = SimHashes.Vacuum;
                            float          temp           = 280f;
                            string         disease        = null;
                            int            disease_count2 = 0;
                            bool           isOre          = false;
                            PrimaryElement component7     = item2.GetComponent <PrimaryElement>();
                            if ((UnityEngine.Object)component7 != (UnityEngine.Object)null)
                            {
                                units          = component7.Units;
                                element3       = component7.ElementID;
                                temp           = component7.Temperature;
                                disease        = ((component7.DiseaseIdx == 255) ? null : Db.Get().Diseases[component7.DiseaseIdx].Id);
                                disease_count2 = component7.DiseaseCount;
                            }
                            float             rotAmount = 0f;
                            Rottable.Instance sMI       = item2.gameObject.GetSMI <Rottable.Instance>();
                            if (sMI != null)
                            {
                                rotAmount = sMI.RotValue;
                            }
                            ElementChunk component8 = item2.GetComponent <ElementChunk>();
                            if ((UnityEngine.Object)component8 != (UnityEngine.Object)null)
                            {
                                isOre = true;
                            }
                            StorageItem storageItem = new StorageItem(item2.PrefabID().Name, units, temp, element3, disease, disease_count2, isOre);
                            if (sMI != null)
                            {
                                storageItem.rottable.rotAmount = rotAmount;
                            }
                            prefab.AssignStorage(storageItem);
                            _excludeEntities.Add(item2);
                        }
                    }
                    list2.Add(prefab);
                    _excludeEntities.Add(buildingComplete.gameObject);
                }
            }
        }
        for (int l = 0; l < list2.Count; l++)
        {
            Prefab prefab2 = list2[l];
            int    x6      = prefab2.location_x + x2;
            int    y6      = prefab2.location_y + y2;
            int    cell2   = Grid.XYToCell(x6, y6);
            switch (prefab2.id)
            {
            default:
                prefab2.connections = 0;
                break;

            case "Wire":
            case "InsulatedWire":
            case "HighWattageWire":
                prefab2.connections = (int)Game.Instance.electricalConduitSystem.GetConnections(cell2, true);
                break;

            case "GasConduit":
            case "InsulatedGasConduit":
                prefab2.connections = (int)Game.Instance.gasConduitSystem.GetConnections(cell2, true);
                break;

            case "LiquidConduit":
            case "InsulatedLiquidConduit":
                prefab2.connections = (int)Game.Instance.liquidConduitSystem.GetConnections(cell2, true);
                break;

            case "LogicWire":
                prefab2.connections = (int)Game.Instance.logicCircuitSystem.GetConnections(cell2, true);
                break;
            }
        }
        for (int m = 0; m < Components.Pickupables.Count; m++)
        {
            if (Components.Pickupables[m].gameObject.activeSelf)
            {
                Pickupable pickupable = Components.Pickupables[m];
                if (!_excludeEntities.Contains(pickupable.gameObject))
                {
                    int num9 = Grid.PosToCell(pickupable);
                    if ((SaveAllPickups || SelectedCells.Contains(num9)) && !(bool)Components.Pickupables[m].gameObject.GetComponent <MinionBrain>())
                    {
                        Grid.CellToXY(num9, out int x7, out int y7);
                        x7 -= x2;
                        y7 -= y2;
                        SimHashes         element4       = SimHashes.Void;
                        float             temperature    = 280f;
                        float             units2         = 1f;
                        string            disease2       = null;
                        int               disease_count3 = 0;
                        float             rotAmount2     = 0f;
                        Rottable.Instance sMI2           = pickupable.gameObject.GetSMI <Rottable.Instance>();
                        if (sMI2 != null)
                        {
                            rotAmount2 = sMI2.RotValue;
                        }
                        PrimaryElement component9 = pickupable.gameObject.GetComponent <PrimaryElement>();
                        if ((UnityEngine.Object)component9 != (UnityEngine.Object)null)
                        {
                            element4       = component9.ElementID;
                            units2         = component9.Units;
                            temperature    = component9.Temperature;
                            disease2       = ((component9.DiseaseIdx == 255) ? null : Db.Get().Diseases[component9.DiseaseIdx].Id);
                            disease_count3 = component9.DiseaseCount;
                        }
                        ElementChunk component10 = pickupable.gameObject.GetComponent <ElementChunk>();
                        if ((UnityEngine.Object)component10 != (UnityEngine.Object)null)
                        {
                            Prefab item = new Prefab(pickupable.PrefabID().Name, Prefab.Type.Ore, x7, y7, element4, temperature, units2, disease2, disease_count3, Orientation.Neutral, null, null, 0);
                            _primaryElementOres.Add(item);
                        }
                        else
                        {
                            Prefab item = new Prefab(pickupable.PrefabID().Name, Prefab.Type.Pickupable, x7, y7, element4, temperature, units2, disease2, disease_count3, Orientation.Neutral, null, null, 0);
                            item.rottable           = new TemplateClasses.Rottable();
                            item.rottable.rotAmount = rotAmount2;
                            list3.Add(item);
                        }
                        _excludeEntities.Add(pickupable.gameObject);
                    }
                }
            }
        }
        GetEntities(Components.Crops.Items, x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities);
        GetEntities(Components.Health.Items, x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities);
        GetEntities(Components.Harvestables.Items, x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities);
        GetEntities(Components.Edibles.Items, x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities);
        GetEntities <Geyser>(x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities);
        GetEntities <OccupyArea>(x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities);
        GetEntities <FogOfWarMask>(x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities);
        TemplateContainer templateContainer = new TemplateContainer();

        templateContainer.Init(list, list2, list3, _primaryElementOres, _otherEntities);
        return(templateContainer);
    }
Exemplo n.º 39
0
 public void Charge(Battery battery)
 {
     Output.WriteLine($"Chraging {battery.Capacity}mAh battery. Ready in {battery.Capacity / Math.Min(battery.ChargingVoltage, Voltage)} hours.");
 }
Exemplo n.º 40
0
 public async Task AddAsync(Battery battery)
 {
     await _context.Batteries.AddAsync(battery);
 }
Exemplo n.º 41
0
 public void Remove(Battery battery)
 {
     _context.Batteries.Remove(battery);
 }
Exemplo n.º 42
0
        /// <summary>
        /// Method invoked once navigated to the page.
        /// Loads app settings state and checks if Windows Hello is available in the system.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (ApplicationData.Current.LocalSettings.Values.ContainsKey("HelloAuthenticationEnabled"))
            {
                WindowsHelloCheckBox.IsChecked = true;
            }

            if (!await KeyCredentialManager.IsSupportedAsync())
            {
                WindowsHelloCheckBox.IsEnabled       = false;
                WindowsHelloRelativePanel.Visibility = Visibility.Visible;
            }
            else
            {
                WindowsHelloRelativePanel.Visibility = Visibility.Collapsed;
            }

            DeviceInformationCollection batteryCollection = await DeviceInformation.FindAllAsync(Battery.GetDeviceSelector());

            BatterySaverRelativePanel.Visibility = batteryCollection.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
        }
Exemplo n.º 43
0
 public static int GetBatteryHolderCount(this KMBombInfo bombInfo, Battery batteryType)
 {
     return(GetBatteryHolderCount(bombInfo, (int)batteryType));
 }
Exemplo n.º 44
0
 public static string GetBatteryName(this Battery battery)
 {
     return(battery?.Name ?? "none");
 }
Exemplo n.º 45
0
 /// <summary>
 /// Event that is triggered when the battery report changes.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="args">The event arguments.</param>
 private async void OnBatteryReportUpdated(Battery sender, object args)
 {
     await UpdateStatus();
 }
Exemplo n.º 46
0
    void OnGUI()
    {
        if (debug)
        {
            Camera  cam = Camera.current;
            Vector3 pos;
            if (cam != null)
            {
                Vector3 worldTextPos = transform.position + new Vector3(0, 1, 0);
                pos = cam.WorldToScreenPoint(worldTextPos);
                if (Vector3.Dot(cam.transform.forward, (worldTextPos - cam.transform.position).normalized) < 0)
                {
                    return;
                }
            }
            else
            {
                return;
            }

            while (lines.Count > 8)
            {
                lines.RemoveAt(0);
            }

            GUI.enabled = true;
            string buffer = "";
            for (int i = 0; i < lines.Count; i++)
            {
                buffer += "\n";
            }


            Texture2D red            = new Texture2D(1, 1);
            Color     transparentRed = new Color(0f, .0f, .0f, .4f);

            red.SetPixel(0, 0, transparentRed);
            red.Apply();

            Texture2D blue            = new Texture2D(1, 1);
            Color     transparentBlue = new Color(.1f, .1f, 1f, .6f);
            blue.SetPixel(0, 0, transparentBlue);
            blue.alphaIsTransparency = true;

            blue.Apply();

            Texture2D green            = new Texture2D(1, 1);
            Color     transparentGreen = new Color(.1f, 1f, .1f, .4f);
            green.SetPixel(0, 0, transparentGreen);
            green.alphaIsTransparency = true;

            green.Apply();

            float   lineHeight = 30f;
            Vector2 size       = new Vector2(200, lines.Count * lineHeight);
            for (int i = 0; i < lines.Count; ++i)
            {
                DecisionInfoObject obj = lines[i];
                float percentFilled    = 0;

                percentFilled = (Mathf.Abs(obj.getPriority()) / (maxPriority));
                if (obj.getPriority() < 0)
                {
                    percentFilled = -percentFilled;
                }

                Rect rectng = new Rect(pos.x - size.x / 2, Screen.height - pos.y - size.y + (i * lineHeight), size.x, lineHeight);

                GUI.skin.box.normal.background = red;

                GUI.Box(rectng, GUIContent.none);

                Rect filled;
                if (percentFilled < 0)
                {
                    filled = new Rect(pos.x + ((size.x / 2) * percentFilled), Screen.height - pos.y - size.y + (i * lineHeight), -((size.x / 2) * percentFilled), lineHeight);
                }
                else
                {
                    filled = new Rect(pos.x, Screen.height - pos.y - size.y + (i * lineHeight), (size.x / 2) * (percentFilled), lineHeight);
                }

                //GUI.skin.box.normal.background = green;
                //GUI.Box(filled, GUIContent.none);
                GUI.DrawTexture(filled, blue);
                //if(obj.isChosen()) {
                //	GUI.Label(textCentered, "+" + obj.getTitle());
                //} else {
                //}
                Rect boxRectangle = new Rect(pos.x - size.x / 2, Screen.height - pos.y - size.y + (i * lineHeight) + lineHeight / 4, 15, 15);
                if (obj.isChosen())
                {
                    GUI.DrawTexture(boxRectangle, green);
                }
                else
                {
                    GUI.DrawTexture(boxRectangle, red);
                }

                Rect textCentered = new Rect(pos.x - size.x / 2 + 17, Screen.height - pos.y - size.y + (i * lineHeight) + 4, size.x, lineHeight);
                GUI.Label(textCentered, obj.getTitle());


                Font     font  = UnityEditor.AssetDatabase.LoadAssetAtPath <Font>("Assets/GUI/Courier.ttf");
                GUIStyle style = new GUIStyle(GUI.skin.label);
                style.font     = font;
                style.fontSize = 14;

                string  priorityString = obj.getPriority().ToString("0.#0").PadLeft(7);
                Vector2 labelSize      = style.CalcSize(new GUIContent(priorityString));
                //Rect center = new Rect(pos.x - labelSize.x/2 - 7, Screen.height - pos.y - size.y + (i * lineHeight), labelSize.x, labelSize.y);
                Rect center = new Rect(pos.x + size.x / 2 - labelSize.x, Screen.height - pos.y - size.y + (i * lineHeight), labelSize.x, labelSize.y);
                GUI.Label(center, priorityString, style);

                string  sourceString     = obj.getSource();
                Vector2 sourceStringSize = style.CalcSize(new GUIContent(sourceString));
                Rect    sourceRect       = new Rect(pos.x + size.x / 2 - sourceStringSize.x, Screen.height - pos.y - size.y + (i * lineHeight) + lineHeight / 2, sourceStringSize.x, sourceStringSize.y);
                GUI.Label(sourceRect, sourceString, style);
            }

            /*
             * Draw the battery meter
             */
            Battery battery = GetComponentInChildren <Battery>();
            if (battery != null)
            {
                Rect progressBar = new Rect(pos.x - size.x / 2, Screen.height - pos.y + 3, size.x, 20);

                GUI.skin.box.normal.background = red;
                GUI.Box(progressBar, GUIContent.none);

                GUI.skin.box.normal.background = green;

                Rect progressBarFull = new Rect(pos.x - size.x / 2, Screen.height - pos.y + 3, size.x * (battery.currentCapacity / battery.maximumCapacity), 20);
                GUI.Box(progressBarFull, GUIContent.none);
            }
        }
    }
Exemplo n.º 47
0
 /// <summary>
 /// Creates a success response.
 /// </summary>
 /// <param name="battery">Saved battery.</param>
 /// <returns>Response.</returns>
 public BatteryResponse(Battery battery) : this(true, string.Empty, battery)
 {
 }
Exemplo n.º 48
0
        public void BatteryCharacteristics()
        {
            Battery battery = new Battery();

            Console.WriteLine(battery);
        }
Exemplo n.º 49
0
    void RepairAircraft()
    {
        FlightAssist flightAssist = GetComponentInChildren <FlightAssist>();

        if (flightAssist != null)
        {
            flightAssist.assistEnabled = true;
        }
        else
        {
            Debug.Log("Could not fix flight assists");
        }

        RCSController rcsController = GetComponentInChildren <RCSController>();

        if (rcsController != null)
        {
            Traverse.Create(rcsController).Field("alive").SetValue(true);
        }
        else
        {
            Debug.Log("Could not fix rcs controller");
        }

        Battery battery = GetComponentInChildren <Battery>();

        if (battery != null)
        {
            Traverse.Create(battery).Field("isAlive").SetValue(true);
            battery.Connect();
        }
        else
        {
            Debug.Log("Could not fix battery");
        }

        GameObject hud = GameObject.Find("CollimatedHud");

        if (hud != null)
        {
            hud.SetActive(true);
        }
        else
        {
            Debug.Log("Could not fix hud");
        }

        GameObject hudWaypoint = GameObject.Find("WaypointLead");

        if (hudWaypoint != null)
        {
            hudWaypoint.SetActive(true);
        }
        else
        {
            Debug.Log("Could not fix hudWaypoint");
        }

        VRJoystick joystick = GetComponentInChildren <VRJoystick>();

        if (joystick != null)
        {
            joystick.sendEvents = true;
        }
        else
        {
            Debug.Log("Could not fix joystick");
        }

        VRInteractable[] levers = GetComponentsInChildren <VRInteractable>();
        foreach (VRInteractable lever in levers)
        {
            lever.enabled = true;
        }
        Debug.Log("Fixed " + levers.Length + " levers");
    }
Exemplo n.º 50
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            double threshold = -1;

            if (!double.TryParse(tbThreshold.Text, out threshold))
            {
                MessageBox.Show("预警门限为非法数字!");
                return;
            }
            double coefficient = -1;

            if (!double.TryParse(tbCoefficient.Text, out coefficient))
            {
                MessageBox.Show("电压参考系数为非法数字!");
                return;
            }
            if (this.battery != null)
            {
                var tempList = this.dataList.Where(item => item.id == this.tbId.Text && this.battery.uid != item.uid);
                if (tempList.Count() > 0)
                {
                    MessageBox.Show("蓄电池编号重复!");
                    return;
                }
                tempList = this.dataList.Where(item => item.address == this.tbAddress.Text && this.battery.uid != item.uid);
                if (tempList.Count() > 0)
                {
                    MessageBox.Show("蓄电池地址重复!");
                    return;
                }
            }
            else
            {
                var tempList = this.dataList.Where(item => item.id == this.tbId.Text);
                if (tempList.Count() > 0)
                {
                    MessageBox.Show("蓄电池编号重复!");
                    return;
                }
                tempList = this.dataList.Where(item => item.address == this.tbAddress.Text);
                if (tempList.Count() > 0)
                {
                    MessageBox.Show("蓄电池地址重复!");
                    return;
                }
            }

            if (!string.IsNullOrEmpty(this.tbId.Text) && !string.IsNullOrEmpty(this.tbAddress.Text)
                //&& !string.IsNullOrEmpty(this.tbOprUser.Text) && !string.IsNullOrEmpty(this.tbKeyTrainNo.Text)
                //&& !string.IsNullOrEmpty(this.tbBatteryType.Text)
                )
            {
                if (this.battery != null)
                {
                    for (var i = 0; i < dataList.Count; i++)
                    {
                        if (dataList[i].uid == this.battery.uid) // 修改,先删除
                        {
                            dataList.RemoveAt(i);
                            break;
                        }
                    }
                }
                var data = new Battery();
                data.uid            = this.dataList.Count == 0 ? 1 : (this.dataList.OrderByDescending(item => item.uid).First().uid + 1);
                data.id             = this.tbId.Text;
                data.address        = this.tbAddress.Text;
                data.oprUser        = this.tbOprUser.Text;
                data.keyTrainNo     = this.tbKeyTrainNo.Text;
                data.batteryType    = this.tbBatteryType.Text;
                data.threshold      = threshold;
                data.coefficient    = coefficient;
                data.lastModifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                this.dataList.Add(data);

                this.battery = null;

                this.tbId.Text          = "";
                this.tbAddress.Text     = "";
                this.tbOprUser.Text     = "";
                this.tbKeyTrainNo.Text  = "";
                this.tbBatteryType.Text = "";
                this.tbThreshold.Text   = "";
                this.tbCoefficient.Text = "";

                XmlHelper.SaveToXml(this.dataFile, this.dataList);
            }
            else
            {
                MessageBox.Show("属性格式错误,存在为空的项!");
            }
        }
Exemplo n.º 51
0
 public Mobile(Screen screen, Battery battery, Microphone micro)
 {
     MobScreen  = screen;
     MobBattery = battery;
     MobMicro   = micro;
 }
Exemplo n.º 52
0
 private void chargeButton_Click(object sender, EventArgs e)
 {
     Battery.ProcessSwitchingOfChargingState();
 }
Exemplo n.º 53
0
        public override MobileDevice CreateMobileDevice(Brand brand, string model, Display display = null, Battery battery = null, Processor processor = null)
        {
            var device = base.CreateMobileDevice(brand, model, display, battery, processor);

            device.Display   = display;
            device.Battery   = battery;
            device.Processor = processor;

            return(device);
        }
Exemplo n.º 54
0
 private void MessageFilteringFrom_FormClosed(object sender, EventArgs e)
 {
     Battery?.StopOngoingChargingProcesses();
 }
Exemplo n.º 55
0
    public static void Main()
    {
        Console.OutputEncoding = System.Text.Encoding.Unicode;
        //for the price to be displayed correctly we set bulgarian culture
        Thread.CurrentThread.CurrentCulture   = new CultureInfo("bg-BG");
        Thread.CurrentThread.CurrentUICulture = new CultureInfo("bg-BG");

        var battery           = new Battery("MegaBattery", 48, 10, BatteryType.LiIon);
        var display           = new Display(15.6, 99999999);
        var prestigio         = new GSM("PAP4055DUO", "Prestigio", 150, "Boco", battery, display);
        var phoneWithMinSpecs = new GSM("someModel", "someManufacturer");
        var basicPhone        = new GSM("Nokia", "TANK", 20, "Grandpa");
        var iphone            = GSM.IPhone4S;

        iphone.Owner = "NotMe";

        GSM[] listOfPhones = new GSM[] { prestigio, phoneWithMinSpecs, basicPhone, iphone };

        for (int phone = 0; phone < listOfPhones.Length; phone++)
        {
            Console.WriteLine(new string('-', 70));
            Console.WriteLine(listOfPhones[phone].ToString());
            Console.WriteLine(new string('-', 70));
        }

        Console.WriteLine("Static property iPhone4S: \n{0}", GSM.IPhone4S);

        //LAST TASK (I use the already created phone prestigio)

        //add a few calls
        prestigio.AddCall(DateTime.Now, new TimeSpan(0, 0, 2, 12), "08827102xx");
        prestigio.AddCall(new DateTime(2014, 12, 23, 12, 22, 31), new TimeSpan(0, 0, 1, 30), "08827103xx");
        prestigio.AddCall(new DateTime(2014, 12, 22, 21, 22, 31), new TimeSpan(0, 0, 4, 12), "08827104xx");

        //Display info about the calls in the call history
        foreach (var call in prestigio.CallHistory)
        {
            Console.WriteLine("Call: Date&Time: {0}, Duration: {1}, dialedPhoneNumber: {2}",
                              call.Date, call.Duration, call.DialedPhoneNumber);
        }

        //Calculate the total price of all calls
        Console.WriteLine("Total price in all call in history: {0}", prestigio.CalculateTotalCallCost(0.37m));


        TimeSpan crntMaxDuration = new TimeSpan(0, 0, 0, 0);
        int      maxIndex        = -1;

        for (var call = 0; call < prestigio.CallHistory.Count; call++)
        {
            if (prestigio.CallHistory[call].Duration > crntMaxDuration)
            {
                crntMaxDuration = prestigio.CallHistory[call].Duration;
                maxIndex        = call;
            }
        }
        prestigio.DeleteCall(prestigio.CallHistory[maxIndex].Date); //remove by date, because only 1 call has this date, its unique like an ID

        //Display calls after deletion
        Console.WriteLine("After the longest call has been deleted, calls are: \n{0}\n", new string('-', 70));
        foreach (var call in prestigio.CallHistory)
        {
            Console.WriteLine("Call: Date&Time: {0}, Duration: {1}, dialedPhoneNumber: {2}",
                              call.Date, call.Duration, call.DialedPhoneNumber);
        }

        prestigio.DeleteCallHistory();
        Console.WriteLine("After callHistory has been cleared, all calls are: ");
        foreach (var call in prestigio.CallHistory)
        {
            Console.WriteLine("Call: Date&Time: {0}, Duration: {1}, dialedPhoneNumber: {2}",
                              call.Date, call.Duration, call.DialedPhoneNumber);
        }
    }
Exemplo n.º 56
0
        /// <summary>
        /// update ui when detect bat state change
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UpdateBatStatUIWork(object sender, DoWorkEventArgs e)
        {
            // waite for user trully open
            mOpenUpdateBatStatUIThredEvent.Reset();
            mOpenUpdateBatStatUIThredEvent.WaitOne();

            string updateUIString = "";
            string tmpString      = "";

            List <Battery> oldState;

            string[] revStrings;
            int      idxNotEmpty;

            oldState = new List <Battery>();
            for (int i = 0; i < Battery.NUMS_BATTERY; i++)
            {
                oldState.Add(new Battery());
            }

            while (true)
            {
                mUpdateBatStatUIEvent.Reset();
                mUpdateBatStatUIEvent.WaitOne();

                lock (mtUpdateBatStatUI)
                {
                    tmpString = mtUpdateBatStatUI;
                    // clean data after process done
                    mtUpdateBatStatUI = "";
                }

                updateUIString += tmpString;

                if (updateUIString.EndsWith("\r\n"))
                {
                    // detect new string by \r\n
                    revStrings = Regex.Split(updateUIString, "\r\n");

                    idxNotEmpty = -1;
                    for (int i = 0; i < revStrings.Length; i++)
                    {
                        if (!String.IsNullOrEmpty(revStrings[i]))
                        {
                            if (revStrings[i].StartsWith("\t"))
                            {
                                idxNotEmpty = i;
                            }
                        }
                    }

                    if (idxNotEmpty != -1)
                    {
                        updateUIString = "";

                        lock (mtListBatStat)
                        {
                            for (int i = 0; i < Battery.NUMS_BATTERY; i++)
                            {
                                oldState[i].gParameter = mtListBatStat[i].gParameter;
                            }

                            Battery.ParseParameter(revStrings[idxNotEmpty], ref mtListBatStat);

                            // compare single param
                            for (int i = 0; i < mtListBatStat.Count; i++)
                            {
                                if (oldState[i].gParameter.stateOfBat != mtListBatStat[i].gParameter.stateOfBat ||
                                    (oldState[i].gParameter.resOfBat != mtListBatStat[i].gParameter.resOfBat)

                                    )
                                {
                                    string resShow = String.Format("{0}\t Bat {1}\t {2}\n",
                                                                   "[" + DateTime.Now + "]", i + "", mtListBatStat[i].gParameter.ToString());

                                    // update for main UI
                                    if (InvokeRequired)
                                    {
                                        BeginInvoke((MethodInvoker) delegate
                                        {
                                            textBoxLogStatusBat.AppendText(resShow);
                                        });
                                    }
                                    else
                                    {
                                        textBoxLogStatusBat.AppendText(resShow);
                                    }
                                    // update for view detail
                                    if (InvokeRequired)
                                    {
                                        BeginInvoke((MethodInvoker) delegate
                                        {
                                            batteryDetailControl.UpdateBatStat(mtListBatStat);
                                            batteryDetailControl.Visible = true;
                                        });
                                    }
                                    else
                                    {
                                        batteryDetailControl.UpdateBatStat(mtListBatStat);
                                        batteryDetailControl.Visible = true;
                                    }

                                    // update data result when change
                                    if (mWriteResuleBat.BaseStream != null)
                                    {
                                        mWriteResuleBat.Write(resShow);
                                        mWriteResuleBat.Flush();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 57
0
    // Update is called once per frame
    void Update()
    {
        float horizontalInput = Input.GetAxis("Horizontal");
        float verticalInput   = Input.GetAxis("Vertical");

        //get direction player is facing
        if ((horizontalInput != 0 || verticalInput != 0) && dAnimator.GetCurrentAnimatorStateInfo(0).IsName("DialogueBox_Close"))
        {
            Vector3 x = new Vector3(1 * horizontalInput, 0, 0);
            Vector3 y = new Vector3(0, verticalInput, 0);
            flashLight.turn(x, y);
        }

        // Movement code

        if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S))
        {
            dir = 2;
            playerMovement.SetBool("idleDown", false);
            playerMovement.SetBool("movingDown", true);
            Debug.Log("movingDown");
        }
        if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W))
        {
            dir = 1;
            playerMovement.SetBool("idleUp", false);
            playerMovement.SetBool("movingUp", true);
            Debug.Log("movingUp");
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A))
        {
            dir = 3;
            playerMovement.SetBool("idleLeft", false);
            playerMovement.SetBool("movingLeft", true);
            Debug.Log("movingLeft");
        }
        if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D))
        {
            dir = 4;
            playerMovement.SetBool("idleRight", false);
            playerMovement.SetBool("movingRight", true);
            Debug.Log("movingRight");
        }

        if (Input.GetKeyUp(KeyCode.DownArrow) || Input.GetKeyUp(KeyCode.S))
        {
            playerMovement.SetBool("movingDown", false);
            playerMovement.SetBool("idleDown", true);
            Debug.Log("idleDown");
        }
        if (Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.W))
        {
            playerMovement.SetBool("movingUp", false);
            playerMovement.SetBool("idleUp", true);
            Debug.Log("idleUp");
        }
        if (Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.A))
        {
            playerMovement.SetBool("movingLeft", false);
            playerMovement.SetBool("idleLeft", true);
            Debug.Log("idleLeft");
        }
        if (Input.GetKeyUp(KeyCode.RightArrow) || Input.GetKeyUp(KeyCode.D))
        {
            playerMovement.SetBool("movingRight", false);
            playerMovement.SetBool("idleRight", true);
            Debug.Log("idleRight");
        }

        //FindObjectOfType<GlobalControl>().hasKey = true;

        //toggle flashlight
        if (Input.GetButtonDown("ToggleLight"))
        {
            flashLight.toggle(flashOn, flashOff);
        }

        //check interactions
        if (currInterObj != null)
        {
            //trigger dialogue
            if (Input.GetKeyDown(KeyCode.F) && currInterObj.tag.Equals("DialogueTrigger") && dAnimator.GetCurrentAnimatorStateInfo(0).IsName("DialogueBox_Close"))
            {
                Debug.Log("F pressed; dialogue");
                currInterObj.GetComponentInParent <DialogueTrigger>().TriggerDialogue();
                if (currInterObj.GetComponent <DialogueTrigger>().hasEvent)
                {
                    currInterObj.GetComponentInParent <DialogueTrigger>().TriggerEvent();
                }
            }
            //continue dialogue
            if (Input.GetKeyDown(KeyCode.Space) && currInterObj.tag.Equals("DialogueTrigger"))
            {
                Debug.Log("Space pressed; continue dialogue");
                currInterObj.GetComponentInParent <DialogueTrigger>().AdvanceDialogue();
            }

            //pick up battery
            if (Input.GetKeyDown(KeyCode.F) && currInterObj.CompareTag("Battery"))
            {
                //special case of first battery. unlocks door and performs battery actions
                if (currInterObj.name == "FirstBattery")
                {
                    Battery bat = currInterObj.GetComponent <Battery>();
                    flashLight.addCharge(bat.getCharge());
                    currInterObj.GetComponentInParent <DialogueTrigger>().TriggerEvent();
                }
                else
                {
                    AudioSource.PlayClipAtPoint(itemPickup, new Vector3(5, 1, 2), 1f);
                    //add charge to player's flashlight and destroy the battery
                    Battery bat = currInterObj.GetComponent <Battery>();
                    flashLight.addCharge(bat.getCharge());
                    Destroy(currInterObj);
                }
            }
        }
        //push puzzle block
        if (Input.GetKeyDown(KeyCode.F))// && isPuzzleBlock(currInterObj.tag))
        {
            //This code is supposed to detect which block the PC is looking at. Only works if looking down.
            RaycastHit2D hit;
            //Vector2 rayDir = getDirectionFacing();

            //Vector3 rayDir = flashLight.transform.eulerAngles;

            //Quaternion q = flashLight.transform.rotation;
            //Vector2 rayDir = new Vector2(q.x, q.y);

            Vector2 rayDir = getDirectionFacing();

            //Debug.Log("Q DIR: " + q);
            Debug.Log("DIRECTION: " + rayDir);
            LayerMask mask = LayerMask.GetMask("BoxInteract");
            hit = Physics2D.Raycast(transform.position, rayDir, 1f, mask, -100.0f, 100.0f);
            Debug.Log("HIT COLLIDER: " + hit.collider.gameObject.name);
            Debug.Log("HIT COLLIDER TRANSFORM: " + hit.collider.transform.position);
            Debug.DrawLine(transform.position, hit.collider.transform.position, Color.red);
            hit.collider.gameObject.GetComponentInParent <PuzzleBlock>().interact(hit.collider.gameObject.name);
            //Debug.Log("F pressed - " + currInterObj.name);
            //currInterObj.GetComponentInParent<PuzzleBlock>().interact(currInterObj.name);
        }
    }
Exemplo n.º 58
0
        public Program()
        {
            // ======== ======== ======== ======== ======== ======== ======== ========
            // SETUP
            // ======== ======== ======== ======== ======== ======== ======== ========
            // Batteries to observe (group name, single block, or "" for all):
            string Batteries = "";

            // Name of a cockpit, or "" to use the first one found:
            string Cockpit = "Cockpit";

            // Display number to use (0 for center panel):
            int DisplayNum = 0;

            // Display text:
            string Format =
                "MWh:\n" +
                "{0:0.00} of {1:0.00}\n" +
                "Charge:\n" +
                "{2:0.0}%\n";

            // ======== ======== ======== ======== ======== ======== ======== ========
            // END OF SETUP
            // ======== ======== ======== ======== ======== ======== ======== ========

            try {
                sFormat = Format;

                gBattery = new Battery(this, Batteries);

                if (Cockpit == string.Empty)
                {
                    List <IMyCockpit> block_list = new List <IMyCockpit>();

                    GridTerminalSystem.GetBlocksOfType(block_list, x => x.IsSameConstructAs(Me));

                    if (block_list.Count > 0)
                    {
                        gCockpit = block_list[0];
                    }
                    else
                    {
                        throw new Exception("No cockpit found.");
                    }
                }
                else if ((gCockpit = GridTerminalSystem.GetBlockWithName(Cockpit) as IMyCockpit) == null || !gCockpit.IsSameConstructAs(Me))
                {
                    throw new Exception($"No blocks found with argument: '{Cockpit}'");
                }

                if (DisplayNum >= 0 && DisplayNum < gCockpit.SurfaceCount)
                {
                    gSurface             = gCockpit.GetSurface(DisplayNum);
                    gSurface.ContentType = ContentType.TEXT_AND_IMAGE;
                }
                else
                {
                    throw new Exception($"Variable 'DisplayNum' is out of range: 0 - {gCockpit.SurfaceCount - 1}");
                }

                Runtime.UpdateFrequency = UpdateFrequency.Update100;
            }
            catch (Exception e) {
                Echo(e.Message);

                if (gBattery != null)
                {
                    Echo(string.Format(sFormat, gBattery.CurrentPower, gBattery.MaxPower, gBattery.Percentage));
                }
            }
        }
Exemplo n.º 59
0
 public MobilePhone(int ID, decimal price, bool isAvailable, Brand brand, int Memory, string CPU, int RAM, string Model, Battery battery, string connectivity, bool ExpandableMemory, double ScreenSize, string GPU, string OperatingSystem)
     : base(ID, price, isAvailable, brand, Memory, CPU, RAM, Model, battery, connectivity, ExpandableMemory, ScreenSize)
 {
     this.GPU             = GPU;
     this.OperatingSystem = OperatingSystem;
 }
Exemplo n.º 60
0
        //---------------------------------------------------------------------------------------------------------



        //Eigentlicher Task
        //--------------------------------------------------------------------------------------------------------------------
        protected override void OnInvoke(ScheduledTask task)
        {
            //PeriodicTask, Periodischer Task
            //****************************************************************************************************
            if (task is PeriodicTask)
            {
                try
                {
                    //Einstellungen laden
                    //------------------------------------------------------------------------
                    //First Time// DateTime der ersten installation
                    IsolatedStorageFileStream filestream = file.OpenFile("Settings/FirstTime.dat", FileMode.Open);
                    StreamReader sr   = new StreamReader(filestream);
                    string       temp = sr.ReadToEnd();
                    filestream.Close();
                    dt = Convert.ToDateTime(temp);

                    //SwapImage //Anzahl erstellter Bilder
                    filestream = file.OpenFile("Settings/SwapImage.dat", FileMode.Open);
                    sr         = new StreamReader(filestream);
                    temp       = sr.ReadToEnd();
                    filestream.Close();
                    SwapImage = Convert.ToInt32(temp);

                    //FullVersion laden
                    filestream = file.OpenFile("Settings/FullVersion.dat", FileMode.Open);
                    sr         = new StreamReader(filestream);
                    temp       = sr.ReadToEnd();
                    filestream.Close();
                    int temp2 = Convert.ToInt32(temp);
                    if (temp2 == 1)
                    {
                        FullVersion = true;
                    }

                    //Einstellungen laden
                    filestream = file.OpenFile("Settings/Settings.dat", FileMode.Open);
                    sr         = new StreamReader(filestream);
                    Settings   = sr.ReadToEnd();
                    filestream.Close();

                    //Einstellungen umsetzen
                    string[] SplitSettings = Regex.Split(Settings, ";");
                    //Einstellungen Ordner
                    SetFolder = SplitSettings[0];
                    //Einstellungen Zufällige Wiedergabe
                    SetRandom = Convert.ToInt32(SplitSettings[1]);
                    //Momentan verwendetes Bild
                    SetImageNow = Convert.ToInt32(SplitSettings[2]);
                    //Batterie Warning
                    SetBatteryWarning = Convert.ToInt32(SplitSettings[3]);
                    //Note Battery Charging
                    SetNoteCharging = Convert.ToInt32(SplitSettings[4]);
                    //Note fully Charged
                    SetNoteFullyCharged = Convert.ToInt32(SplitSettings[5]);
                    //Note Sounds
                    SetNoteSounds = SplitSettings[6];
                    BatteryStatus = SplitSettings[7];
                    //SetNoteSounds abspielen
                    LogoStart = Convert.ToBoolean(SplitSettings[8]);

                    //Sprachdatei laden
                    filestream = file.OpenFile("Lang.dat", FileMode.Open);
                    sr         = new StreamReader(filestream);
                    string lang = sr.ReadToEnd();
                    filestream.Close();
                    string[] langSplit = Regex.Split(lang, ";");
                    //Sprachdatei umwandeln
                    BatteryFullyCharged = langSplit[0];
                    BatteryIsCharging   = langSplit[1];
                    BatteryLow          = langSplit[2];
                    Day     = langSplit[3];
                    Days    = langSplit[4];
                    Hour    = langSplit[5];
                    Hours   = langSplit[6];
                    Minute  = langSplit[7];
                    Minutes = langSplit[8];


                    //Bei Vollversion
                    if (FullVersion == true)
                    {
                    }
                    //Bei Demoversion
                    else
                    {
                        //Prüfen ob Trial Zeit abgelaufen
                        TimeSpan diff    = dt_Now - dt;
                        int      MinToGo = 1440 - Convert.ToInt32(diff.TotalMinutes);
                        //Wenn Zeit abgelaufen
                        if (MinToGo <= 0)
                        {
                            //Angeben das Bild auf Leer gestellt wird
                            Run = false;
                        }
                    }
                    //------------------------------------------------------------------------


                    //Bild neu erstellen
                    //------------------------------------------------------------------------
                    //Wichtig, bool "Run" beachten
                    if (Run == true)
                    {
                        //Variabeln
                        bool   NoPicture   = false;
                        string ShowPicture = "";


                        //Wenn bestimmter Ordner ausgewählt
                        if (SetFolder != "*")
                        {
                            //Variabeln
                            string AllFolders = "";
                            string RunFolder;

                            //Ordner.dat auslesen ob Bilder vorhanden
                            filestream = file.OpenFile("FoldersDat/" + SetFolder + ".dat", FileMode.Open);
                            sr         = new StreamReader(filestream);
                            temp       = sr.ReadToEnd();
                            filestream.Close();
                            int cTempPictures = Convert.ToInt32(temp);
                            //Prüfen ob Dateien in Ordner vorhanden
                            if (cTempPictures > 0)
                            {
                                //Der Reihe nach
                                if (SetRandom != 1)
                                {
                                    //Alle Bilder laden
                                    string[] AllPictures  = file.GetFileNames("Thumbs/" + SetFolder + "/");
                                    int      cAllPictures = AllPictures.Count();
                                    //SetImageNow prüfen
                                    if (SetImageNow >= cAllPictures)
                                    {
                                        SetImageNow = 1;
                                    }
                                    else
                                    {
                                        SetImageNow++;
                                    }
                                    //Settings neu erstellen
                                    CreateSettings();
                                    //ShowPicture erstellen
                                    ShowPicture = "Folders/" + SetFolder + "/" + AllPictures[(SetImageNow - 1)];
                                }

                                //Zufälliges Bild aus Ordner wählen
                                else
                                {
                                    Random   Rand         = new Random();
                                    string[] AllPictures  = file.GetFileNames("Thumbs/" + SetFolder + "/");
                                    int      cAllPictures = AllPictures.Count();
                                    int      iPicture     = Rand.Next(1, cAllPictures + 1);
                                    if (iPicture > cAllPictures)
                                    {
                                        iPicture = cAllPictures;
                                    }
                                    ShowPicture = "Folders/" + SetFolder + "/" + AllPictures[iPicture - 1];
                                }
                            }
                            //Wenn keine Dateien im Ordner vorhanden
                            else
                            {
                                //Ordner Einstellung zurücksetzten
                                SetFolder = "*";
                                CreateSettings();
                            }
                        }


                        //Prüfen ob Random ausgewählt ist
                        if (SetFolder == "*")
                        {
                            //Ordner auslesen
                            string[] FoldersSplit  = file.GetFileNames("FoldersDat/");
                            int      cFoldersSplit = FoldersSplit.Count();
                            string   AllFolders    = "";
                            string   RunFolder;

                            //Ordner durchlaufen
                            for (int i = 0; i < cFoldersSplit; i++)
                            {
                                //Ordner.dat auslesen ob Bilder vorhanden
                                filestream = file.OpenFile("FoldersDat/" + FoldersSplit[i], FileMode.Open);
                                sr         = new StreamReader(filestream);
                                temp       = sr.ReadToEnd();
                                filestream.Close();
                                int cTempPictures = Convert.ToInt32(temp);
                                //Prüfen ob Dateien in Ordner vorhanden
                                if (cTempPictures > 0)
                                {
                                    AllFolders += FoldersSplit[i] + "///";
                                }
                            }

                            //Zufälligen Ordner auswählen
                            string[] AllFoldersSplit  = Regex.Split(AllFolders, "///");
                            int      cAllFoldersSplit = AllFoldersSplit.Count() - 1;
                            if (cAllFoldersSplit > 0)
                            {
                                Random Rand    = new Random();
                                int    iFolder = Rand.Next(1, (cAllFoldersSplit + 1));
                                if (iFolder > cAllFoldersSplit)
                                {
                                    iFolder = cAllFoldersSplit;
                                }
                                RunFolder = AllFoldersSplit[iFolder - 1];
                                string[] SplitRunFolder  = Regex.Split(RunFolder, ".dat");
                                int      cSplitRunFolder = SplitRunFolder.Count();
                                RunFolder = SplitRunFolder[0];
                                for (int i2 = 1; i2 < (cSplitRunFolder - 1); i2++)
                                {
                                    RunFolder += ".dat" + SplitRunFolder[i2];
                                }

                                //Zufälliges Bild aus Ordner wählen
                                string[] AllPictures  = file.GetFileNames("Thumbs/" + RunFolder + "/");
                                int      cAllPictures = AllPictures.Count();
                                int      iPicture     = Rand.Next(1, cAllPictures + 1);
                                if (iPicture > cAllPictures)
                                {
                                    iPicture = cAllPictures;
                                }
                                ShowPicture = "Folders/" + RunFolder + "/" + AllPictures[iPicture - 1];
                            }
                            else
                            {
                                NoPicture = true;
                            }
                        }


                        //Prüfen ob Bild vorhanden und Lockscreen erstellen
                        if (NoPicture == false)
                        {
                            //Prüfen ob Ordner schon vorhanden
                            if (!file.DirectoryExists("Background"))
                            {
                                file.CreateDirectory("Background");
                            }
                            //Prüfen ob Bilder vorhanden und alte Bilder löschen
                            string SaveFile;
                            if (file.FileExists("Background/" + (SwapImage - 1) + ".jpg"))
                            {
                                file.DeleteFile("Background/" + (SwapImage - 1) + ".jpg");
                            }
                            if (file.FileExists("Background/" + (SwapImage - 2) + ".jpg"))
                            {
                                file.DeleteFile("Background/" + (SwapImage - 2) + ".jpg");
                            }

                            //SwapImage erhöhen
                            SwapImage++;
                            //SaveFile neu erstellen
                            SaveFile = "Background/" + SwapImage + ".jpg";

                            //SwapImage speichern
                            filestream = file.OpenFile("Settings/SwapImage.dat", FileMode.Open);
                            StreamWriter sw = new StreamWriter(filestream);
                            sw.WriteLine(SwapImage);
                            sw.Flush();
                            filestream.Close();

                            //Datei kopieren
                            file.CopyFile(ShowPicture, SaveFile);

                            //Lockscreen erstellen
                            string filePathOfTheImage = SaveFile;
                            var    schema             = "ms-appdata:///Local/";
                            var    uri = new Uri(schema + filePathOfTheImage, UriKind.RelativeOrAbsolute);
                            if (Windows.Phone.System.UserProfile.LockScreenManager.IsProvidedByCurrentApplication)
                            {
                                Windows.Phone.System.UserProfile.LockScreen.SetImageUri(uri);
                            }
                        }

                        //Wenn kein Bild vorhanden
                        else
                        {
                            //Bild auf LockscreenImage setzen
                            ShowPicture = "LockscreenImage.jpg";

                            //Prüfen ob Ordner schon vorhanden
                            if (!file.DirectoryExists("Background"))
                            {
                                file.CreateDirectory("Background");
                            }
                            //Prüfen ob Bilder vorhanden und alte Bilder löschen
                            string SaveFile;
                            if (file.FileExists("Background/" + (SwapImage - 1) + ".jpg"))
                            {
                                file.DeleteFile("Background/" + (SwapImage - 1) + ".jpg");
                            }
                            if (file.FileExists("Background/" + (SwapImage - 2) + ".jpg"))
                            {
                                file.DeleteFile("Background/" + (SwapImage - 2) + ".jpg");
                            }

                            //SwapImage erhöhen
                            SwapImage++;
                            //SaveFile neu erstellen
                            SaveFile = "Background/" + SwapImage + ".jpg";

                            //SwapImage speichern
                            filestream = file.OpenFile("Settings/SwapImage.dat", FileMode.Open);
                            StreamWriter sw = new StreamWriter(filestream);
                            sw.WriteLine(SwapImage);
                            sw.Flush();
                            filestream.Close();

                            //Datei kopieren
                            file.CopyFile(ShowPicture, SaveFile);

                            //Lockscreen erstellen
                            string filePathOfTheImage = SaveFile;
                            var    schema             = "ms-appdata:///Local/";
                            var    uri = new Uri(schema + filePathOfTheImage, UriKind.RelativeOrAbsolute);
                            Windows.Phone.System.UserProfile.LockScreen.SetImageUri(uri);
                        }
                    }
                    //Wenn Bild nicht gewechselt wird
                    else
                    {
                        //Bild auf LockscreenImage setzen
                        string ShowPicture = "LockscreenImage.jpg";

                        //Prüfen ob Ordner schon vorhanden
                        if (!file.DirectoryExists("Background"))
                        {
                            file.CreateDirectory("Background");
                        }
                        //Prüfen ob Bilder vorhanden und alte Bilder löschen
                        string SaveFile;
                        if (file.FileExists("Background/" + (SwapImage - 1) + ".jpg"))
                        {
                            file.DeleteFile("Background/" + (SwapImage - 1) + ".jpg");
                        }
                        if (file.FileExists("Background/" + (SwapImage - 2) + ".jpg"))
                        {
                            file.DeleteFile("Background/" + (SwapImage - 2) + ".jpg");
                        }

                        //SwapImage erhöhen
                        SwapImage++;
                        //SaveFile neu erstellen
                        SaveFile = "Background/" + SwapImage + ".jpg";

                        //SwapImage speichern
                        filestream = file.OpenFile("Settings/SwapImage.dat", FileMode.Open);
                        StreamWriter sw = new StreamWriter(filestream);
                        sw.WriteLine(SwapImage);
                        sw.Flush();
                        filestream.Close();

                        //Datei kopieren
                        file.CopyFile(ShowPicture, SaveFile);

                        //Lockscreen erstellen
                        string filePathOfTheImage = SaveFile;
                        var    schema             = "ms-appdata:///Local/";
                        var    uri = new Uri(schema + filePathOfTheImage, UriKind.RelativeOrAbsolute);
                        Windows.Phone.System.UserProfile.LockScreen.SetImageUri(uri);
                    }
                }
                catch
                {
                    file.CreateDirectory("Dreck geht nicht");
                }
                //------------------------------------------------------------------------



                //Benachrichtigungen erstellen
                //------------------------------------------------------------------------
                string ToastNote    = "none";
                string ToastTitle   = "";
                string ToastContent = "";

                bool doSilentToast = false;
                if (SetNoteSounds == "*")
                {
                    doSilentToast = true;
                }
                bool CustomSounds = true;
                if (SetNoteSounds == "**")
                {
                    CustomSounds = false;
                }


                if (Run == true)
                {
                    //Benachrichtigung das Battery voll aufgeladen ist
                    if (BatteryLevel == 100 & PowerSource == "External" & BatteryStatus != "full")
                    {
                        //Batterie Status neu erstellen
                        BatteryStatus = "full";
                        CreateSettings();
                        //Toast Variabeln erstellen
                        ToastNote    = "BatteryFullyCharged";
                        ToastTitle   = BatteryFullyCharged;
                        ToastContent = BatteryLevel + " %";
                    }

                    //Benachrichtigung wenn Battery geladen wird
                    else if (PowerSource == "External" & BatteryStatus != "loading" & BatteryStatus != "full")
                    {
                        //Batterie Status neu erstellen
                        BatteryStatus = "loading";
                        CreateSettings();
                        //Toast Variabeln erstellen
                        ToastNote    = "BatteryIsCharging";
                        ToastTitle   = BatteryIsCharging;
                        ToastContent = BatteryLevel + " %";
                    }

                    //Benachrichtigen wenn Battery schwach
                    else if (SetBatteryWarning >= BatteryLevel & BatteryStatus != "loading")
                    {
                        //Toast Variabeln erstellen
                        ToastNote    = "BatteryLow";
                        ToastTitle   = BatteryLow;
                        ToastContent = BatteryLevel + " %";
                    }

                    //Wenn keine Benachrichtigung
                    else if (PowerSource != "External")
                    {
                        //Batterie Status neu erstellen
                        BatteryStatus = "none";
                        CreateSettings();
                    }

                    //Benachrichtigung ausgeben
                    if ((ToastNote == "BatteryFullyCharged" & SetNoteFullyCharged == 1) | (ToastNote == "BatteryIsCharging" & SetNoteCharging == 1) | (ToastNote == "BatteryLow"))
                    {
                        ShowToast(ToastNote, ToastTitle, ToastContent, CustomSounds, doSilentToast);
                    }
                }
                //------------------------------------------------------------------------


                //Iconic Tile updaten
                //-----------------------------------------------------------------------------------------------------------------
                //Wenn Anzeige ausgeführt wird
                if (Run == true)
                {
                    try
                    {
                        //Restliche Zeit anzeigen
                        TimeSpan tempTime    = Battery.GetDefault().RemainingDischargeTime;
                        int      tempDays    = tempTime.Days;
                        int      tempHours   = tempTime.Hours;
                        int      tempMinutes = tempTime.Minutes;
                        string   tempText    = "";
                        if (tempDays != 0)
                        {
                            if (tempDays >= 20)
                            {
                                tempText += "20 " + Days + ", ";
                            }
                            else
                            {
                                if (tempDays == 1)
                                {
                                    tempText += "1 " + Day + ", ";
                                }
                                else
                                {
                                    tempText += tempDays + " " + Days + ", ";
                                }
                            }
                        }
                        if (tempHours != 0)
                        {
                            if (tempHours == 1)
                            {
                                tempText += "1 " + Hour + ", ";
                            }
                            else
                            {
                                tempText += tempHours + " " + Hours + ", ";
                            }
                        }
                        else
                        {
                            if (tempDays != 0)
                            {
                                tempText += "0 " + Hours + ", ";
                            }
                        }
                        if (tempMinutes == 1)
                        {
                            tempText += "1 " + Minute;
                        }
                        else
                        {
                            tempText += tempMinutes + " " + Minutes;
                        }


                        //Batterie Leistung umwandeln
                        if (BatteryLevel == 100)
                        {
                            BatteryLevel = 99;
                        }
                        //Tile neu erstellen
                        ShellTile      tile     = ShellTile.ActiveTiles.First();
                        IconicTileData TileData = new IconicTileData()
                        {
                            //Title = TileTitle,
                            //WideBackContent = "[back of wide Tile size content]",
                            Count        = BatteryLevel,
                            WideContent1 = tempText,
                            //SmallBackgroundImage = new Uri(tempUri, UriKind.Absolute),
                            //BackgroundImage = new Uri(tempUri, UriKind.Absolute),
                            //BackBackgroundImage = [back of medium Tile size URI],
                            //WideBackgroundImage = [front of wide Tile size URI],
                            //WideBackBackgroundImage = [back of wide Tile size URI],
                        };
                        tile.Update(TileData);
                    }
                    catch
                    {
                    }
                }
                //Wenn Anzeige nicht ausgeführt wird
                else
                {
                    try
                    {
                        //Tile neu erstellen
                        ShellTile      tile     = ShellTile.ActiveTiles.First();
                        IconicTileData TileData = new IconicTileData()
                        {
                            //Title = TileTitle,
                            //WideBackContent = "[back of wide Tile size content]",
                            Count = 0,
                            //SmallBackgroundImage = new Uri(tempUri, UriKind.Absolute),
                            //BackgroundImage = new Uri(tempUri, UriKind.Absolute),
                            //BackBackgroundImage = [back of medium Tile size URI],
                            //WideBackgroundImage = [front of wide Tile size URI],
                            //WideBackBackgroundImage = [back of wide Tile size URI],
                        };
                        tile.Update(TileData);
                    }
                    catch
                    {
                    }
                }
                //-----------------------------------------------------------------------------------------------------------------
            }
            //****************************************************************************************************

            //ScheduledActionService.LaunchForTest("PeriodicAgent", TimeSpan.FromSeconds(60));
            NotifyComplete();
        }