Beispiel #1
0
 private void listViewScenario_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
 {
     if (e.IsSelected)
     {
         this.listViewScenario.Update();
         _currentScenarioRow = e.Item.Tag as ADACommunicatorDataSet.ScenarioRow;
         RefreshTextListView();
     }
 }
Beispiel #2
0
        private void buttonChangeSymbol_Click(object sender, EventArgs e)
        {
            DataRowView view = this.BindingContext[adaCommunicatorDataSet1, SCENARIO_TABLE].Current as DataRowView;

            ADACommunicatorDataSet.ScenarioRow scenarioRow = view.Row as ADACommunicatorDataSet.ScenarioRow;

            SymbolPicker picker = new SymbolPicker();

            SymbolDataSet.LocalizedSymbolRow symbolRow = picker.PickSymbol(this,
                                                                           scenarioRow.IsSymbolIdNull() ? -1 : scenarioRow.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, SCENARIO_TABLE].EndCurrentEdit();

                view.BeginEdit();
                scenarioRow.SymbolId = symbolRow.SymbolId;
                if (scenarioRow.IsNameNull() || scenarioRow.Name.Length == 0)
                {
                    scenarioRow.Name = symbolRow.Name;
                }

                view.EndEdit();
            }
        }
Beispiel #3
0
        private void RefreshScenarioListView()
        {
            this.toolStripStatusInfo.Text = Resources.RefreshCategoryListView;
            this.statusStripInfo.Refresh();

            this.listViewScenario.Clear();
            this.imageListScenario.Images.Clear();
            DataRow[] rows = this.communicatorDataSet.Scenario.Select(@"IsActive = 'true'", "[Name] ASC");

            int selectedScenario = 0;

            foreach (ADACommunicatorDataSet.ScenarioRow 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.listViewScenario.Items.Add(name, this.imageListScenario.Images.Count);
                        this.imageListScenario.Images.Add(new Bitmap(ms));
                    }
                }
                else
                {
                    item = this.listViewScenario.Items.Add(name);
                }

                item.Tag = row;

                if (_currentScenarioRow == row)
                {
                    selectedScenario = this.listViewScenario.Items.Count - 1;
                }
            }

            if (this.listViewScenario.Items.Count > 0)
            {
                this.listViewScenario.SelectedIndices.Clear();
                this.listViewScenario.SelectedIndices.Add(selectedScenario);
            }
            else
            {
                _currentScenarioRow = null;
            }

            this.toolStripStatusInfo.Text = Resources.Ready;
        }
Beispiel #4
0
        private void ScenarioDetailForm_Load(object sender, EventArgs e)
        {
            DataRowView view = this.BindingContext[adaCommunicatorDataSet1, SCENARIO_TABLE].Current as DataRowView;

            ADACommunicatorDataSet.ScenarioRow scenarioRow = view.Row as ADACommunicatorDataSet.ScenarioRow;

            if (!scenarioRow.IsSymbolIdNull())
            {
                if (!scenarioRow.SymbolRow.IsImageNull())
                {
                    byte[] image = scenarioRow.SymbolRow.Image;
                    this.pictureBoxImage.Image = ImageEngine.Resize(ImageEngine.FromArray(image), this.pictureBoxImage.Size);
                }
            }

            buttonPlaySound.Enabled = (!scenarioRow.IsSymbolIdNull() && !scenarioRow.SymbolRow.IsSoundNull());
        }
Beispiel #5
0
        private void buttonAddScenario_Click(object sender, EventArgs e)
        {
            ScenarioDetailForm f = new ScenarioDetailForm();

            f.CommunicatorDataSet.Merge(communicatorDataSet);

            ADACommunicatorDataSet.ScenarioRow newScenarioRow = f.CommunicatorDataSet.Scenario.NewScenarioRow();
            newScenarioRow.Name     = "";
            newScenarioRow.IsActive = true;
            f.CommunicatorDataSet.Scenario.AddScenarioRow(newScenarioRow);

            f.CommunicatorDataSet.DefaultViewManager.DataViewSettings["Scenario"].RowFilter = "ScenarioId=" + newScenarioRow.ScenarioId;

            if (f.ShowDialog() == DialogResult.OK)
            {
                communicatorDataSet.Merge(f.CommunicatorDataSet);
                _currentScenarioRow = communicatorDataSet.Scenario.FindByScenarioId(newScenarioRow.ScenarioId);
                RefreshScenarioListView();
            }
        }
Beispiel #6
0
        private void buttonPlaySound_Click(object sender, EventArgs e)
        {
            try
            {
                using (SoundPlayer player = new SoundPlayer())
                {
                    DataRowView view = this.BindingContext[adaCommunicatorDataSet1, SCENARIO_TABLE].Current as DataRowView;
                    ADACommunicatorDataSet.ScenarioRow scenarioRow = view.Row as ADACommunicatorDataSet.ScenarioRow;

                    using (MemoryStream ms = new MemoryStream(scenarioRow.SymbolRow.Sound))
                    {
                        player.Stream = ms;
                        player.Play();
                    }
                }
            }
            catch (Exception ex)
            {
                ReportError(ex);
            }
        }