private void listViewText_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { if (e.IsSelected) { _currentTextRow = e.Item.Tag as ADACommunicatorDataSet.TextRow; } }
private void buttonChangeSymbol_Click(object sender, EventArgs e) { DataRowView view = this.BindingContext[adaCommunicatorDataSet1, TEXT_TABLE].Current as DataRowView; ADACommunicatorDataSet.TextRow textRow = view.Row as ADACommunicatorDataSet.TextRow; SymbolPicker picker = new SymbolPicker(); SymbolDataSet.LocalizedSymbolRow symbolRow = picker.PickSymbol(this, textRow.IsSymbolIdNull() ? -1 : textRow.SymbolId); if (symbolRow != null) { if (adaCommunicatorDataSet1.Symbol.FindBySymbolId(symbolRow.SymbolId) == null) { ADACommunicatorDataSet.SymbolRow newRow = adaCommunicatorDataSet1.Symbol.NewSymbolRow(); newRow.SymbolId = symbolRow.SymbolId; if (!symbolRow.IsSoundNull()) { newRow.Sound = symbolRow.Sound; } if (!symbolRow.IsImageNull()) { newRow.Image = symbolRow.Image; } adaCommunicatorDataSet1.Symbol.AddSymbolRow(newRow); adaCommunicatorDataSet1.Symbol.AcceptChanges(); } byte[] image = symbolRow.Image; if (image != null) { this.pictureBoxImage.Image = ImageEngine.Resize(ImageEngine.FromArray(image), this.pictureBoxImage.Size); } buttonPlaySound.Enabled = !symbolRow.IsSoundNull(); this.BindingContext[adaCommunicatorDataSet1, TEXT_TABLE].EndCurrentEdit(); view.BeginEdit(); if (textRow.IsNameNull() || textRow.Name.Length == 0) { textRow.Name = symbolRow.Name; } if (textRow.IsDescriptonNull() || textRow.Descripton.Length == 0) { textRow.Descripton = textRow.Name; } textRow.SymbolId = symbolRow.SymbolId; view.EndEdit(); } }
private void RefreshTextListView() { int selectedText = 0; this.toolStripStatusInfo.Text = Resources.RefreshCategoryListView; this.statusStripInfo.Refresh(); this.listViewText.Clear(); this.imageListText.Images.Clear(); DataRow[] rows = this.communicatorDataSet.Text.Select( "ScenarioId = " + _currentScenarioRow.ScenarioId, "[Name] ASC"); foreach (ADACommunicatorDataSet.TextRow row in rows) { string name = row.Name; byte[] image = row.IsSymbolIdNull() ? null : row.SymbolRow.Image; ListViewItem item; if (image != null) { using (MemoryStream ms = new MemoryStream(image)) { item = this.listViewText.Items.Add(name, this.imageListText.Images.Count); this.imageListText.Images.Add(new Bitmap(ms)); } } else { item = this.listViewText.Items.Add(name); } item.Tag = row; if (_currentTextRow == row) { selectedText = this.listViewText.Items.Count - 1; } } if (this.listViewText.Items.Count > 0) { this.listViewText.SelectedIndices.Clear(); this.listViewText.SelectedIndices.Add(selectedText); } else { _currentTextRow = null; } this.toolStripStatusInfo.Text = Resources.Ready; }
private void TextDetailForm_Load(object sender, EventArgs e) { DataRowView view = this.BindingContext[adaCommunicatorDataSet1, TEXT_TABLE].Current as DataRowView; ADACommunicatorDataSet.TextRow textRow = view.Row as ADACommunicatorDataSet.TextRow; if (!textRow.IsSymbolIdNull()) { if (!textRow.SymbolRow.IsImageNull()) { byte[] image = textRow.SymbolRow.Image; this.pictureBoxImage.Image = ImageEngine.Resize(ImageEngine.FromArray(image), this.pictureBoxImage.Size); } } buttonPlaySound.Enabled = (!textRow.IsSymbolIdNull() && !textRow.SymbolRow.IsSoundNull()); }
private void buttonAddText_Click(object sender, EventArgs e) { TextDetailForm f = new TextDetailForm(); f.CommunicatorDataSet.Merge(communicatorDataSet); ADACommunicatorDataSet.TextRow newTextRow = f.CommunicatorDataSet.Text.NewTextRow(); newTextRow.ScenarioId = _currentScenarioRow.ScenarioId; newTextRow.Name = ""; newTextRow.Descripton = ""; f.CommunicatorDataSet.Text.AddTextRow(newTextRow); f.CommunicatorDataSet.DefaultViewManager.DataViewSettings["Text"].RowFilter = "TextId=" + newTextRow.TextId; if (f.ShowDialog() == DialogResult.OK) { communicatorDataSet.Merge(f.CommunicatorDataSet); _currentTextRow = communicatorDataSet.Text.FindByTextId(newTextRow.TextId); RefreshTextListView(); } }
private void buttonPlaySound_Click(object sender, EventArgs e) { try { using (SoundPlayer player = new SoundPlayer()) { DataRowView view = this.BindingContext[adaCommunicatorDataSet1, TEXT_TABLE].Current as DataRowView; ADACommunicatorDataSet.TextRow textRow = view.Row as ADACommunicatorDataSet.TextRow; using (MemoryStream ms = new MemoryStream(textRow.SymbolRow.Sound)) { player.Stream = ms; player.Play(); } } } catch (Exception ex) { ReportError(ex); } }