private void RemoveDisconnected() { List <ICameraDevice> removedCameras = ConnectedDevices.Where(device => !device.IsConnected).ToList(); foreach (ICameraDevice device in removedCameras) { ConnectedDevices.Remove(device); } }
void PerformSearch(string searchTerm) { if (DllListings != null) { if (string.IsNullOrEmpty(searchTerm)) { DllListings = _originalDllListings; } else { var filteredList = _originalDllListings.Where(model => model.Name.ToLowerInvariant().Contains(searchTerm.ToLowerInvariant())); DllListings = new ObservableCollection <IDllListingModel>(filteredList); } } }
private void CopyFiles(object o) { AsyncObservableCollection <FileItem> items = o as AsyncObservableCollection <FileItem>; items = new AsyncObservableCollection <FileItem>(items.Where(file => file.IsChecked)); dlg.MaxValue = items.Count; int i = 0; foreach (var fileItem in items) { dlg.Progress = i; dlg.ImageSource = fileItem.Thumbnail; dlg.Label = Path.GetFileName(fileItem.FileName); if (File.Exists(fileItem.FileName)) { try { var dest = Path.Combine(destfolder, Path.GetFileName(fileItem.FileName)); if (fileItem.RotationAngle == 0) { File.Copy(fileItem.FileName, dest, true); } else { using (MagickImage image = new MagickImage(fileItem.FileName)) { image.BackgroundColor = new MagickColor(Color.Black); image.Rotate(fileItem.RotationAngle); image.Format = MagickFormat.Jpeg; // Save the result image.Write(dest); } } } catch (Exception exception) { Log.Error("ErrorCopy file", exception); } } //Thread.Sleep(100); i++; } dlg.Hide(); }
private void item_PropertyChanged(object sender, PropertyChangedEventArgs e) { _photoSession.Braketing.ExposureValues.Clear(); foreach ( CheckedListItem listItem in collection.Where( listItem => listItem.IsChecked && !_photoSession.Braketing.ExposureValues.Contains(listItem.Name))) { _photoSession.Braketing.ExposureValues.Add(listItem.Name); } _photoSession.Braketing.ShutterValues.Clear(); foreach ( CheckedListItem listItem in shuttercollection.Where( listItem => listItem.IsChecked && !_photoSession.Braketing.ShutterValues.Contains(listItem.Name)) ) { _photoSession.Braketing.ShutterValues.Add(listItem.Tag); } _photoSession.Braketing.PresetValues.Clear(); foreach ( CheckedListItem listItem in presetcollection.Where( (item) => item.IsChecked && !_photoSession.Braketing.PresetValues.Contains(item.Name))) { _photoSession.Braketing.PresetValues.Add(listItem.Name); } _photoSession.Braketing.ApertureValues.Clear(); foreach ( CheckedListItem listItem in aperturecollection.Where( (item) => item.IsChecked && !_photoSession.Braketing.ApertureValues.Contains(item.Name))) { _photoSession.Braketing.ApertureValues.Add(listItem.Name); } }
private async void InitializeNotes() { // Get local files first await App.Local.Initialize(); AllGroups = new GroupCollection((await App.Local.GetAllGroups()).Select(x => new GroupViewModel(x))); _notes = new AsyncObservableCollection <NoteViewModel>((await App.Local.GetAllNotes()).Select(x => new NoteViewModel(x))); string storedCloudKey = await App.Local.GetSelectedNoteID(); if (!string.IsNullOrEmpty(storedCloudKey)) { SelectedNote = _notes.Where(n => n.CloudKey == storedCloudKey).FirstOrDefault(); } _view = CollectionViewSource.GetDefaultView(_notes); _view.SortDescriptions.Add(new SortDescription("Title", ListSortDirection.Ascending)); AllGroups.UpdateViewGroupDescription(_view); _view.Filter = NoteFilter; await Task.Run(() => CheckForCloudUpdates()); }
private void ZipFiles(object o) { AsyncObservableCollection <FileItem> items = o as AsyncObservableCollection <FileItem>; items = new AsyncObservableCollection <FileItem>(items.Where(file => file.IsChecked)); dlg.MaxValue = items.Count; int i = 0; using (ZipFile zip = new ZipFile(destfile)) { foreach (var fileItem in items) { dlg.Progress = i; dlg.ImageSource = fileItem.Thumbnail; dlg.Label = Path.GetFileName(fileItem.FileName); zip.AddFile(fileItem.FileName, ""); i++; zip.Save(destfile); } } dlg.Hide(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (_photoSession.Braketing.ExposureValues.Count == 0) { _photoSession.Braketing.ExposureValues = new AsyncObservableCollection <string> { "-1", "0", "+1" } } ; foreach (string value in _device.ExposureCompensation.Values) { CheckedListItem item = new CheckedListItem() { Name = value, IsChecked = _photoSession.Braketing.ExposureValues.Contains(value) }; item.PropertyChanged += item_PropertyChanged; collection.Add(item); } listBox1.ItemsSource = collection; Dictionary <long, string> exposurevals = new Dictionary <long, string>(); int s_index = _device.ShutterSpeed.Values.IndexOf(_device.ShutterSpeed.Value); int s_min = s_index - 4; int s_max = s_index + 4; //exposurevals.Add(s_index, "0"); //long incre = _device.ShutterSpeed.NumericValues[s_index]; //int step = 0; //for (int i = s_index; i < _device.ShutterSpeed.Values.Count; i++) //{ // if (_device.ShutterSpeed.NumericValues[i]%incre == 0) // { // exposurevals.Add(i, step.ToString()); // step++; // incre = _device.ShutterSpeed.NumericValues[i]; // } //} //incre = _device.ShutterSpeed.NumericValues[s_index]; //step = 0; //for (int i = s_index; i >0; i--) //{ // if (incre % _device.ShutterSpeed.NumericValues[i] == 0) // { // if (step != 0) // { // exposurevals.Add(i, (-step).ToString()); // } // step++; // incre = _device.ShutterSpeed.NumericValues[i]; // } //} if (s_min < 0) { s_min = 0; } if (s_max >= _device.ShutterSpeed.Values.Count) { s_max = _device.ShutterSpeed.Values.Count - 1; } for (int i = 0; i < _device.ShutterSpeed.Values.Count; i++) { if (_device.ShutterSpeed.Values[i] == "Bulb") { continue; } CheckedListItem item = new CheckedListItem() { Name = _device.ShutterSpeed.Values[i] + (exposurevals.ContainsKey(i) ? " EV " + exposurevals[i] : ""), Tag = _device.ShutterSpeed.Values[i] }; if (i == s_index || i == s_min || i == s_max) { item.IsChecked = true; } item.PropertyChanged += item_PropertyChanged; shuttercollection.Add(item); } lst_shutter.ItemsSource = shuttercollection; foreach (CameraPreset cameraPreset in ServiceProvider.Settings.CameraPresets) { CheckedListItem item = new CheckedListItem() { Name = cameraPreset.Name, IsChecked = _photoSession.Braketing.PresetValues.Contains(cameraPreset.Name) }; item.PropertyChanged += item_PropertyChanged; presetcollection.Add(item); } lst_preset.ItemsSource = presetcollection; if (_device.Mode.Value == "M") { tab_exposure.Visibility = Visibility.Visible; tab_manual.Visibility = Visibility.Visible; tab_manual.IsSelected = true; _photoSession.Braketing.Mode = 1; } else { _photoSession.Braketing.Mode = 0; tab_exposure.Visibility = Visibility.Visible; tab_manual.Visibility = Visibility.Collapsed; tab_exposure.IsSelected = true; } item_PropertyChanged(null, null); } void item_PropertyChanged(object sender, PropertyChangedEventArgs e) { _photoSession.Braketing.ExposureValues.Clear(); foreach (CheckedListItem listItem in collection.Where(listItem => listItem.IsChecked && !_photoSession.Braketing.ExposureValues.Contains(listItem.Name))) { _photoSession.Braketing.ExposureValues.Add(listItem.Name); } _photoSession.Braketing.ShutterValues.Clear(); foreach (CheckedListItem listItem in shuttercollection.Where(listItem => listItem.IsChecked && !_photoSession.Braketing.ShutterValues.Contains(listItem.Name))) { _photoSession.Braketing.ShutterValues.Add(listItem.Tag); } _photoSession.Braketing.PresetValues.Clear(); foreach (CheckedListItem listItem in presetcollection.Where((item) => item.IsChecked && !_photoSession.Braketing.PresetValues.Contains(item.Name))) { _photoSession.Braketing.PresetValues.Add(listItem.Name); } }
private async Task GetAllNotesAndUpdate() { Offline = !App.Cloud.IsConnected(); if (Offline) { return; } GettingLatestNotes = true; var notes = await App.Cloud.GetAllNotes(); if (notes == null) // null if we time out trying to connect { return; } string cloudKey = SelectedNote?.CloudKey; // Loop through the notes backwards so as to remove them if needed for (int i = _notes.Count - 1; i >= 0; i--) { // Note exists in cloud - update if necessary if (notes.ContainsKey(_notes[i]?.CloudKey ?? "")) { if (notes[_notes[i].CloudKey].LastModified > _notes[i].LastModified) // Cloud note is newer { await App.Cloud.GetNoteWithContent(_notes[i].NoteData); await App.Local.UpdateNote(_notes[i].NoteData); } else if (notes[_notes[i].CloudKey].LastModified < _notes[i].LastModified) // Local note is newer { await App.Cloud.UpdateNote(_notes[i].NoteData); } notes.Remove(_notes[i].CloudKey); } // Note no longer exists in cloud, delete locally and in localDB else if (!notes.ContainsKey(_notes[i]?.CloudKey ?? "")) { await App.Local.DeleteNote(_notes[i].NoteData); _notes.RemoveAt(i); } } // These are the new notes coming from the cloud foreach (Note note in notes.Values) { await App.Cloud.GetNoteWithContent(note); _notes.Add(new NoteViewModel(note)); await App.Local.AddNote(note); } if (String.IsNullOrEmpty(cloudKey) && _notes.Count > 0) { SelectedNote = _notes[0]; } else { SelectedNote = _notes.Where(x => x.CloudKey == cloudKey).FirstOrDefault(); } // Forces a refresh on the converter! foreach (var note in _notes) { note.ForceLastModifiedConverterRefresh(); } GettingLatestNotes = false; }