public LibraryWindowViewModel() { view = CollectionViewSource.GetDefaultView(LibraryItems); LibraryItems = new System.Collections.ObjectModel.ObservableCollection<string>(iservice.Files); iservice.Start(); iservice.FilesUpdated += new EventHandler<EventArgs<IList<string>>>(iservice_FilesUpdated); this.PropertyChanged += (s, ea) => System.Diagnostics.Debug.WriteLine(ea.PropertyName + " changed to " + this.GetType().GetProperty(ea.PropertyName).GetValue(this,null)); Observable.FromEventPattern<System.ComponentModel.PropertyChangedEventArgs>(this, "PropertyChanged") .Where(et => et.EventArgs.PropertyName == "SearchString") .Throttle(TimeSpan.FromMilliseconds(250)) .Subscribe(_ => { System.Diagnostics.Debug.WriteLine("search string changed"); if (SearchString.Trim() == string.Empty) view.Filter = null; else view.Filter = o => Regex.IsMatch(o as string, SearchString, RegexOptions.IgnoreCase); view.Refresh(); FilteredLibraryItemsCount = LibraryItems.Where(o => Regex.IsMatch(o as string, SearchString, RegexOptions.IgnoreCase)).Count(); }); //Observable.FromEventPattern<System.ComponentModel.PropertyChangedEventArgs>(this, "PropertyChanged") // .Where(et => et.EventArgs.PropertyName == "LibraryItems") // .Do(et => view = CollectionViewSource.GetDefaultView(LibraryItems)); }
private void calcTotal() { double _tempTotal = totalTimeFromDwg + timeRollupCol.Where(a => a.include == true).Sum(a => a.Time); _tempTotal = Math.Round(_tempTotal / 60, 2);//15-05-2018, added to change this to mins //TotalMins.Content = "Total : " + _tempTotal + " secs";//15-05-2018 if (_tempTotal == 1) { TotalMins.Content = "Total : " + _tempTotal + " min"; } else { TotalMins.Content = "Total : " + _tempTotal + " mins";//15-05-2018 } finalTimeFromUI = _tempTotal; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); databaseAddress = createAddress(); connection = new SqlConnection(databaseAddress.ConnectionString); // Create your application here TextView scanview = FindViewById <TextView>(Resource.Id.scanview); TextView txt = FindViewById <TextView>(Resource.Id.txtdata); listView = FindViewById <ListView>(Resource.Id.listView1); txt.Text += clientId; ble = CrossBluetoothLE.Current; adapter = CrossBluetoothLE.Current.Adapter; deviceList = new ObservableCollection <IDevice>(); Button Test = FindViewById <Button>(Resource.Id.btnTest); Test.Click += delegate { var state = ble.State; var info = ble.State.ToString(); new AlertDialog.Builder(this) .SetMessage(info) .SetTitle("Bluetooth State") .Show(); }; Button button = FindViewById <Button>(Resource.Id.dbbutton); button.Click += delegate { //var db = new SQLiteConnection(dbPath); ////set up table //db.CreateTable<Contact>(); ////create new contact obj Contact myContact = new Contact(clientId, prevLocation); ////store obj into table //db.Insert(myContact); connection.Open(); StringBuilder query = new StringBuilder(); query.Append("INSERT INTO UsersTable(Username, Location)VALUES('" + myContact.Name + "', '" + myContact.Location + "')"); string sqlquery = query.ToString(); SqlCommand command = new SqlCommand(sqlquery, connection); command.ExecuteNonQuery(); connection.Close(); }; Button showbutton = FindViewById <Button>(Resource.Id.showbtn); showbutton.Click += delegate { //set up db connection var db = new SQLiteConnection(dbPath); //connect to table var table = db.Table <Contact>(); foreach (var item in table) { Contact myContact = new Contact(item.Name, item.Location); txt.Text += myContact + "\n"; } }; Button BLEscan = FindViewById <Button>(Resource.Id.scanner); BLEscan.Click += async delegate { scanview.Text = ""; deviceList.Clear(); adapter.DeviceDiscovered += (s, a) => { deviceList.Add(a.Device); }; await adapter.StartScanningForDevicesAsync(); scanview.Text += "Device count:" + deviceList.Count; List <IDevice> x = deviceList .Where(device => device.Name != null) //&& device.Rssi > -30) .ToList(); scanview.Text += "Var X:" + x.Count; CreateList(x); prevLocation = x.ElementAt(0).Name; }; }