public Station Add(Station station) //add station { if (station == null) { throw new ArgumentNullException("station"); } if (station.StationName == "") { throw new ArgumentException("station"); } Station s = FindStation(station.StationName); if (s == null) { Stations.Add(station); //add to list if (OnStationUpdate != null) { OnStationUpdate(this, station, true); } return(station); } return(s); }
public void Add() { switch (CurrentOption) { case Options.Station: var newStation = new Station { Name = string.Empty, Description = string.Empty, EcpCode = 0, RailwayStations = new List <RailwayStation> { RailwayStation } }; Stations.Add(newStation); CountLine = Stations.Count; break; case Options.OperativeSchedule: var newOperSh = new OperativeSchedule { ArrivalTime = DateTime.Now, DepartureTime = DateTime.Now, RouteName = string.Empty, NumberOfTrain = string.Empty, ListOfStops = new ObservableCollection <Station>(), ListWithoutStops = new ObservableCollection <Station>() }; OperativeSchedules.Add(newOperSh); CountLine = OperativeSchedules.Count; break; case Options.RegulatorySchedule: var newRegSh = new RegulatorySchedule { ArrivalTime = DateTime.Now, DepartureTime = DateTime.Now, RouteName = string.Empty, NumberOfTrain = string.Empty, DaysFollowings = null, ListOfStops = new ObservableCollection <Station>(), ListWithoutStops = new ObservableCollection <Station>() }; RegulatorySchedules.Add(newRegSh); CountLine = RegulatorySchedules.Count; break; } }
public static void AddStation(int _id, int idNode) { Station st = new Station(_id, Graph.FindNodeById(idNode)); Stations.Add(st); OnCreateStation?.Invoke(st); }
private void __InitializeStations() { if (Stations == null) { Stations = new ObservableCollection <ESTWSelectionStationViewModel>(); } else { Stations.Clear(); } foreach (var Station in m_Estw.Stations) { if (!Station.HasScheduleFile) { continue; } var VM = new ESTWSelectionStationViewModel(Station); VM.IsSelected = Runtime.VisibleStations.Contains(Station); VM.PropertyChanged += __Station_PropertyChanged; Stations.Add(VM); } __RefreshSelection(); }
public static async Task RefreshStations() { XmlDocument stationXml = new XmlDocument(); stationXml.LoadXml(await Http.Client.GetStringAsync(WeatherStationDataXmlUrl)); Stations.Add(new WeatherStation(stationXml.DocumentElement)); }
public void AddStation(string stationName, double x, double y, bool isTransfer) { if (!HasStation(stationName)) { Station station = new Station(stationName, x, y, isTransfer); Stations.Add(station); } }
/// <summary> /// Adds a Station object to the list /// </summary> /// <param name="station"></param> public void AddStation(Station station) { Stations.Add(station); if (PlayingStation == null) { PlayingStation = station; } }
public void AddStation(Station station) { if (station == null) { throw new System.ArgumentNullException("Station is equal to null while trying to add to the train {0}", Name); } Stations.Add(station); }
public static void StationMapper() { string[] stationData = FetchData(stationDataPath); for (int i = 1; i < stationData.Length; i++) { string[] splitline = stationData[i].Split(';', ',', ':', '|'); Stations.Add(new Station(int.Parse(splitline[0]), splitline[1], bool.Parse(splitline[2]))); } }
public void Add(Station station) { if (HasStation(station)) { throw new TrackLayoutException(string.Format(CultureInfo.CurrentCulture, Resources.Strings.DuplicateAddOfStation, station)); } station.Layout = this; Stations.Add(station); }
private void GetStation(AudioAnalyzerConfigurationMonitorIDStation station) { Station stationSend = new Station(); stationSend.StationID = station.StationID; stationSend.StationName = station.StationName; stationSend.ListOfMeters = new List <Meter>(); GetMeters(station, stationSend, station.MeterID.Count()); Stations.Add(stationSend); }
public void AddStations(ICollection <ServiceStation> stations) { foreach (ServiceStation station in stations) { if (StationExistsByName(station) == null) { Stations.Add(new RouteStationMapper().MapFrom(station)); } } }
public static void AddStation(Station newStation) { if (UniqueStation(newStation, out Station foundStation)) { Stations.Add(newStation); } else { Console.WriteLine($"Станция с именем {newStation.Name} уже существует. Её номер - №{foundStation.ID}"); } }
public async void LoadStationsAsync(SynchronizationContext uiContext) { foreach (var station in await _simulator.GetStations()) { uiContext.Send(x => { Stations.Add(new StationVM(station, _simulator)); _stationsLoaded = true; UpdateSimulationReady(); }, null); } }
public void AddStation(string name, int level, double posX, double posY) { Station station = new Station(Stations.Count, name, level, posX, posY); Stations.Add(station); //HACK Delete this code from here. Add Route if Station selected. if (Transports.Count > 0) { Transports.ElementAt(0).Route.Add(station); } }
public void AddStation() { if (Stations == null) { Stations = new List <PowerCoreDockingStation>(); } if (!Stations.Contains(this)) { Stations.Add(this); } }
public Savegame(string fileLoc) { this._playerShips = new ObservableCollection <Ship>(); this._shipyards = new ObservableCollection <Shipyard>(); this._stations = new ObservableCollection <Station>(); Path = fileLoc; Data = XElement.Load(_path, LoadOptions.PreserveWhitespace); IEnumerable <XElement> ships = from ship in _data.Descendants().Elements("component") where (string)ship.Attribute("owner") == "player" && (string)ship.Attribute("state") != "wreck" && ((string)ship.Attribute("class") == "ship_xl" | (string)ship.Attribute("class") == "ship_l" | (string)ship.Attribute("class") == "ship_s" | (string)ship.Attribute("class") == "ship_xs") orderby(string) ship.Attribute("name") select ship; foreach (XElement ship in ships) { PlayerShips.Add(new Ship(ship)); } IEnumerable <XElement> shipyards = this._data.Descendants().Elements("component").Where(delegate(XElement shipyard) { bool result = false; if (shipyard.Attribute("macro") != null && shipyard.Attribute("macro").Value.ToString().EndsWith("yard_macro")) { result = true; } return(result); } ); foreach (XElement shipyard in shipyards) { Shipyards.Add(new Shipyard(shipyard)); } IEnumerable <XElement> stations = this._data.Descendants().Elements("component").Where(delegate(XElement ele) { bool result = false; if (ele.Attribute("owner") != null && ele.Attribute("class") != null && (ele.Attribute("owner").Value.ToString() == "player") && ele.Attribute("class").Value.Contains("station")) { result = true; } return(result); }); foreach (XElement station in stations) { Stations.Add(new Station(station)); } }
public Station CreateStationFromSearch(string token) { JObject req = new JObject(); req["musicToken"] = token; var result = CallRPC("station.createStation", req); var station = new Station(this, result.Result); Stations.Add(station); return(station); }
public void AddStation(int station) { App.Current.Dispatcher.Invoke(() => { var newStation = Stations.FirstOrDefault(s => s.StationNumber == station); if (newStation is null) { Stations.Add(new Station { StationNumber = station }); } }); }
/// <summary> /// Adds a Station object to the list /// </summary> /// <param name="station"></param> public bool AddStation(Station station) { if (station.IsPlayable()) { Stations.Add(station); if (PlayingStation == null) { PlayingStation = station; } return(true); } return(false); }
private Station CreateStation(Song song, string type) { JObject req = new JObject(); req["trackToken"] = song.TrackToken; req["musicType"] = type; var result = CallRPC("station.createStation", req); var station = new Station(this, result.Result); Stations.Add(station); return(station); }
private async Task LoadInformationAsync() { var stations = await Task.Run(() => _repository.Stations.GetRangeAsync()); foreach (var station in stations) { Stations.Add(new StationModel(station, _repository)); } SelectedStationMap = Stations.FirstOrDefault(); timer.Interval = new TimeSpan(0, 0, 10); timer.Tick += timer_Tick; timer.Start(); }
public Station AddStation(Line line, string name) { if (line == null) { throw new ArgumentNullException(nameof(line)); } if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name)); } var result = new Station(Stations.Count, name, line); Stations.Add(result); return(result); }
/// <summary> /// Метод возвращает экземпляр класса <see cref="Station"/> или, если в таблице нет такой записи, создаёт её /// </summary> /// <param name="name">Название станции</param> /// <param name="railRoadName">Название железной дороги</param> /// <param name="stateName">Название региона</param> /// <param name="countryName">Название страны</param> /// <returns>Экземпляр класса <see cref="Station"/></returns> public Station GetStation(string name, string railRoadName, string stateName, string countryName) { var station = Stations.FirstOrDefault(s => s.Name.Equals(name) && s.State.Name.Equals(stateName) && s.RailRoad.Name.Equals(railRoadName)); if (station == null) { station = new Station { Name = name, State = GetState(stateName, countryName), RailRoad = GetRailRoad(railRoadName, countryName) }; Stations.Add(station); SaveChanges(); } return(station); }
private async Task UpdateList(RecordChangedEventArgs <Station> e) { await Task.Delay(1); if (e.ChangeType == ChangeType.None) { return; } if (e.ChangeType == ChangeType.Delete) { var s = Stations.FirstOrDefault(c => c.Model.StationId == e.Entity.StationId); if (s == null) { return; } Stations.Remove(s); } if (e.ChangeType == ChangeType.Insert) { if (Stations.Contains(new StationModel(e.Entity, _repository))) { return; } Stations.Add(new StationModel(e.Entity, _repository)); } if (e.ChangeType == ChangeType.Update) { var s = Stations.FirstOrDefault(c => c.Model.StationId == e.Entity.StationId); if (s == null) { return; } var i = Stations.IndexOf(s); Stations.Remove(s); Stations.Insert(i, new StationModel(e.Entity, _repository)); } }
public void CreateStation(Stop a) { String las = a.Gps_X; las.Replace(',', '.'); String lons = a.Gps_Y; lons.Replace(',', '.'); Boolean existeStop = false; Station existente = null; ICollection keyStop = Stations.Keys; foreach (String key in keyStop) { if (nameStop(((Station)stations[key]).ShortName).Equals(nameStop(a.ShortName))) { existeStop = true; existente = ((Station)stations[key]); break; } } if (existeStop == true) { (existente).addStop(a.ShortName, a); } else { Ubication ubi = new Ubication(lons, las); Station b = new Station(a.StopId, a.PlanVersionId, a.ShortName, a.LongName, ubi); b.addStop(a.ShortName, a); Stations.Add(a.StopId, b); } }
public MainViewModel() { RawIn_Command = new RelayCommand(OnRawIn_Command); EmptyOut_Command = new RelayCommand(OnEmptyOut_Command); EmptyIn_Command = new RelayCommand(OnEmptyIn_Command); FinOut_Command = new RelayCommand(OnFinOut_Command); Reset_Command = new RelayCommand(OnReset_Command); Start_Command = new RelayCommand(OnStart_Command); Stations.Add(new StationIdItem { Station_Id = AgvStationEnum.RX07, Station_Name = "工业实训单元" }); Stations.Add(new StationIdItem { Station_Id = AgvStationEnum.RX08, Station_Name = "汽车刹车盘单元" }); Stations.Add(new StationIdItem { Station_Id = AgvStationEnum.RX09, Station_Name = "3C加工单元单元" }); //测试用 //TestStationDevice 替换成 AgvStationClient\AllenBradleyClientDevice(RX07) 或者AgvStationClient\FanucRobotClientDevice(RX08/RX09) _Client = new TestStationCient <TestStationDevice>(AgvStationEnum.RX08, new TestStationDevice()); _Client.SendStationClientStateMessageEvent += (s) => { DispatcherHelper.CheckBeginInvokeOnUI(() => { Messages.Add(new MessageItem { State = s.State, Message = s.Message, CreateDateTime = DateTime.Now }); }); }; m_static_BackgroundWorker.WorkerReportsProgress = false; m_static_BackgroundWorker.WorkerSupportsCancellation = true; m_static_BackgroundWorker.DoWork += ScannerStaticFunc; m_static_BackgroundWorker.RunWorkerAsync(); }
public void AddStation(string address, double latitude, double longitude, string stationId) { Station station = new Station(address, stationId, latitude, longitude); Stations.Add(station); }
/// <summary> /// Initialize the view model /// </summary> private void Init() { Log("Initializing .."); //First task who gets the stations state var t1 = new Task(async() => { HttpClient httpClient = new HttpClient(); httpClient.Timeout = TimeSpan.FromSeconds(30); Task <HttpResponseMessage> t = null; try { //IMPORTANT !! //If the link above doesn't work , it's because the free azure account doesn't work anymore , so you need to run it locally t = httpClient.GetAsync("https://finalprojectsela.azurewebsites.net/api/airport/GetCurrentStationsState"); t.Wait(); } catch (Exception exc) { OnError(exc.Message); } if (t.Result.StatusCode == System.Net.HttpStatusCode.BadRequest || t.Result.StatusCode == System.Net.HttpStatusCode.InternalServerError) { OnError(t.Result.Content.ReadAsStringAsync().Result); } else { var result = JsonConvert.DeserializeObject <List <Common.Station> >(t.Result.Content.ReadAsStringAsync().Result); foreach (var station in result) { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { if (station.Plane != null) { Planes.Add(new Models.Plane(station.Plane.Name, station.Plane.ActionDate, station.Plane.waitingTime, station.Plane.flightState)); Stations.Add(new Models.Station(station.Number) { Plane = station.Plane.Name }); } else { Stations.Add(new Models.Station(station.Number)); } }); } } }); //Second Task who get the future departures and arrivals var t2 = new Task(async() => { HttpClient httpClient = new HttpClient(); httpClient.Timeout = TimeSpan.FromSeconds(30); Task <HttpResponseMessage> t = null; try { //IMPORTANT !! //If the link above doesn't work , it's because the free azure account doesn't work anymore , so you need to run it locally t = httpClient.GetAsync("https://finalprojectsela.azurewebsites.net/api/airport/GetFutureDeparturesAndArrivals"); t.Wait(); } catch (Exception exc) { OnError(exc.Message); } if (t.Result.StatusCode == System.Net.HttpStatusCode.BadRequest || t.Result.StatusCode == System.Net.HttpStatusCode.InternalServerError) { OnError(t.Result.Content.ReadAsStringAsync().Result); } else { var result = JsonConvert.DeserializeObject <List <Common.Plane> >(t.Result.Content.ReadAsStringAsync().Result); foreach (var plane in result) { await DispatcherHelper.ExecuteOnUIThreadAsync(() => { FutureFlights.Add(new Models.Plane(plane.Name, plane.ActionDate, plane.waitingTime, plane.flightState)); }); } } }); //Third task who open the hub connection var t3 = new Task(() => { try { //IMPORTANT !! //If the link above doesn't work , it's because the free azure account doesn't work anymore , so you need to run it locally HubConnection hubConnection = new HubConnection("https://finalprojectsela.azurewebsites.net"); var proxy = hubConnection.CreateHubProxy("AirportHub"); proxy.On <Common.Plane>("departureOrArrival", DepartureOrArrival); proxy.On <Common.Plane>("moved", Moved); proxy.On <string>("onerror", OnError); hubConnection.Start(); } catch (Exception exc) { OnError(exc.Message); throw; } }); t1.Start(); t2.Start(); t3.Start(); Task.WhenAll(t1, t2, t3).ContinueWith((t) => { Log("Finished initialization ! "); }); }
public async Task AddStationAsync(RadioStation station) { await _sqlService.InsertAsync(station); Stations.Add(station); }