/// <summary> /// double click event on one of the labels(bus's license number) the function open new bus data window /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BusDoubleClick(object sender, RoutedEventArgs e) { //getting the license from the label sender's name. int licesnse = int.Parse(((Label)sender).Name.Substring(3)); int ind = FindBus(licesnse); if (BusLst[ind].BusDat == null) { //updates the window and the bus. BusData busDataWin = new BusData(BusLst[ind]); BusLst[ind].BusDat = busDataWin; busDataWin.Show(); } else { MessageBox.Show("Bus Data window already open!");//can't open the same data window again } }
} //property /// <summary> /// constructor for Bus cless /// </summary> /// <param name="licNum">the Bus's licesnse number</param> /// <param name="date">the date that the bus started working </param> /// <param name="kmFromFuel">the km that droven from last fuel</param> /// <param name="kmFromtreat">the km that droven from last treatment</param> /// <param name="kmT">the total km </param> /// <param name="lastTreat">the date of the last treatment</param> /// <param name="startDate">the date of the start acivity of the bus</param> public Bus(int licNum, DateTime startDate, int kmT = 0, int kmFromFuel = 0, int kmFromtreat = 0, DateTime lastTreat = default(DateTime)) { _kmTotal = kmT; _kmFromFuel = kmFromFuel; _kmFromtreat = kmFromtreat; _licNum = licNum; _start = startDate; if (lastTreat == default(DateTime)) { _lastTreat = DateTime.Now; // the default is the date of the inserting the bus } else { _lastTreat = lastTreat; } state = BusState.Ready; counter = 0; busDat = null; // for check if the bus data win is open or not }