protected override void OnClosing(CancelEventArgs e)
        {
            var rMode = Preference.Instance.UI.CloseConfirmationMode.Value;
            if (rMode == ConfirmationMode.Always || (rMode == ConfirmationMode.DuringSortie && KanColleGame.Current.Sortie is SortieInfo))
            {
                var rDialog = new TaskDialog()
                {
                    Caption = StringResources.Instance.Main.Product_Name,
                    Instruction = StringResources.Instance.Main.Window_ClosingConfirmation_Instruction,
                    Icon = TaskDialogIcon.Information,
                    Buttons =
                    {
                        new TaskDialogCommandLink(TaskDialogCommonButton.Yes, StringResources.Instance.Main.Window_ClosingConfirmation_Button_Yes),
                        new TaskDialogCommandLink(TaskDialogCommonButton.No, StringResources.Instance.Main.Window_ClosingConfirmation_Button_No),
                    },
                    DefaultCommonButton = TaskDialogCommonButton.No,

                    OwnerWindow = this,
                    ShowAtTheCenterOfOwner = true,
                };
                if (rDialog.ShowAndDispose().ClickedCommonButton == TaskDialogCommonButton.No)
                {
                    e.Cancel = true;
                    return;
                }
            }

            base.OnClosing(e);
        }
        protected override void OnClosing(CancelEventArgs e)
        {
            var rMode = Preference.Instance.UI.CloseConfirmationMode.Value;

            if (rMode == ConfirmationMode.Always || (rMode == ConfirmationMode.DuringSortie && KanColleGame.Current.Sortie is SortieInfo && !(KanColleGame.Current.Sortie is PracticeInfo)))
            {
                var rDialog = new TaskDialog()
                {
                    Caption     = StringResources.Instance.Main.Product_Name,
                    Instruction = StringResources.Instance.Main.Window_ClosingConfirmation_Instruction,
                    Icon        = TaskDialogIcon.Information,
                    Buttons     =
                    {
                        new TaskDialogCommandLink(TaskDialogCommonButton.Yes, StringResources.Instance.Main.Window_ClosingConfirmation_Button_Yes),
                        new TaskDialogCommandLink(TaskDialogCommonButton.No,  StringResources.Instance.Main.Window_ClosingConfirmation_Button_No),
                    },
                    DefaultCommonButton = TaskDialogCommonButton.No,

                    OwnerWindow            = this,
                    ShowAtTheCenterOfOwner = true,
                };
                if (rDialog.ShowAndDispose().ClickedCommonButton == TaskDialogCommonButton.No)
                {
                    e.Cancel = true;
                    return;
                }
            }

            base.OnClosing(e);
        }
Exemple #3
0
        void SetCookie()
        {
            var rYear   = DateTime.Now.AddYears(4).ToString("yyyy");
            var rScript = $"javascript:void(eval(\"document.cookie = 'ckcy=1;expires=Sun, 09 Feb {rYear} 09:00:09 GMT;domain=osapi.dmm.com;path=/'; document.cookie = 'ckcy=1;expires=Sun, 09 Feb  {rYear} 09:00:09 GMT;domain=203.104.209.7;path=/'; document.cookie = 'ckcy=1;expires=Sun, 09 Feb  {rYear} 09:00:09 GMT;domain=www.dmm.com;path=/netgame/';\")); location.href = \"{Url}\";";

            Uri rUri;

            if (!Uri.TryCreate(rScript, UriKind.Absolute, out rUri))
            {
                return;
            }

            r_Owner.Communicator.Write(CommunicatorMessages.Navigate + ":" + rUri.ToString());

            var rDialog = new TaskDialog()
            {
                Caption     = StringResources.Instance.Main.Product_Name,
                Instruction = StringResources.Instance.Main.Browser_Navigator_SetCookie_Instruction,
                Icon        = TaskDialogIcon.Information,

                OwnerWindow            = App.Current.MainWindow,
                ShowAtTheCenterOfOwner = true,
            };

            rDialog.ShowAndDispose();
        }
        void HttpOnly_Checked(object sender, RoutedEventArgs e)
        {
            if (!HttpOnly.IsChecked.Value)
            {
                return;
            }

            var rDialog = new TaskDialog()
            {
                Caption     = StringResources.Instance.Main.Product_Name,
                Instruction = StringResources.Instance.Main.PreferenceWindow_Network_UseUpstreamProxy_HttpOnly_Dialog_Instruction,
                Icon        = TaskDialogIcon.Information,
                Content     = StringResources.Instance.Main.PreferenceWindow_Network_UseUpstreamProxy_HttpOnly_Dialog_Content,
                Buttons     =
                {
                    new TaskDialogButton(TaskDialogCommonButton.Yes, StringResources.Instance.Main.PreferenceWindow_Network_UseUpstreamProxy_HttpOnly_Dialog_Button_Yes),
                    new TaskDialogButton(TaskDialogCommonButton.No,  StringResources.Instance.Main.PreferenceWindow_Network_UseUpstreamProxy_HttpOnly_Dialog_Button_No),
                },
                DefaultCommonButton = TaskDialogCommonButton.No,

                OwnerWindow            = WindowUtil.GetTopWindow(),
                ShowAtTheCenterOfOwner = true,
            };

            if (rDialog.ShowAndDispose().ClickedCommonButton == TaskDialogCommonButton.No)
            {
                HttpOnly.IsChecked = false;
            }
        }
Exemple #5
0
        void ShowUnhandledExceptionDialog(Exception rpException)
        {
            var rLogFilename = Logger.GetNewExceptionLogFilename();

            try
            {
                using (var rStreamWriter = new StreamWriter(Logger.GetNewExceptionLogFilename(), false, new UTF8Encoding(true)))
                {
                    rStreamWriter.WriteLine("Unhandled Exception:");
                    rStreamWriter.WriteLine();
                    rStreamWriter.WriteLine(rpException.ToString());
                    rStreamWriter.WriteLine();
                }
            }
            catch
            {
                rLogFilename = null;
            }

            var rDialog = new TaskDialog()
            {
                Caption     = UnhandledExceptionDialogStringResources.ProductName,
                Instruction = UnhandledExceptionDialogStringResources.Instruction,
                Icon        = TaskDialogIcon.Error,
                Content     = UnhandledExceptionDialogStringResources.Content,

                Detail = rpException.ToString(),
                ShowDetailAtTheBottom = true,

                OwnerWindowHandle      = r_MainWindowHandle,
                ShowAtTheCenterOfOwner = true,
            };

            if (rLogFilename != null)
            {
                rDialog.EnableHyperlinks = true;
                rDialog.FooterIcon       = TaskDialogIcon.Information;
                rDialog.Footer           = string.Format(UnhandledExceptionDialogStringResources.Footer, $"<a href=\"{rLogFilename}\">{rLogFilename}</a>");

                EventHandler <string> rHyperlinkClicked = null;
                rHyperlinkClicked = delegate
                {
                    if (File.Exists(rLogFilename))
                    {
                        Process.Start(rLogFilename);
                    }
                };
                EventHandler rClosed = null;
                rClosed = delegate
                {
                    rDialog.HyperlinkClicked -= rHyperlinkClicked;
                    rDialog.Closed           -= rClosed;
                };
                rDialog.HyperlinkClicked += rHyperlinkClicked;
                rDialog.Closed           += rClosed;
            }

            rDialog.ShowAndDispose();
        }
Exemple #6
0
        public void GenerateCode()
        {
            var rText = GenerateCodeCore();

            if (Preference.Instance.Game.CompositionSharing_AutoOpenBrowser.Value)
            {
                Process.Start("http://kancolle-calc.net/deckbuilder.html?predeck=" + rText);
                return;
            }

            Clipboard.SetDataObject(rText);

            var rDialog = new TaskDialog()
            {
                Caption     = StringResources.Instance.Main.Window_CompositionSharing,
                Instruction = StringResources.Instance.Main.CompositionSharing_GenerateCode_CopyToClipboard_Message,
                Icon        = TaskDialogIcon.Information,

                OwnerWindow            = WindowUtil.GetTopWindow(),
                ShowAtTheCenterOfOwner = true,
            };

            rDialog.ShowAndDispose();
        }
        void HttpOnly_Checked(object sender, RoutedEventArgs e)
        {
            if (!HttpOnly.IsChecked.Value)
                return;

            var rDialog = new TaskDialog()
            {
                Caption = StringResources.Instance.Main.Product_Name,
                Instruction = StringResources.Instance.Main.PreferenceWindow_Network_UseUpstreamProxy_HttpOnly_Dialog_Instruction,
                Icon = TaskDialogIcon.Information,
                Content = StringResources.Instance.Main.PreferenceWindow_Network_UseUpstreamProxy_HttpOnly_Dialog_Content,
                Buttons =
                {
                    new TaskDialogButton(TaskDialogCommonButton.Yes, StringResources.Instance.Main.PreferenceWindow_Network_UseUpstreamProxy_HttpOnly_Dialog_Button_Yes),
                    new TaskDialogButton(TaskDialogCommonButton.No, StringResources.Instance.Main.PreferenceWindow_Network_UseUpstreamProxy_HttpOnly_Dialog_Button_No),
                },
                DefaultCommonButton = TaskDialogCommonButton.No,

                OwnerWindow = WindowUtil.GetTopWindow(),
                ShowAtTheCenterOfOwner = true,
            };
            if (rDialog.ShowAndDispose().ClickedCommonButton == TaskDialogCommonButton.No)
                HttpOnly.IsChecked = false;
        }
        void ShowUnhandledExceptionDialog(Exception rpException)
        {
            var rLogFilename = Logger.GetNewExceptionLogFilename();
            try
            {
                using (var rStreamWriter = new StreamWriter(Logger.GetNewExceptionLogFilename(), false, new UTF8Encoding(true)))
                {
                    rStreamWriter.WriteLine("Unhandled Exception:");
                    rStreamWriter.WriteLine();
                    rStreamWriter.WriteLine(rpException.ToString());
                    rStreamWriter.WriteLine();
                }
            }
            catch
            {
                rLogFilename = null;
            }

            var rDialog = new TaskDialog()
            {
                Caption = UnhandledExceptionDialogStringResources.ProductName,
                Instruction = UnhandledExceptionDialogStringResources.Instruction,
                Icon = TaskDialogIcon.Error,
                Content = UnhandledExceptionDialogStringResources.Content,

                Detail = rpException.ToString(),
                ShowDetailAtTheBottom = true,

                OwnerWindowHandle = r_MainWindowHandle,
                ShowAtTheCenterOfOwner = true,
            };

            if (rLogFilename != null)
            {
                rDialog.EnableHyperlinks = true;
                rDialog.FooterIcon = TaskDialogIcon.Information;
                rDialog.Footer = string.Format(UnhandledExceptionDialogStringResources.Footer, $"<a href=\"{rLogFilename}\">{rLogFilename}</a>");

                EventHandler<string> rHyperlinkClicked = null;
                rHyperlinkClicked = delegate
                {
                    if (File.Exists(rLogFilename))
                        Process.Start(rLogFilename);
                };
                EventHandler rClosed = null;
                rClosed = delegate
                {
                    rDialog.HyperlinkClicked -= rHyperlinkClicked;
                    rDialog.Closed -= rClosed;
                };
                rDialog.HyperlinkClicked += rHyperlinkClicked;
                rDialog.Closed += rClosed;
            }

            rDialog.ShowAndDispose();
        }
Exemple #9
0
        public void TakeScreenshot(object rpTabControl)
        {
            var rTabControl = rpTabControl as Control;

            if (rTabControl == null)
            {
                return;
            }

            var rContent = rTabControl.Template.FindName("PART_SelectedContentHost", rTabControl) as ContentPresenter;

            if (rContent == null)
            {
                return;
            }

            var rRenderTargetBitmap = new RenderTargetBitmap((int)(rContent.ActualWidth * DpiUtil.ScaleX), (int)(rContent.ActualHeight * DpiUtil.ScaleY), DpiUtil.DpiX, DpiUtil.DpiY, PixelFormats.Pbgra32);

            rRenderTargetBitmap.Render(rContent);

            var rScreenshotFilename = string.Empty;

            var rOutputToFile = Preference.Instance.Game.CompositionSharing_OutputScreenshotToFile.Value;

            if (!rOutputToFile)
            {
                Clipboard.SetImage(rRenderTargetBitmap);
            }
            else
            {
                using (var rSaveDialog = new CommonSaveFileDialog())
                {
                    rSaveDialog.FileTypes.Add(new CommonFileDialogFileType("PNG", "png"));

                    if (rSaveDialog.Show(WindowUtil.GetTopWindow()) == CommonFileDialogResult.Cancel)
                    {
                        return;
                    }

                    rScreenshotFilename = rSaveDialog.Filename;

                    if (!rScreenshotFilename.OICEndsWith(".png"))
                    {
                        rScreenshotFilename += ".png";
                    }
                }

                using (var rFile = File.OpenWrite(rScreenshotFilename))
                {
                    var rEncoder = new PngBitmapEncoder()
                    {
                        Frames = { BitmapFrame.Create(rRenderTargetBitmap) }
                    };
                    rEncoder.Save(rFile);
                }
            }

            var rDialog = new TaskDialog()
            {
                Caption     = StringResources.Instance.Main.Window_CompositionSharing,
                Instruction = StringResources.Instance.Main.CompositionSharing_TakeScreenshot_Clipboard_Message,
                Icon        = TaskDialogIcon.Information,

                OwnerWindow            = WindowUtil.GetTopWindow(),
                ShowAtTheCenterOfOwner = true,
            };

            if (!rOutputToFile)
            {
                rDialog.Instruction = StringResources.Instance.Main.CompositionSharing_TakeScreenshot_Clipboard_Message;
            }
            else
            {
                rDialog.Instruction      = StringResources.Instance.Main.CompositionSharing_TakeScreenshot_File_Message;
                rDialog.EnableHyperlinks = true;
                rDialog.FooterIcon       = TaskDialogIcon.Information;
                rDialog.Footer           = $"<a href=\"{rScreenshotFilename}\">{rScreenshotFilename}</a>";

                EventHandler <string> rHyperlinkClicked = null;
                rHyperlinkClicked = delegate
                {
                    if (File.Exists(rScreenshotFilename))
                    {
                        Process.Start(rScreenshotFilename);
                    }
                };
                EventHandler rClosed = null;
                rClosed = delegate
                {
                    rDialog.HyperlinkClicked -= rHyperlinkClicked;
                    rDialog.Closed           -= rClosed;
                };
                rDialog.HyperlinkClicked += rHyperlinkClicked;
                rDialog.Closed           += rClosed;
            }

            rDialog.ShowAndDispose();
        }
        void RestartGame()
        {
            var rMode = Preference.Instance.Browser.RefreshConfirmationMode.Value;
            if (rMode == ConfirmationMode.Always || (rMode == ConfirmationMode.DuringSortie && KanColleGame.Current.Sortie is SortieInfo))
            {
                var rDialog = new TaskDialog()
                {
                    Caption = StringResources.Instance.Main.Product_Name,
                    Instruction = StringResources.Instance.Main.Browser_RestartConfirmation_Instruction,
                    Icon = TaskDialogIcon.Information,
                    Buttons =
                    {
                        new TaskDialogCommandLink(TaskDialogCommonButton.Yes, StringResources.Instance.Main.Browser_RestartConfirmation_Button_Refresh),
                        new TaskDialogCommandLink(TaskDialogCommonButton.No, StringResources.Instance.Main.Browser_RestartConfirmation_Button_Stay),
                    },
                    DefaultCommonButton = TaskDialogCommonButton.No,

                    OwnerWindow = App.Current.MainWindow,
                    ShowAtTheCenterOfOwner = true,
                };

                if (rDialog.ShowAndDispose().ClickedCommonButton == TaskDialogCommonButton.No)
                    return;
            }

            r_Owner.Navigator.Refresh();
        }
        void SetCookie()
        {
            var rYear = DateTime.Now.AddYears(4).ToString("yyyy");
            var rScript = $"javascript:void(eval(\"document.cookie = 'ckcy=1;expires=Sun, 09 Feb {rYear} 09:00:09 GMT;domain=osapi.dmm.com;path=/'; document.cookie = 'ckcy=1;expires=Sun, 09 Feb  {rYear} 09:00:09 GMT;domain=203.104.209.7;path=/'; document.cookie = 'ckcy=1;expires=Sun, 09 Feb  {rYear} 09:00:09 GMT;domain=www.dmm.com;path=/netgame/';\")); location.href = \"{Url}\";";

            Uri rUri;
            if (!Uri.TryCreate(rScript, UriKind.Absolute, out rUri))
                return;

            r_Owner.Communicator.Write(CommunicatorMessages.Navigate + ":" + rUri.ToString());

            var rDialog = new TaskDialog()
            {
                Caption = StringResources.Instance.Main.Product_Name,
                Instruction = StringResources.Instance.Main.Browser_Navigator_SetCookie_Instruction,
                Icon = TaskDialogIcon.Information,

                OwnerWindow = App.Current.MainWindow,
                ShowAtTheCenterOfOwner = true,
            };

            rDialog.ShowAndDispose();
        }