private void VisualSettingControl_Load(object sender, EventArgs e)
        {
            var colorSetDirectory = this.GetColorSetDirectory;
            if (Directory.Exists(colorSetDirectory))
            {
                this.OpenFileDialog.InitialDirectory = colorSetDirectory;
                this.SaveFileDialog.InitialDirectory = colorSetDirectory;
            }

            this.WidthNumericUpDown.Value = this.BarSize.Width;
            this.HeightNumericUpDown.Value = this.BarSize.Height;

            this.RefreshSampleImage();

            this.ChangeFontItem.Click += (s1, e1) =>
            {
                var f = new FontDialogWindow();
                f.SetOwner(this.ParentForm);

                f.FontInfo = this.GetFontInfo();
                if (f.ShowDialog().Value)
                {
                    this.SetFontInfo(f.FontInfo);
                    this.RefreshSampleImage();
                }
            };

            this.ChangeFontColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.FontColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.FontColor = this.ColorDialog.Color;
                    this.RefreshSampleImage();
                }
            };

            this.ChangeFontOutlineColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.FontOutlineColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.FontOutlineColor = this.ColorDialog.Color;
                    this.RefreshSampleImage();
                }
            };

            this.ChangeBarColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.BarColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.BarColor = this.ColorDialog.Color;
                    this.RefreshSampleImage();
                }
            };

            this.ChangeBarOutlineColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.BarOutlineColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.BarOutlineColor = this.ColorDialog.Color;
                    this.RefreshSampleImage();
                }
            };

            this.ChangeBackgoundColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.backgroundColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.backgroundColor = Color.FromArgb(
                        this.alphaDialog.Alpha,
                        this.ColorDialog.Color);
                    this.RefreshSampleImage();
                }
            };

            this.ChangeBackgroundAlphaItem.Click += (s1, e1) =>
            {
                this.alphaDialog.Alpha = this.backgroundColor.A;
                if (this.alphaDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.backgroundColor = Color.FromArgb(
                        this.alphaDialog.Alpha,
                        this.backgroundColor);
                    this.RefreshSampleImage();
                }
            };

            this.LoadColorSetItem.Click += (s1, e1) =>
            {
                if (this.OpenFileDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    using (var sr = new StreamReader(this.OpenFileDialog.FileName, new UTF8Encoding(false)))
                    {
                        var xs = new XmlSerializer(typeof(ColorSet));
                        var colorSet = xs.Deserialize(sr) as ColorSet;
                        if (colorSet != null)
                        {
                            this.FontColor = colorSet.FontColor.FromHTML();
                            this.FontOutlineColor = colorSet.FontOutlineColor.FromHTML();
                            this.BarColor = colorSet.BarColor.FromHTML();
                            this.BarOutlineColor = colorSet.BarOutlineColor.FromHTML();
                            this.backgroundColor = string.IsNullOrWhiteSpace(colorSet.BackgroundColor) ?
                                Color.Transparent :
                                Color.FromArgb(colorSet.BackgroundAlpha, colorSet.BackgroundColor.FromHTML());

                            this.RefreshSampleImage();

                            // カラーパレットに登録する
                            this.ColorDialog.CustomColors = new int[]
                            {
                                ColorTranslator.ToOle(colorSet.FontColor.FromHTML()),
                                ColorTranslator.ToOle(colorSet.FontOutlineColor.FromHTML()),
                                ColorTranslator.ToOle(colorSet.BarColor.FromHTML()),
                                ColorTranslator.ToOle(colorSet.BarOutlineColor.FromHTML()),
                            };
                        }
                    }
                }
            };

            this.SaveColorSetItem.Click += (s1, e1) =>
            {
                if (string.IsNullOrWhiteSpace(this.SaveFileDialog.FileName))
                {
                    this.SaveFileDialog.FileName = "スペスペ配色セット.xml";
                }

                if (this.SaveFileDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    var colorSet = new ColorSet()
                    {
                        FontColor = this.FontColor.ToHTML(),
                        FontOutlineColor = this.FontOutlineColor.ToHTML(),
                        BarColor = this.BarColor.ToHTML(),
                        BarOutlineColor = this.BarOutlineColor.ToHTML(),
                        BackgroundColor = this.backgroundColor.ToHTML(),
                        BackgroundAlpha = this.backgroundColor.A,
                    };

                    using (var sw = new StreamWriter(this.SaveFileDialog.FileName, false, new UTF8Encoding(false)))
                    {
                        var xs = new XmlSerializer(typeof(ColorSet));
                        xs.Serialize(sw, colorSet);
                    }
                }
            };

            this.WidthNumericUpDown.ValueChanged += (s1, e1) =>
            {
                this.RefreshSampleImage();
            };

            this.HeightNumericUpDown.ValueChanged += (s1, e1) =>
            {
                this.RefreshSampleImage();
            };

            this.ResetSpellFontItem.Click += (s1, e1) =>
            {
                foreach (var s in SpellTimerTable.Table)
                {
                    s.Font = this.GetFontInfo();
                }

                SpellTimerCore.Default.ClosePanels();
                SpellTimerTable.Save();
            };

            this.ResetSpellBarSizeItem.Click += (s1, e1) =>
            {
                foreach (var s in SpellTimerTable.Table)
                {
                    s.BarWidth = this.BarSize.Width;
                    s.BarHeight = this.BarSize.Height;
                }

                SpellTimerCore.Default.ClosePanels();
                SpellTimerTable.Save();
            };

            this.ResetSpellColorItem.Click += (s1, e1) =>
            {
                foreach (var s in SpellTimerTable.Table)
                {
                    s.FontColor = this.FontColor.ToHTML();
                    s.FontOutlineColor = this.FontOutlineColor.ToHTML();
                    s.BarColor = this.BarColor.ToHTML();
                    s.BarOutlineColor = this.BarOutlineColor.ToHTML();
                    s.BackgroundColor = this.backgroundColor.ToHTML();
                    s.BackgroundAlpha = this.backgroundColor.A;
                }

                SpellTimerCore.Default.ClosePanels();
                SpellTimerTable.Save();
            };

            this.ResetTelopFontItem.Click += (s1, e1) =>
            {
                foreach (var s in OnePointTelopTable.Default.Table)
                {
                    s.Font = this.GetFontInfo();
                }

                OnePointTelopController.CloseTelops();
                OnePointTelopTable.Default.Save();
            };

            this.ResetTelopColorItem.Click += (s1, e1) =>
            {
                foreach (var s in OnePointTelopTable.Default.Table)
                {
                    s.FontColor = this.FontColor.ToHTML();
                    s.FontOutlineColor = this.FontOutlineColor.ToHTML();
                    s.BackgroundColor = this.backgroundColor.ToHTML();
                    s.BackgroundAlpha = this.backgroundColor.A;
                }

                OnePointTelopController.CloseTelops();
                OnePointTelopTable.Default.Save();
            };
        }
Example #2
0
        private void VisualSettingControl_Load(object sender, EventArgs e)
        {
            var colorSetDirectory = this.GetColorSetDirectory;

            if (Directory.Exists(colorSetDirectory))
            {
                this.OpenFileDialog.InitialDirectory = colorSetDirectory;
                this.SaveFileDialog.InitialDirectory = colorSetDirectory;
            }

            this.WidthNumericUpDown.Value  = this.BarSize.Width;
            this.HeightNumericUpDown.Value = this.BarSize.Height;

            this.RefreshSampleImage();

            this.ChangeFontItem.Click += (s1, e1) =>
            {
                var f = new FontDialogWindow();
                f.SetOwner(this.ParentForm);

                f.FontInfo = this.GetFontInfo();
                if (f.ShowDialog().Value)
                {
                    this.SetFontInfo(f.FontInfo);
                    this.RefreshSampleImage();
                }
            };

            this.ChangeFontColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.FontColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.FontColor = this.ColorDialog.Color;
                    this.RefreshSampleImage();
                }
            };

            this.ChangeFontOutlineColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.FontOutlineColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.FontOutlineColor = this.ColorDialog.Color;
                    this.RefreshSampleImage();
                }
            };

            this.ChangeWarningFontColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.WarningFontColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.WarningFontColor = this.ColorDialog.Color;
                    this.RefreshSampleImage();
                }
            };

            this.ChangeWarningFontOutlineColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.WarningFontOutlineColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.WarningFontOutlineColor = this.ColorDialog.Color;
                    this.RefreshSampleImage();
                }
            };

            this.ChangeBarColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.BarColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.BarColor = this.ColorDialog.Color;
                    this.RefreshSampleImage();
                }
            };

            this.ChangeBarOutlineColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.BarOutlineColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.BarOutlineColor = this.ColorDialog.Color;
                    this.RefreshSampleImage();
                }
            };

            this.ChangeBackgoundColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.backgroundColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.backgroundColor = Color.FromArgb(
                        this.alphaDialog.Alpha,
                        this.ColorDialog.Color);
                    this.RefreshSampleImage();
                }
            };

            this.ChangeBackgroundAlphaItem.Click += (s1, e1) =>
            {
                this.alphaDialog.Alpha = this.backgroundColor.A;
                if (this.alphaDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.backgroundColor = Color.FromArgb(
                        this.alphaDialog.Alpha,
                        this.backgroundColor);
                    this.RefreshSampleImage();
                }
            };

            this.LoadColorSetItem.Click += (s1, e1) =>
            {
                if (this.OpenFileDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    using (var sr = new StreamReader(this.OpenFileDialog.FileName, new UTF8Encoding(false)))
                    {
                        var xs       = new XmlSerializer(typeof(ColorSet));
                        var colorSet = xs.Deserialize(sr) as ColorSet;
                        if (colorSet != null)
                        {
                            this.FontColor               = colorSet.FontColor.FromHTML();
                            this.FontOutlineColor        = colorSet.FontOutlineColor.FromHTML();
                            this.WarningFontColor        = colorSet.WarningFontColor.FromHTML();
                            this.WarningFontOutlineColor = colorSet.WarningFontOutlineColor.FromHTML();
                            this.BarColor        = colorSet.BarColor.FromHTML();
                            this.BarOutlineColor = colorSet.BarOutlineColor.FromHTML();
                            this.backgroundColor = string.IsNullOrWhiteSpace(colorSet.BackgroundColor) ?
                                                   Color.Transparent :
                                                   Color.FromArgb(colorSet.BackgroundAlpha, colorSet.BackgroundColor.FromHTML());

                            this.RefreshSampleImage();

                            // カラーパレットに登録する
                            this.ColorDialog.CustomColors = new int[]
                            {
                                ColorTranslator.ToOle(colorSet.FontColor.FromHTML()),
                                ColorTranslator.ToOle(colorSet.FontOutlineColor.FromHTML()),
                                ColorTranslator.ToOle(colorSet.BarColor.FromHTML()),
                                ColorTranslator.ToOle(colorSet.BarOutlineColor.FromHTML()),
                            };
                        }
                    }
                }
            };

            this.SaveColorSetItem.Click += (s1, e1) =>
            {
                if (string.IsNullOrWhiteSpace(this.SaveFileDialog.FileName))
                {
                    this.SaveFileDialog.FileName = "スペスペ配色セット.xml";
                }

                if (this.SaveFileDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    var colorSet = new ColorSet()
                    {
                        FontColor               = this.FontColor.ToHTML(),
                        FontOutlineColor        = this.FontOutlineColor.ToHTML(),
                        WarningFontColor        = this.WarningFontColor.ToHTML(),
                        WarningFontOutlineColor = this.WarningFontOutlineColor.ToHTML(),
                        BarColor        = this.BarColor.ToHTML(),
                        BarOutlineColor = this.BarOutlineColor.ToHTML(),
                        BackgroundColor = this.backgroundColor.ToHTML(),
                        BackgroundAlpha = this.backgroundColor.A,
                    };

                    using (var sw = new StreamWriter(this.SaveFileDialog.FileName, false, new UTF8Encoding(false)))
                    {
                        var xs = new XmlSerializer(typeof(ColorSet));
                        xs.Serialize(sw, colorSet);
                    }
                }
            };

            this.WidthNumericUpDown.ValueChanged += (s1, e1) =>
            {
                this.RefreshSampleImage();
            };

            this.HeightNumericUpDown.ValueChanged += (s1, e1) =>
            {
                this.RefreshSampleImage();
            };

            this.ResetSpellFontItem.Click += (s1, e1) =>
            {
                foreach (var s in SpellTimerTable.Table)
                {
                    s.Font = this.GetFontInfo();
                }

                SpellTimerCore.Default.ClosePanels();
                SpellTimerTable.Save();
            };

            this.ResetSpellBarSizeItem.Click += (s1, e1) =>
            {
                foreach (var s in SpellTimerTable.Table)
                {
                    s.BarWidth  = this.BarSize.Width;
                    s.BarHeight = this.BarSize.Height;
                }

                SpellTimerCore.Default.ClosePanels();
                SpellTimerTable.Save();
            };

            this.ResetSpellColorItem.Click += (s1, e1) =>
            {
                foreach (var s in SpellTimerTable.Table)
                {
                    s.FontColor               = this.FontColor.ToHTML();
                    s.FontOutlineColor        = this.FontOutlineColor.ToHTML();
                    s.WarningFontColor        = this.WarningFontColor.ToHTML();
                    s.WarningFontOutlineColor = this.WarningFontOutlineColor.ToHTML();
                    s.BarColor        = this.BarColor.ToHTML();
                    s.BarOutlineColor = this.BarOutlineColor.ToHTML();
                    s.BackgroundColor = this.backgroundColor.ToHTML();
                    s.BackgroundAlpha = this.backgroundColor.A;
                }

                SpellTimerCore.Default.ClosePanels();
                SpellTimerTable.Save();
            };

            this.ResetTelopFontItem.Click += (s1, e1) =>
            {
                foreach (var s in OnePointTelopTable.Default.Table)
                {
                    s.Font = this.GetFontInfo();
                }

                OnePointTelopController.CloseTelops();
                OnePointTelopTable.Default.Save();
            };

            this.ResetTelopColorItem.Click += (s1, e1) =>
            {
                foreach (var s in OnePointTelopTable.Default.Table)
                {
                    s.FontColor        = this.FontColor.ToHTML();
                    s.FontOutlineColor = this.FontOutlineColor.ToHTML();
                    s.BackgroundColor  = this.backgroundColor.ToHTML();
                    s.BackgroundAlpha  = this.backgroundColor.A;
                }

                OnePointTelopController.CloseTelops();
                OnePointTelopTable.Default.Save();
            };
        }