private async void XMLApplyOnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (this.ViewModel == null ||
                    this.ViewModel.Model == null)
                {
                    return;
                }

                var xml = this.XMLEditor.Text;
                if (string.IsNullOrEmpty(xml))
                {
                    return;
                }

                var obj = await this.ViewModel.Model.FromXMLAsync(xml);

                if (obj == null)
                {
                    return;
                }

                this.ViewModel.Model.ImportProperties(obj);
            }
            catch (Exception ex)
            {
                ModernMessageBox.ShowDialog(
                    "Error on applying XML to this settings.",
                    "XML Error",
                    MessageBoxButton.OK,
                    ex);
            }
        }
        public TimelineManagerView()
        {
            this.InitializeComponent();
            this.SetLocale(Settings.Default.UILocale);
            this.LoadConfigViewResources();

            if (!WPFHelper.IsDesignMode)
            {
                if (this.TimelineConfig.Enabled)
                {
                    WPFHelper.BeginInvoke(async() =>
                    {
                        try
                        {
                            await Task.Run(() => TimelineManager.Instance.LoadTimelineModels());
                        }
                        catch (Exception ex)
                        {
                            TimelineModel.ShowRazorDumpFile();

                            ModernMessageBox.ShowDialog(
                                ex.Message,
                                "Timeline Loader",
                                MessageBoxButton.OK,
                                ex.InnerException);
                        }
                    });
                }
            }

            this.StyleListView.SelectionChanged += (x, y) =>
            {
                if (this.TimelineConfig.DesignMode)
                {
                    var selectedStyle = this.StyleListView.SelectedItem as TimelineStyle;

                    TimelineOverlay.HideDesignOverlay(false);
                    TimelineOverlay.ShowDesignOverlay(selectedStyle);

                    TimelineNoticeOverlay.HideDesignOverlay();
                    TimelineNoticeOverlay.ShowDesignOverlay(selectedStyle);
                }
            };

            this.timer.Tick += (x, y) =>
            {
                if (TimelineController.CurrentController != null)
                {
                    // ついでにスタートボタンのラベルを切り替える
                    this.StartButtonLabel = TimelineController.CurrentController.IsRunning ?
                                            StopString :
                                            StartString;
                }
            };

            this.timer.Start();
        }
Exemple #3
0
        public TriggerTesterView()
        {
            this.InitializeComponent();
            this.SetLocale(Settings.Default.UILocale);
            this.LoadConfigViewResources();

            // ウィンドウのスタート位置を決める
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;

            this.MouseLeftButtonDown += (x, y) => this.DragMove();

            this.CloseButton.Click += (x, y) =>
            {
                this.testTimer.Stop();
                this.Close();
            };

            this.Closed += (x, y) =>
            {
                PluginMainWorker.Instance.InSimulation = false;
                this.ClearTestCondition();
            };

            this.testTimer.Tick += this.TestTimer_Tick;

            this.RunButton.Click += async(x, y) =>
            {
                // インスタンススペルを消去する
                SpellTable.Instance.RemoveInstanceSpellsAll();

                await Task.Run(() =>
                {
                    PluginMainWorker.Instance.InSimulation = true;

                    lock (this)
                    {
                        this.testTimer.Stop();
                        this.isPause = false;

                        foreach (var log in this.Logs)
                        {
                            log.IsDone = false;
                        }

                        this.prevTestTimestamp = DateTime.Now;
                        this.TestTime          = TimeSpan.Zero;
                        this.testTimer.Start();
                    }
                });
            };

            this.PauseButton.Click += (x, y) =>
            {
                this.isPause             = !this.isPause;
                this.PauseButton.Content =
                    this.isPause ? "Resume" : "Pause";
            };

            this.StopButton.Click += async(x, y) =>
            {
                await Task.Run(() =>
                {
                    lock (this)
                    {
                        this.testTimer.Stop();

                        foreach (var log in this.Logs)
                        {
                            log.IsDone = false;
                        }

                        this.prevTestTimestamp = DateTime.MinValue;
                    }

                    PluginMainWorker.Instance.InSimulation = false;
                });

                // インスタンススペルを消去する
                SpellTable.Instance.RemoveInstanceSpellsAll();
            };

            this.OpenButton.Click += (x, y) =>
            {
                var result = this.openFileDialog.ShowDialog(ActGlobals.oFormActMain);
                if (result != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                this.LogFile = this.openFileDialog.FileName;
                this.LoadLog();
            };

            this.ApplyButton.Click += async(x, y) =>
            {
                await Task.Run(() =>
                {
                    // インスタンススペルを消去する
                    SpellTable.Instance.RemoveInstanceSpellsAll();

                    // テスト条件を適用する
                    this.ApplyTestCondition();
                });

                ModernMessageBox.ShowDialog(
                    "Test Condition was applied.",
                    "Trigger Simulator");
            };

            this.ClearButton.Click += async(x, y) =>
            {
                await Task.Run(() =>
                {
                    // インスタンススペルを消去する
                    SpellTable.Instance.RemoveInstanceSpellsAll();

                    // テスト条件を解除する
                    this.ClearTestCondition();
                });

                ModernMessageBox.ShowDialog(
                    "Test Condition was cleard.",
                    "Trigger Simulator");
            };
        }
        public TriggerTesterView()
        {
            this.InitializeComponent();
            this.SetLocale(Settings.Default.UILocale);
            this.LoadConfigViewResources();

            // ウィンドウのスタート位置を決める
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;

            this.MouseLeftButtonDown += (x, y) => this.DragMove();

            this.Loaded += async(x, y) =>
            {
                await WPFHelper.InvokeAsync(() =>
                {
                    this.MessageLabel.Content    = "Loading, Please wait...";
                    this.MessageLabel.Visibility = Visibility.Visible;
                },
                                            DispatcherPriority.Normal);

                // シミュレーションモードをONにする
                PluginMainWorker.Instance.InSimulation = true;
                TableCompiler.Instance.InSimulation    = true;

                await Task.Delay(TimeSpan.FromSeconds(0.5));

                await WPFHelper.BeginInvoke(() =>
                {
                    this.MessageLabel.Content    = string.Empty;
                    this.MessageLabel.Visibility = Visibility.Collapsed;
                },
                                            DispatcherPriority.ApplicationIdle);
            };

            this.CloseButton.Click += (x, y) =>
            {
                this.testTimer.Stop();
                this.Close();
            };

            this.Closed += (x, y) =>
            {
                PluginMainWorker.Instance.InSimulation = false;
                TableCompiler.Instance.InSimulation    = false;
                this.ClearTestCondition();
            };

            this.testTimer.Tick += this.TestTimer_Tick;

            this.RunButton.Click += async(x, y) =>
            {
                // インスタンススペルを消去する
                SpellTable.Instance.RemoveInstanceSpellsAll();

                await Task.Run(() =>
                {
                    lock (this)
                    {
                        this.testTimer.Stop();
                        this.isPause = false;

                        foreach (var log in this.Logs)
                        {
                            log.IsDone = false;
                        }

                        this.prevTestTimestamp = DateTime.Now;
                        this.TestTime          = TimeSpan.Zero;
                        this.testTimer.Start();
                    }
                });
            };

            this.PauseButton.Click += (x, y) =>
            {
                this.isPause             = !this.isPause;
                this.PauseButton.Content =
                    this.isPause ? "Resume" : "Pause";
            };

            this.StopButton.Click += async(x, y) =>
            {
                await Task.Run(() =>
                {
                    lock (this)
                    {
                        this.testTimer.Stop();

                        foreach (var log in this.Logs)
                        {
                            log.IsDone = false;
                        }

                        this.prevTestTimestamp = DateTime.MinValue;
                    }

                    PluginMainWorker.Instance.InSimulation = false;
                    ChatLogWorker.Instance?.Write(true);
                });

                // インスタンススペルを消去する
                SpellTable.Instance.RemoveInstanceSpellsAll();
            };

            this.OpenButton.Click += (x, y) =>
            {
                var result = this.openFileDialog.ShowDialog(ActGlobals.oFormActMain);
                if (result != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                this.LogFile = this.openFileDialog.FileName;
                this.LoadLog();
            };

            this.ApplyButton.Click += async(x, y) =>
            {
                await WPFHelper.InvokeAsync(() =>
                {
                    this.MessageLabel.Content    = "Loading, Please wait...";
                    this.MessageLabel.Visibility = Visibility.Visible;
                },
                                            DispatcherPriority.Normal);

                await Task.Run(() =>
                {
                    // インスタンススペルを消去する
                    SpellTable.Instance.RemoveInstanceSpellsAll();

                    // テスト条件を適用する
                    this.ApplyTestCondition();
                });

                ModernMessageBox.ShowDialog(
                    "Test Condition was applied.",
                    "Trigger Simulator");

                await Task.Delay(TimeSpan.FromSeconds(0.5));

                await WPFHelper.BeginInvoke(() =>
                {
                    this.MessageLabel.Content    = string.Empty;
                    this.MessageLabel.Visibility = Visibility.Collapsed;
                },
                                            DispatcherPriority.ApplicationIdle);
            };

            this.ClearButton.Click += async(x, y) =>
            {
                await WPFHelper.InvokeAsync(() =>
                {
                    this.MessageLabel.Content    = "Loading, Please wait...";
                    this.MessageLabel.Visibility = Visibility.Visible;
                },
                                            DispatcherPriority.Normal);

                await Task.Run(() =>
                {
                    // インスタンススペルを消去する
                    SpellTable.Instance.RemoveInstanceSpellsAll();

                    // テスト条件を解除する
                    this.ClearTestCondition();
                });

                ModernMessageBox.ShowDialog(
                    "Test Condition was cleard.",
                    "Trigger Simulator");

                await Task.Delay(TimeSpan.FromSeconds(0.5));

                await WPFHelper.BeginInvoke(() =>
                {
                    this.MessageLabel.Content    = string.Empty;
                    this.MessageLabel.Visibility = Visibility.Collapsed;
                },
                                            DispatcherPriority.ApplicationIdle);
            };

            // AddLogLine
            this.AddLogLineButton.Click += async(x, y) => await this.AddLogLineAsync();

            this.AddLogLineTextBox.KeyDown += async(x, y) =>
            {
                if (y.Key == Key.Enter)
                {
                    if (!string.IsNullOrEmpty(this.AddLogLineTextBox.Text))
                    {
                        this.LogLine = this.AddLogLineTextBox.Text;
                    }

                    await this.AddLogLineAsync();
                }
            };
        }
        private void ApplyButton_Click(
            object sender,
            RoutedEventArgs e)
        {
            void ifdo(bool b, Action a)
            {
                if (b)
                {
                    a.Invoke();
                }
            }

            void copySpell(Spell d, Spell s)
            {
                ifdo(this.CopyFont, () => d.Font                                 = s.Font.Clone() as FontInfo);
                ifdo(this.CopyFontFill, () => d.FontColor                        = s.FontColor);
                ifdo(this.CopyFontStrokke, () => d.FontOutlineColor              = s.FontOutlineColor);
                ifdo(this.CopyFontWarningFill, () => d.WarningFontColor          = s.WarningFontColor);
                ifdo(this.CopyFontWarningStroke, () => d.WarningFontOutlineColor = s.WarningFontOutlineColor);
                ifdo(this.CopyProgressBarSize, () => d.BarHeight                 = s.BarHeight);
                ifdo(this.CopyProgressBarSize, () => d.BarWidth                  = s.BarWidth);
                ifdo(this.CopyProgressBarFill, () => d.BarColor                  = s.BarColor);
                ifdo(this.CopyProgressBarStroke, () => d.BarOutlineColor         = s.BarOutlineColor);
                ifdo(this.CopyBackground, () => d.BackgroundColor                = s.BackgroundColor);
                ifdo(this.CopyBackground, () => d.BackgroundAlpha                = s.BackgroundAlpha);
                ifdo(this.CopyIconSize, () => d.SpellIconSize                    = s.SpellIconSize);
                ifdo(this.CopyIconOverlapRecastTime, () => d.OverlapRecastTime   = s.OverlapRecastTime);
                ifdo(this.CopyIconToDarkness, () => d.ReduceIconBrightness       = s.ReduceIconBrightness);
                ifdo(this.CopyIconHideSpellName, () => d.HideSpellName           = s.HideSpellName);
            }

            void copyTicker(Ticker d, Ticker s)
            {
                ifdo(this.CopyFont, () => d.Font                    = s.Font.Clone() as FontInfo);
                ifdo(this.CopyFontFill, () => d.FontColor           = s.FontColor);
                ifdo(this.CopyFontStrokke, () => d.FontOutlineColor = s.FontOutlineColor);
                ifdo(this.CopyBackground, () => d.BackgroundColor   = s.BackgroundColor);
                ifdo(this.CopyBackground, () => d.BackgroundAlpha   = s.BackgroundAlpha);
                ifdo(this.CopyX, () => d.Left = s.Left);
                ifdo(this.CopyY, () => d.Top  = s.Top);
            }

            if (this.IsSpell)
            {
                var src = this.SourceConfig as Spell;

                foreach (var item in this.Spells)
                {
                    switch (item)
                    {
                    case SpellPanel panel:
                        foreach (Spell spell in panel.Children)
                        {
                            if (spell.IsChecked)
                            {
                                copySpell(spell, src);
                            }
                        }
                        break;

                    case Spell spell:
                        if (spell.IsChecked)
                        {
                            copySpell(spell, src);
                        }
                        break;
                    }

                    (item as ITreeItem).IsChecked = false;
                }
            }

            if (this.IsTicker)
            {
                var src = this.SourceConfig as Ticker;

                foreach (var item in this.Tickers)
                {
                    if (item is Ticker ticker)
                    {
                        if (ticker.IsChecked)
                        {
                            copyTicker(ticker, src);
                        }
                    }

                    (item as ITreeItem).IsChecked = false;
                }
            }

            this.Close();

            ModernMessageBox.ShowDialog(
                "Done!",
                "ACT.Hojoring");
        }
        public static bool ShowDialog(
            string message,
            string caption,
            MessageBoxButton button = MessageBoxButton.OK,
            Exception ex            = null)
        {
            var view = new ModernMessageBox()
            {
                Message = message,
                Caption = caption,
            };

            if (button == MessageBoxButton.OKCancel)
            {
                view.CancelButton.Visibility = Visibility.Visible;
            }
            else
            {
                view.CancelButton.Visibility = Visibility.Collapsed;
            }

            view.Details = string.Empty;

            if (ex != null)
            {
                var info = ex.GetType().ToString() + Environment.NewLine + Environment.NewLine;
                info += ex.Message + Environment.NewLine;
                info += ex.StackTrace.ToString();

                if (ex.InnerException != null)
                {
                    info += Environment.NewLine + Environment.NewLine;
                    info += "Inner Exception :" + Environment.NewLine;
                    info += ex.InnerException.GetType().ToString() + Environment.NewLine + Environment.NewLine;
                    info += ex.InnerException.Message + Environment.NewLine;
                    info += ex.InnerException.StackTrace.ToString();
                }

                view.Details = info;
            }

            if (view.HasDetails)
            {
                view.WindowBorderBrush = Brushes.OrangeRed;
                SystemSounds.Beep.Play();
            }
            else
            {
                view.WindowBorderBrush = Brushes.Gold;
                view.SizeToContent     = SizeToContent.WidthAndHeight;
                SystemSounds.Asterisk.Play();
            }

            view.RaisePropertyChanged(nameof(WindowBorderBrush));
            view.RaisePropertyChanged(nameof(Caption));
            view.RaisePropertyChanged(nameof(Message));
            view.RaisePropertyChanged(nameof(Details));
            view.RaisePropertyChanged(nameof(HasDetails));

            return(view.ShowDialog() ?? false);
        }