/// <summary> /// 追加コマンドを実行する /// </summary> private void AddCommandExecute() { Book addBook = new Book(books.GetList().Count + 1, Book.Title, Book.Author, Book.Price); books.Add(addBook); CollectionList.Add(addBook); }
/// <summary> /// 追加コマンドを実行する /// </summary> private void AddCommandExecute() { Book addBook = new Book(DataBaseManager.GetIDNextData(), Book.Title, Book.Author, Book.Price); books.Add(addBook); DataBaseManager.AddDataBase(addBook); CollectionList.Add(addBook); }
/// <summary> /// 削除コマンドを実行する /// </summary> /// <param name="someBook"></param> private void DelCommandExecute(Book someBook) { books.Del(someBook); CollectionList.Clear(); foreach (var book in books.GetList()) { CollectionList.Add(book); } }
private async void SetupRealm() { _realm = await NoInternetVM.IsConnectedOnMainPage("matches"); EventList = _realm.All <EventModel>().Where(data => data.MatchId == Match.Id); CommentList = _realm.All <CommentModel>().Where(data => data.MatchId == Match.Id); CollectionList.Add(new ObservableCollectionsVM { CollectionList = EventList, ListSwitch = true }); CollectionList.Add(new ObservableCollectionsVM { CollectionList = CommentList, ListSwitch = false }); }
void AddCollection() { Collection collection = new() { Title = "New friggin collection", Type = "Game" }; CollectionList.Add(collection); } bool AddCollectionCanExecute() { return(MainBigSelection == CollectionList); }
private void AddCollection(object param) { CollectionVM cvm = new CollectionVM(); cvm.Name = param as String; NotifyPropertyChanged("CollectionList"); ConfFileSaver settings = new ConfFileSaver(); ConfFileSaver include = new ConfFileSaver(); ConfFileSaver exclude = new ConfFileSaver(); MenuParser menu = new MenuParser(); //todo change path string path = RetroFE.GetAbsolutePath() + "/Collections/" + cvm.Name; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (!File.Exists(path + "/Settings.conf")) { CollectionList.Add(cvm); settings.Save(path + "/Settings.conf"); if (!File.Exists(path + "/Include.txt")) { include.Save(path + "/Include.txt"); } if (!File.Exists(path + "/Exclude.txt")) { exclude.Save(path + "/Exclude.txt"); } //menu.Save(path + "/Menu.xml"); } }
private void Add_Click(object sender, RoutedEventArgs e) { CollectionList.Add(); }
private void LoanAdvancedCustomizableFields() { // fields List <CustomizableField> advancedCustomizableFields = ServicesProvider.GetInstance(). GetCustomizableFieldsServices(). SelectCustomizableFields( (int)Enum.Parse(typeof(OCustomizableFieldEntities), _entity.ToString())); // values List <CustomizableFieldValue> values = GetCustomizableFieldsServices().SelectCustomizableFieldValues(_linkId, _entityType); if (advancedCustomizableFields != null && advancedCustomizableFields.Count > 0) { foreach (CustomizableField field in advancedCustomizableFields) { CustomProperty myField = null; string fieldName = field.Name; CustomizableFieldValue value = GetValueForField(values, fieldName); string fieldDescription = field.Description; switch (field.Type) { case OCustomizableFieldTypes.Boolean: bool boolValue = value != null && bool.Parse(value.Value); myField = new CustomProperty(fieldName, fieldDescription, boolValue, typeof(bool), false, true); break; case OCustomizableFieldTypes.Number: object numberValue = value == null ? string.Empty : value.Value; myField = new CustomProperty(fieldName, fieldDescription, numberValue, typeof(string), false, true); break; case OCustomizableFieldTypes.String: string stringValue = value == null ? string.Empty : value.Value; myField = new CustomProperty(fieldName, fieldDescription, stringValue, typeof(string), false, true); break; case OCustomizableFieldTypes.Date: DateTime dateTime = value == null ? DateTime.Today : Converter.CustomFieldValueToDate(value.Value); myField = new CustomProperty(fieldName, fieldDescription, dateTime, typeof(DateTime), false, true); break; case OCustomizableFieldTypes.Collection: if (value == null) { _advancedFieldsCollections.Add(fieldName, field.Collection); myField = new CustomProperty(fieldName, fieldDescription, string.Empty, typeof(CollectionType), false, true); } else { Collection.Items = value.Field.Collection; if (value.Value != null) { _advancedFieldsCollections.Add(value.Field.Name, value.Field.Collection); myField = new CustomProperty(value.Field.Name, value.Field.Description, Collection.Items[int.Parse(value.Value)], typeof(CollectionType), false, true); } else { _advancedFieldsCollections.Add(value.Field.Name, value.Field.Collection); myField = new CustomProperty(value.Field.Name, value.Field.Description, string.Empty, typeof(CollectionType), false, true); } } break; case OCustomizableFieldTypes.Client: CustomClientField clientField; if (value == null || value.Value == string.Empty) { clientField = CustomClientField.Empty; } else { int personId; if (!int.TryParse(value.Value, out personId)) { clientField = CustomClientField.Empty; } else { var clientService = ServiceProvider.GetClientServices(); var person = clientService.FindPersonById(personId); clientField = new CustomClientField(person); } } myField = new CustomProperty(fieldName, fieldDescription, clientField, typeof(CustomClientField), false, true); break; } _advancedFields.Add(myField); } } fieldGrid.Refresh(); }
private void GETThingspeakProc() { // code block for DEMO // end block // get data from thingspeak code block string proxy = "D:\\Documents\\School Documents\\Thesis C\\SD Trap Data and Other Results\\CompiledDG.CSV"; int counter = 1; var myList = new List <Reading>(); using (var streamReader = new StreamReader(proxy)) { while (!streamReader.EndOfStream) { var splitLine = streamReader.ReadLine().Split(','); var newReading = new Reading() { ReadingId = counter, TrapNumber = splitLine[0], Geo1 = splitLine[1], Geo2 = splitLine[2], OFreq = float.Parse(splitLine[3]), AFreq = float.Parse(splitLine[4]), CFreq = float.Parse(splitLine[5]), Datetime = splitLine[6], Temperature = float.Parse(splitLine[7]), Humidity = float.Parse(splitLine[8]), Genus = int.Parse(splitLine[9]), Species = int.Parse(splitLine[10]), Sex = int.Parse(splitLine[11]), }; // add the entity in the list myList.Add(newReading); counter += 1; } streamReader.Close(); } // scry block string query1 = ""; string query2 = ""; const string url = "https://api.thingspeak.com/channels/1005703/feeds.json?"; HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); Stream receiveStream = myHttpWebResponse.GetResponseStream(); Encoding encode = System.Text.Encoding.GetEncoding("utf-8"); StreamReader readStream = new StreamReader(receiveStream, encode); Char[] read = new Char[256]; int count = readStream.Read(read, 0, 256); while (count > 0) { String str = new String(read, 0, count); query1 = query1 + str; count = readStream.Read(read, 0, 256); } myHttpWebResponse.Close(); readStream.Close(); const string url2 = "https://api.thingspeak.com/channels/1005707/feeds.json?"; HttpWebRequest myHttpWebRequest2 = (HttpWebRequest)WebRequest.Create(url2); HttpWebResponse myHttpWebResponse2 = (HttpWebResponse)myHttpWebRequest2.GetResponse(); Stream receiveStream2 = myHttpWebResponse2.GetResponseStream(); Encoding encode2 = System.Text.Encoding.GetEncoding("utf-8"); StreamReader readStream2 = new StreamReader(receiveStream2, encode); Char[] read2 = new Char[256]; int count2 = readStream2.Read(read2, 0, 256); while (count2 > 0) { String str2 = new String(read2, 0, count2); query2 = query2 + str2; count2 = readStream2.Read(read2, 0, 256); } myHttpWebResponse2.Close(); readStream2.Close(); channelOneFeeds channelOneFeeds = JsonConvert.DeserializeObject <channelOneFeeds>(query1); channelTwoFeeds channelTwoFeeds = JsonConvert.DeserializeObject <channelTwoFeeds>(query2); List <ChannelOne> channelOneList = new List <ChannelOne>(); List <ChannelTwo> channelTwoList = new List <ChannelTwo>(); channelOneList = channelOneFeeds.feeds; channelTwoList = channelTwoFeeds.feeds; //channelOneList.Reverse(); //channelTwoList.Reverse(); // end block // compare and add to CollectionList, ReadingList, TrapList[1].NoOfCaughtMosquitoes, TotalMales, TotalFemales properties int scryValue = 0; if (channelOneList.Count > 5) { scryValue = 5; } else { scryValue = channelOneList.Count; } for (int i = 0; i < scryValue; i++) { DateTime feb16 = new DateTime(2020, 2, 16); DateTime feb15 = new DateTime(2020, 2, 15); DateTime feb9 = new DateTime(2020, 2, 8); DateTime feb8 = new DateTime(2020, 2, 16); if (feb16.Month != channelOneList[i].created_at.Month && feb16.Day != channelOneList[i].created_at.Day && feb15.Day != channelOneList[i].created_at.Day && feb9.Day != channelOneList[i].created_at.Day && feb8.Day != channelOneList[i].created_at.Day) { var newReading = new Reading() { ReadingId = counter, TrapNumber = channelOneList[i].field5.ToString(), Geo1 = channelOneList[i].field1, Geo2 = channelOneList[i].field2, OFreq = (float)channelTwoList[i].field1, AFreq = (float)channelTwoList[i].field2, CFreq = (float)channelTwoList[i].field3, Datetime = channelOneList[i].created_at.AddHours(8).ToString("dd/MM/yyyy hh:mm tt"), Temperature = (float)channelOneList[i].field3, Humidity = (float)channelOneList[i].field4, Genus = (int)channelTwoList[i].field4, Species = (int)channelTwoList[i].field5, Sex = (int)channelTwoList[i].field6, }; // add the entity in the list myList.Add(newReading); counter += 1; } } ReadingList = new ObservableCollection <Reading>(myList); // end block // Convert readings to collections string oldDate = ""; int numberOfReadings = 0; int collectionCounter = CollectionList.Count + 1; foreach (var reading in ReadingList) { if (reading.TrapNumber == "1") { TrapList[0].NoOfCaughtMosquitoes += 1; } else if (reading.TrapNumber == "2") { TrapList[1].NoOfCaughtMosquitoes += 1; } else if (reading.TrapNumber == "3") { TrapList[2].NoOfCaughtMosquitoes += 1; } if (reading.Sex == 1) { TotalFemales += 1; } else { TotalMales += 1; } if (oldDate == "") { oldDate = reading.Datetime.Remove(10); numberOfReadings += 1; } else { if (oldDate != reading.Datetime.Remove(10)) { var newCollection = new Collection() { CollectionId = collectionCounter, Date = oldDate, NumberOfReadings = numberOfReadings }; CollectionList.Add(newCollection); collectionCounter += 1; oldDate = reading.Datetime.Remove(10); numberOfReadings = 1; var point = new DataPoint(newCollection.CollectionId, newCollection.NumberOfReadings); Points.Add(point); } else { numberOfReadings += 1; } } } var lastCollection = new Collection() { CollectionId = collectionCounter, Date = oldDate, NumberOfReadings = numberOfReadings }; CollectionList.Add(lastCollection); var lastPoint = new DataPoint(lastCollection.CollectionId, lastCollection.NumberOfReadings); Points.Add(lastPoint); foreach (var collection in CollectionList) { TotalNumberOfMosquitoes += collection.NumberOfReadings; } // end block MessageBox.Show("Loaded data from Thingspeak!", "Load Successful!", MessageBoxButton.OK, MessageBoxImage.Information); }
private void OpenCSVFileProc() { // get readings string filename = ""; int counter = 1; OpenFileDialog dialog = new OpenFileDialog(); dialog.Title = "Open CSV File"; dialog.Filter = "CSV Files (*.csv)|*.csv"; dialog.ShowDialog(); filename = dialog.FileName; while (filename == "") { OpenFileDialog repeatDialog = new OpenFileDialog(); repeatDialog.Title = "Open CSV File"; repeatDialog.Filter = "CSV Files (*.csv)|*.csv"; repeatDialog.ShowDialog(); filename = repeatDialog.FileName; } var myList = new List <Reading>(); using (var streamReader = new StreamReader(filename)) { while (!streamReader.EndOfStream) { var splitLine = streamReader.ReadLine().Split(','); var newReading = new Reading() { ReadingId = counter, TrapNumber = splitLine[0], Geo1 = splitLine[1], Geo2 = splitLine[2], OFreq = float.Parse(splitLine[3]), AFreq = float.Parse(splitLine[4]), CFreq = float.Parse(splitLine[5]), Datetime = splitLine[6], Temperature = float.Parse(splitLine[7]), Humidity = float.Parse(splitLine[8]), Genus = int.Parse(splitLine[9]), Species = int.Parse(splitLine[10]), Sex = int.Parse(splitLine[11]), }; // add the entity in the list myList.Add(newReading); counter += 1; } streamReader.Close(); } ReadingList = new ObservableCollection <Reading>(myList); // Convert readings to collections string oldDate = ""; int numberOfReadings = 0; int collectionCounter = CollectionList.Count + 1; foreach (var reading in ReadingList) { if (reading.TrapNumber == "1") { TrapList[0].NoOfCaughtMosquitoes += 1; } else if (reading.TrapNumber == "2") { TrapList[1].NoOfCaughtMosquitoes += 1; } else if (reading.TrapNumber == "3") { TrapList[2].NoOfCaughtMosquitoes += 1; } if (reading.Sex == 1) { TotalFemales += 1; } else { TotalMales += 1; } if (oldDate == "") { oldDate = reading.Datetime.Remove(10); numberOfReadings += 1; } else { if (oldDate != reading.Datetime.Remove(10)) { var newCollection = new Collection() { CollectionId = collectionCounter, Date = oldDate, NumberOfReadings = numberOfReadings }; CollectionList.Add(newCollection); collectionCounter += 1; oldDate = reading.Datetime.Remove(10); numberOfReadings = 1; var point = new DataPoint(newCollection.CollectionId, newCollection.NumberOfReadings); Points.Add(point); } else { numberOfReadings += 1; } } } var lastCollection = new Collection() { CollectionId = collectionCounter, Date = oldDate, NumberOfReadings = numberOfReadings }; CollectionList.Add(lastCollection); var lastPoint = new DataPoint(lastCollection.CollectionId, lastCollection.NumberOfReadings); Points.Add(lastPoint); foreach (var collection in CollectionList) { TotalNumberOfMosquitoes += collection.NumberOfReadings; } MessageBox.Show("Loaded data from a .csv file!", "Load Successful!", MessageBoxButton.OK, MessageBoxImage.Information); }