Esempio n. 1
0
        private void ActivityDetailForm_Load(object sender, EventArgs e)
        {
            DataRowView view = this.BindingContext[adaScheduleDataSet1, ACTIVITY_TABLE].Current as DataRowView;

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

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

            ADAScheduleDataSet.Activity_ReminderRow[] activityReminderRows = activityRow.GetActivity_ReminderRows();

            foreach (ADAScheduleDataSet.Activity_ReminderRow activityReminderRow in activityReminderRows)
            {
                if (!activityReminderRow.IsTimeNull() &&
                    activityReminderRow.ReminderId == ADADataAccess.Constants.ALARM_REMINDER_ID)
                {
                    this.dateTimePickerAlarm.Value = activityReminderRow.Time;
                    _alarmTimeSpan = activityReminderRow.Time - activityRow.EndTime;
                }
            }

            buttonPlaySound.Enabled = (!activityRow.IsSymbolIdNull() && !activityRow.SymbolRow.IsSoundNull());
        }
Esempio n. 2
0
        private void CategoryDetailForm_Load(object sender, EventArgs e)
        {
            try
            {
                LocalizedCategoryNameTableAdapter localizedCategoryNameAdapter = new LocalizedCategoryNameTableAdapter();
                localizedCategoryNameAdapter.Fill(this.categoryDetailDataSet.LocalizedCategoryName, categoryId, cultureName);

                if (categoryId > 0)
                {
                    CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();
                    categoryAdapter.Fill(this.categoryDetailDataSet.Category, categoryId);
                }

                byte[] image = this.categoryDetailDataSet.Category.Rows[0]["Image"] as byte[];
                if (image != null)
                {
                    this.pictureBoxImage.Image = ImageEngine.Resize(ImageEngine.FromArray(image), this.pictureBoxImage.Size);
                }

                EnableButtons();
            }
            catch (Exception ex)
            {
                ReportError(ex.Message.ToString());
                this.DialogResult = DialogResult.Abort;
                this.Close();
            }
        }
Esempio n. 3
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();
            }
        }
Esempio n. 4
0
        private Image CreatePicture(Image image)
        {
            Image orginalImage = ImageEngine.Resize(image, image.Size);

            DataRowView view = this.BindingContext[categoryDetailDataSet, CATEGORY].Current as DataRowView;

            view.BeginEdit();
            view.Row["Image"] = ImageEngine.ToArray(orginalImage);
            view.EndEdit();

            return(ImageEngine.Resize(image, this.pictureBoxImage.Size));
        }
Esempio n. 5
0
        /// <summary>
        /// Ensures all Mipmaps are generated in MipMaps.
        /// </summary>
        /// <param name="MipMaps">MipMaps to check.</param>
        /// <returns>Number of mipmaps present in MipMaps.</returns>
        internal static int BuildMipMaps(List <MipMap> MipMaps)
        {
            if (MipMaps?.Count == 0)
            {
                return(0);
            }

            MipMap currentMip = MipMaps[0];

            // KFreon: Check if mips required
            int estimatedMips = DDSGeneral.EstimateNumMipMaps(currentMip.Width, currentMip.Height);

            if (MipMaps.Count > 1)
            {
                return(estimatedMips);
            }

            // KFreon: Half dimensions until one == 1.
            MipMap[] newmips = new MipMap[estimatedMips];

            // TODO: Component size - pixels
            //var baseBMP = UsefulThings.WPF.Images.CreateWriteableBitmap(currentMip.Pixels, currentMip.Width, currentMip.Height);
            //baseBMP.Freeze();

            Action <int> action = new Action <int>(item =>
            {
                int index = item;
                MipMap newmip;
                var scale = 1d / (2 << (index - 1));  // Shifting is 2^index - Math.Pow seems extraordinarly slow.
                //newmip = ImageEngine.Resize(baseBMP, scale, scale, currentMip.Width, currentMip.Height, currentMip.LoadedFormatDetails);
                newmip             = ImageEngine.Resize(currentMip, scale, scale);
                newmips[index - 1] = newmip;
            });

            // Start at 1 to skip top mip
            if (ImageEngine.EnableThreading)
            {
                Parallel.For(1, estimatedMips + 1, new ParallelOptions {
                    MaxDegreeOfParallelism = ImageEngine.NumThreads
                }, action);
            }
            else
            {
                for (int item = 1; item < estimatedMips + 1; item++)
                {
                    action(item);
                }
            }

            MipMaps.AddRange(newmips);
            return(MipMaps.Count);
        }
Esempio n. 6
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();
            }
        }
Esempio n. 7
0
        private void WorkSystemDetail_Load(object sender, EventArgs e)
        {
            DataRowView view = this.BindingContext[adaWorkSystemDataSet1, SCHEDULE_TABLE].Current as DataRowView;

            ADAWorkSystemDataSet.ScheduleRow scheduleRow = view.Row as ADAWorkSystemDataSet.ScheduleRow;

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

            buttonPlaySound.Enabled = (!scheduleRow.IsSymbolIdNull() && !scheduleRow.SymbolRow.IsSoundNull());
        }
Esempio n. 8
0
        private void ActivityDetailForm_Load(object sender, EventArgs e)
        {
            DataRowView view = this.BindingContext[adaWorkSystemDataSet1, ACTIVITY_TABLE].Current as DataRowView;

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

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

            buttonPlaySound.Enabled = (!activityRow.IsSymbolIdNull() && !activityRow.SymbolRow.IsSoundNull());
        }
Esempio n. 9
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());
        }
Esempio n. 10
0
        private void ResizeImage(Image image)
        {
            int    width, height;
            double widthRatio  = (double)image.Width / pictureBox1.Width;
            double heightRatio = (double)image.Height / pictureBox1.Height;

            if (widthRatio > heightRatio)
            {
                width  = pictureBox1.Width;
                height = (int)(image.Height / widthRatio);
            }
            else
            {
                width  = (int)(image.Width / heightRatio);
                height = pictureBox1.Height;
            }

            pictureBox1.Image = ImageEngine.Resize(image, new Size(width, height));
        }