Exemple #1
0
        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();
            }
        }
Exemple #2
0
        private void buttonChangeSymbol_Click(object sender, EventArgs e)
        {
            DataRowView view = this.BindingContext[adaScheduleDataSet1, ACTIVITY_TABLE].Current as DataRowView;

            ADAScheduleDataSet.ActivityRow activityRow = view.Row as ADAScheduleDataSet.ActivityRow;

            SymbolPicker picker = new SymbolPicker();

            SymbolDataSet.LocalizedSymbolRow symbolRow = picker.PickSymbol(this,
                                                                           activityRow.IsSymbolIdNull() ? -1 : activityRow.SymbolId);

            if (symbolRow != null)
            {
                if (adaScheduleDataSet1.Symbol.FindBySymbolId(symbolRow.SymbolId) == null)
                {
                    ADAScheduleDataSet.SymbolRow newRow = adaScheduleDataSet1.Symbol.NewSymbolRow();
                    newRow.SymbolId = symbolRow.SymbolId;

                    if (!symbolRow.IsSoundNull())
                    {
                        newRow.Sound = symbolRow.Sound;
                    }

                    if (!symbolRow.IsImageNull())
                    {
                        newRow.Image = symbolRow.Image;
                    }

                    adaScheduleDataSet1.Symbol.AddSymbolRow(newRow);
                }

                byte[] image = symbolRow.Image;
                if (image != null)
                {
                    this.pictureBoxImage.Image = ImageEngine.Resize(ImageEngine.FromArray(image), this.pictureBoxImage.Size);
                }

                buttonPlaySound.Enabled = !symbolRow.IsSoundNull();

                this.BindingContext[adaScheduleDataSet1, ACTIVITY_TABLE].EndCurrentEdit();

                view.BeginEdit();
                activityRow.Name     = symbolRow.Name;
                activityRow.SymbolId = symbolRow.SymbolId;
                activityRow.Image    = image;
                view.EndEdit();
            }
        }