private void DataGridStreamDeckButtons_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { try { if (DataGridStreamDeckButtons.SelectedItems.Count != 1) { SetComboBoxButtonNameValueNone(); } else { var buttonExport = (ButtonExport)DataGridStreamDeckButtons.SelectedItems[0]; SetComboBoxButtonNameValue(StreamDeckCommon.ButtonNumber(buttonExport.Button.StreamDeckButtonName)); } if (DataGridStreamDeckButtons.SelectedItems.Cast <ButtonExport>().ToList().Select(m => m.LayerName).Distinct().ToList().Count > 1) { ComboBoxLayers.Text = string.Empty; } else if (DataGridStreamDeckButtons.SelectedItems.Count == 1) { ComboBoxLayers.Text = ((ButtonExport)DataGridStreamDeckButtons.SelectedItems[0]).LayerName; } else if (DataGridStreamDeckButtons.SelectedItems.Count == 0) { ComboBoxLayers.Text = string.Empty; } SetFormState(); } catch (Exception ex) { Common.ShowErrorMessageBox(ex); } }
private void UpdateButtonInfoFromSource() { HideAllDotImages(); foreach (var buttonImage in ButtonImages) { buttonImage.Bill.Clear(); var streamDeckButton = StreamDeckPanelInstance.SelectedLayer.GetStreamDeckButton(buttonImage.Bill.StreamDeckButtonName); buttonImage.Bill.Button = streamDeckButton; if (streamDeckButton.HasConfig) { SetDotImageStatus(true, StreamDeckCommon.ButtonNumber(streamDeckButton.StreamDeckButtonName)); } } }
private void ReadFile(string filename) { try { if (!VerifyImportArchive(filename)) { System.Windows.MessageBox.Show("Archive does not contain button data file " + StreamDeckConstants.BUTTON_EXPORT_FILENAME + ". Choose an other file.", "Invalid export file", MessageBoxButton.OK, MessageBoxImage.Error); return; } /* * Copy zip to temp folder and work on it there */ StreamDeckCommon.CleanDCSFPTemporaryFolder(); var tempFolder = StreamDeckCommon.GetDCSFPTemporaryFolder(); _extractedFilesFolder = tempFolder + "\\extracted_files"; if (!Directory.Exists(_extractedFilesFolder)) { Directory.CreateDirectory(_extractedFilesFolder); } File.Copy(filename, tempFolder + "\\" + Path.GetFileName(filename)); filename = tempFolder + "\\" + Path.GetFileName(filename); /* * Extract files to folder extracted_files */ ZipArchiver.ExtractZipFile(filename, _extractedFilesFolder); Clear(); var fileContents = File.ReadAllText(_extractedFilesFolder + "\\" + StreamDeckConstants.BUTTON_EXPORT_FILENAME); TranslateJSON(fileContents); ShowButtons(); } finally { Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow; } }
private void SetFormState() { try { if (!_isLoaded) { return; } if (_dcsbiosConverter.ConverterOutputType == EnumConverterOutputType.NotSet) { StackPanelRaw.Visibility = Visibility.Collapsed; StackPanelImage.Visibility = Visibility.Collapsed; StackPanelOverlayImage.Visibility = Visibility.Collapsed; } if (StreamDeckCommon.GetComparatorValue(ComboBoxComparisonType1.Text) == EnumComparator.NotSet || StreamDeckCommon.GetComparatorValue(ComboBoxComparisonType1.Text) == EnumComparator.Always) { StackPanelSecondCriteria.Visibility = Visibility.Collapsed; StackPanelAddSecondCriteria.Visibility = Visibility.Visible; } ButtonAddSecondCriteria.IsEnabled = ComboBoxComparisonType1.SelectedItem.Equals(ComboBoxItemAlways1) == false; var criteria1DataOK = !string.IsNullOrEmpty(TextBoxReferenceValue1.Text) && SelectedComparator1 != EnumComparator.NotSet; var criteria2DataOK = !string.IsNullOrEmpty(TextBoxReferenceValue2.Text) && SelectedComparator2 != EnumComparator.NotSet; var referenceValuesOK = Use2Criteria ? double.TryParse(TextBoxReferenceValue1.Text, out var result1) && double.TryParse(TextBoxReferenceValue2.Text, out var result2) : double.TryParse(TextBoxReferenceValue1.Text, out var result3); var criteriaOK = (!Use2Criteria || criteria2DataOK) && criteria1DataOK && referenceValuesOK; ButtonOk.IsEnabled = criteriaOK && _dcsbiosConverter.FaceConfigurationIsOK && IsDirty; } catch (Exception ex) { Common.ShowErrorMessageBox(ex); } }