private async void BtnScreenhot_Click(object sender, RoutedEventArgs e)
		{
			if(Helper.MainWindow.DeckPickerList.SelectedDeck == null) return;
			var screenShotWindow = new PlayerWindow(Config.Instance, Helper.MainWindow.DeckPickerList.SelectedDeck.Cards, true);
			screenShotWindow.Show();
			screenShotWindow.Top = 0;
			screenShotWindow.Left = 0;
			await Task.Delay(100);
			var source = PresentationSource.FromVisual(screenShotWindow);
			if(source == null) return;

			var dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
			var dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;

			var fileName = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, dpiX, dpiY,
			                                     Helper.MainWindow.DeckPickerList.SelectedDeck.Name);

			screenShotWindow.Shutdown();
			if(fileName == null)
				await Helper.MainWindow.ShowMessageAsync("", "Error saving screenshot");
			else
				await Helper.MainWindow.ShowSavedFileMessage(fileName, "Screenshots");

			After_Click();
		}
Esempio n. 2
0
 private void Window_Closing_1(object sender, CancelEventArgs e)
 {
     try
     {
         _overlay.Close();
         _logReader.Stop();
         _updateThread.Abort();
         _playerWindow.Shutdown();
         _opponentWindow.Shutdown();
         _xmlManagerConfig.Save("config.xml", _config);
     }
     catch (Exception)
     {
         //doesnt matter
     }
 }
        private async void BtnScreenhot_Click(object sender, RoutedEventArgs e)
        {
            var selectedDeck = DeckPickerList.SelectedDecks.FirstOrDefault();

            if (selectedDeck == null)
            {
                return;
            }
            Logger.WriteLine("Creating screenshot of " + selectedDeck.GetSelectedDeckVersion().GetDeckInfo(), "Screenshot");
            var screenShotWindow = new PlayerWindow(Config.Instance, selectedDeck.GetSelectedDeckVersion().Cards, true);

            screenShotWindow.Show();
            screenShotWindow.Top  = 0;
            screenShotWindow.Left = 0;
            await Task.Delay(100);

            var source = PresentationSource.FromVisual(screenShotWindow);

            if (source == null)
            {
                return;
            }

            var dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
            var dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;

            var deck       = DeckList.Instance.ActiveDeckVersion;
            var pngEncoder = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, dpiX, dpiY, deck.Name);

            screenShotWindow.Shutdown();

            if (pngEncoder != null)
            {
                var fileName = Helper.ShowSaveFileDialog(Helper.RemoveInvalidFileNameChars(deck.Name), "png");

                if (fileName != null)
                {
                    using (var stream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
                        pngEncoder.Save(stream);

                    await this.ShowSavedFileMessage(fileName);

                    Logger.WriteLine("Saved screenshot of " + deck.GetDeckInfo() + " to file: " + fileName, "Export");
                }
            }
        }
Esempio n. 4
0
        private async void BtnScreenhot_Click(object sender, RoutedEventArgs e)
        {
            if (Helper.MainWindow.DeckPickerList.SelectedDeck == null)
            {
                return;
            }
            var screenShotWindow = new PlayerWindow(Config.Instance, Helper.MainWindow.DeckPickerList.SelectedDeck.Cards, true);

            screenShotWindow.Show();
            screenShotWindow.Top  = 0;
            screenShotWindow.Left = 0;
            await Task.Delay(100);

            var source = PresentationSource.FromVisual(screenShotWindow);

            if (source == null)
            {
                return;
            }

            var dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
            var dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;

            var fileName = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, dpiX, dpiY,
                                                 Helper.MainWindow.DeckPickerList.SelectedDeck.Name);

            screenShotWindow.Shutdown();
            if (fileName == null)
            {
                await Helper.MainWindow.ShowMessageAsync("", "Error saving screenshot");
            }
            else
            {
                await Helper.MainWindow.ShowSavedFileMessage(fileName, "Screenshots");
            }

            After_Click();
        }
Esempio n. 5
0
        private async void BtnScreenhot_Click(object sender, RoutedEventArgs e)
        {
            if (DeckList.Instance.ActiveDeck == null)
            {
                return;
            }
            Logger.WriteLine("Creating screenshot of " + DeckList.Instance.ActiveDeckVersion.GetDeckInfo(), "Screenshot");
            var screenShotWindow = new PlayerWindow(Config.Instance, DeckList.Instance.ActiveDeckVersion.Cards, true);

            screenShotWindow.Show();
            screenShotWindow.Top  = 0;
            screenShotWindow.Left = 0;
            await Task.Delay(100);

            var source = PresentationSource.FromVisual(screenShotWindow);

            if (source == null)
            {
                return;
            }

            var dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
            var dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;

            var fileName = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, dpiX, dpiY, DeckList.Instance.ActiveDeckVersion.Name);

            screenShotWindow.Shutdown();
            if (fileName == null)
            {
                await this.ShowMessageAsync("", "Error saving screenshot");
            }
            else
            {
                await ShowSavedFileMessage(fileName, "Screenshots");
            }
        }
		private async void BtnScreenhot_Click(object sender, RoutedEventArgs e)
		{
			var selectedDeck = DeckPickerList.SelectedDecks.FirstOrDefault();
            if(selectedDeck == null)
				return;
			Logger.WriteLine("Creating screenshot of " + selectedDeck.GetSelectedDeckVersion().GetDeckInfo(), "Screenshot");
			var screenShotWindow = new PlayerWindow(Config.Instance, selectedDeck.GetSelectedDeckVersion().Cards, true);
			screenShotWindow.Show();
			screenShotWindow.Top = 0;
			screenShotWindow.Left = 0;
			await Task.Delay(100);
			var source = PresentationSource.FromVisual(screenShotWindow);
			if(source == null)
				return;

			var dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
			var dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;

			var deck = DeckList.Instance.ActiveDeckVersion;
			var pngEncoder = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, dpiX, dpiY, deck.Name);
			screenShotWindow.Shutdown();

			if(pngEncoder != null)
			{
				var fileName = Helper.ShowSaveFileDialog(Helper.RemoveInvalidFileNameChars(deck.Name), "png");

				if(fileName != null)
				{
					using(var stream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
						pngEncoder.Save(stream);

					await this.ShowSavedFileMessage(fileName);
					Logger.WriteLine("Saved screenshot of " + deck.GetDeckInfo() + " to file: " + fileName, "Export");
				}
			}
		}
		private async void BtnScreenhot_Click(object sender, RoutedEventArgs e)
		{
			var selectedDeck = DeckPickerList.SelectedDecks.FirstOrDefault();
			if(selectedDeck == null)
				return;
			Logger.WriteLine("Creating screenshot of " + selectedDeck.GetSelectedDeckVersion().GetDeckInfo(), "Screenshot");
			var screenShotWindow = new PlayerWindow(Config.Instance, selectedDeck.GetSelectedDeckVersion().Cards, true);
			screenShotWindow.Show();
			screenShotWindow.Top = 0;
			screenShotWindow.Left = 0;
			await Task.Delay(100);
			var source = PresentationSource.FromVisual(screenShotWindow);
			if(source == null)
				return;

			var dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
			var dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;

			var deck = selectedDeck.GetSelectedDeckVersion();
			var pngEncoder = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, dpiX, dpiY, deck.Name);
			screenShotWindow.Shutdown();

			if(pngEncoder != null)
			{
				var saveOperation = await this.ShowScreenshotUploadSelectionDialog();
				var tmpFile = new FileInfo(Path.Combine(Config.Instance.DataDir, string.Format("tmp{0}.png", DateTime.Now.ToFileTime())));
				var fileName = saveOperation.SaveLocal
					               ? Helper.ShowSaveFileDialog(Helper.RemoveInvalidFileNameChars(deck.Name), "png") : tmpFile.FullName;
				if(fileName != null)
				{
					string imgurUrl = null;
					using(var ms = new MemoryStream())
					using(var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
					{
						pngEncoder.Save(ms);
						ms.WriteTo(fs);
						if(saveOperation.Upload)
						{
							var controller = await this.ShowProgressAsync("Uploading...", "");
							imgurUrl = await Imgur.Upload(Config.Instance.ImgurClientId, ms, deck.Name);
							await controller.CloseAsync();
						}
					}

					if(imgurUrl != null)
					{
						await this.ShowSavedAndUploadedFileMessage(saveOperation.SaveLocal ? fileName : null, imgurUrl);
						Logger.WriteLine("Uploaded screenshot to " + imgurUrl, "Export");
					}
					else
						await this.ShowSavedFileMessage(fileName);
					Logger.WriteLine("Saved screenshot of " + deck.GetDeckInfo() + " to file: " + fileName, "Export");
				}
				if(tmpFile.Exists)
				{
					try
					{
						tmpFile.Delete();
					}
					catch(Exception ex)
					{
						Logger.WriteLine(ex.ToString(), "ExportScreenshot");
					}
				}
			}
		}
Esempio n. 8
0
        private async void BtnScreenhot_Click(object sender, RoutedEventArgs e)
        {
            var selectedDeck = DeckPickerList.SelectedDecks.FirstOrDefault();

            if (selectedDeck == null)
            {
                return;
            }
            Logger.WriteLine("Creating screenshot of " + selectedDeck.GetSelectedDeckVersion().GetDeckInfo(), "Screenshot");
            var screenShotWindow = new PlayerWindow(_game, selectedDeck.Cards.ToSortedCardList());

            screenShotWindow.Show();
            screenShotWindow.Top  = 0;
            screenShotWindow.Left = 0;
            await Task.Delay(100);

            var source = PresentationSource.FromVisual(screenShotWindow);

            if (source == null)
            {
                return;
            }

            //adjusting the DPI is apparently no longer/not necessary?
            var dpiX = 96.0;             //* source.CompositionTarget.TransformToDevice.M11;
            var dpiY = 96.0;             //* source.CompositionTarget.TransformToDevice.M22;

            var deck       = selectedDeck.GetSelectedDeckVersion();
            var pngEncoder = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, 96, 96, deck.Name);

            screenShotWindow.Shutdown();

            if (pngEncoder != null)
            {
                var saveOperation = await this.ShowScreenshotUploadSelectionDialog();

                var tmpFile  = new FileInfo(Path.Combine(Config.Instance.DataDir, string.Format("tmp{0}.png", DateTime.Now.ToFileTime())));
                var fileName = saveOperation.SaveLocal
                                                       ? Helper.ShowSaveFileDialog(Helper.RemoveInvalidFileNameChars(deck.Name), "png") : tmpFile.FullName;
                if (fileName != null)
                {
                    string imgurUrl = null;
                    using (var ms = new MemoryStream())
                        using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
                        {
                            pngEncoder.Save(ms);
                            ms.WriteTo(fs);
                            if (saveOperation.Upload)
                            {
                                var controller = await this.ShowProgressAsync("Uploading...", "");

                                imgurUrl = await Imgur.Upload(Config.Instance.ImgurClientId, ms, deck.Name);

                                await controller.CloseAsync();
                            }
                        }

                    if (imgurUrl != null)
                    {
                        await this.ShowSavedAndUploadedFileMessage(saveOperation.SaveLocal?fileName : null, imgurUrl);

                        Logger.WriteLine("Uploaded screenshot to " + imgurUrl, "Export");
                    }
                    else
                    {
                        await this.ShowSavedFileMessage(fileName);
                    }
                    Logger.WriteLine("Saved screenshot of " + deck.GetDeckInfo() + " to file: " + fileName, "Export");
                }
                if (tmpFile.Exists)
                {
                    try
                    {
                        tmpFile.Delete();
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLine(ex.ToString(), "ExportScreenshot");
                    }
                }
            }
        }
        private async void Window_Closing(object sender, CancelEventArgs e)
        {
            try
            {
                _doUpdate = false;

                //wait for update to finish, might otherwise crash when overlay gets disposed
                for (var i = 0; i < 100; i++)
                {
                    if (_canShowDown)
                    {
                        break;
                    }
                    await Task.Delay(50);
                }

                Config.Instance.SelectedTags = Config.Instance.SelectedTags.Distinct().ToList();
                Config.Instance.ShowAllDecks = DeckPickerList.ShowAll;

                Config.Instance.WindowWidth       = (int)(Width - (GridNewDeck.Visibility == Visibility.Visible ? GridNewDeck.ActualWidth : 0));
                Config.Instance.WindowHeight      = (int)Height;
                Config.Instance.TrackerWindowTop  = (int)Top;
                Config.Instance.TrackerWindowLeft = (int)Left;

                //position of add. windows is NaN if they were never opened.
                if (!double.IsNaN(PlayerWindow.Left))
                {
                    Config.Instance.PlayerWindowLeft = (int)PlayerWindow.Left;
                }
                if (!double.IsNaN(PlayerWindow.Top))
                {
                    Config.Instance.PlayerWindowTop = (int)PlayerWindow.Top;
                }
                Config.Instance.PlayerWindowHeight = (int)PlayerWindow.Height;

                if (!double.IsNaN(OpponentWindow.Left))
                {
                    Config.Instance.OpponentWindowLeft = (int)OpponentWindow.Left;
                }
                if (!double.IsNaN(OpponentWindow.Top))
                {
                    Config.Instance.OpponentWindowTop = (int)OpponentWindow.Top;
                }
                Config.Instance.OpponentWindowHeight = (int)OpponentWindow.Height;

                if (!double.IsNaN(TimerWindow.Left))
                {
                    Config.Instance.TimerWindowLeft = (int)TimerWindow.Left;
                }
                if (!double.IsNaN(TimerWindow.Top))
                {
                    Config.Instance.TimerWindowTop = (int)TimerWindow.Top;
                }
                Config.Instance.TimerWindowHeight = (int)TimerWindow.Height;
                Config.Instance.TimerWindowWidth  = (int)TimerWindow.Width;

                if (!double.IsNaN(StatsWindow.Left))
                {
                    Config.Instance.StatsWindowLeft = (int)StatsWindow.Left;
                }
                if (!double.IsNaN(StatsWindow.Top))
                {
                    Config.Instance.StatsWindowTop = (int)StatsWindow.Top;
                }
                Config.Instance.StatsWindowHeight = (int)StatsWindow.Height;
                Config.Instance.StatsWindowWidth  = (int)StatsWindow.Width;

                _notifyIcon.Visible = false;
                Overlay.Close();
                HsLogReader.Instance.Stop();
                TimerWindow.Shutdown();
                PlayerWindow.Shutdown();
                OpponentWindow.Shutdown();
                StatsWindow.Shutdown();
                Config.Save();
                WriteDecks();
            }
            catch (Exception)
            {
                //doesnt matter
            }
        }
		private async void DeckOptionsFlyoutBtnScreenhot_Click(object sender, RoutedEventArgs e)
		{
			if (DeckPickerList.SelectedDeck == null) return;
			PlayerWindow screenShotWindow = new PlayerWindow(_config, DeckPickerList.SelectedDeck.Cards, true);
			screenShotWindow.Show();
			screenShotWindow.Top = 0;
			screenShotWindow.Left = 0;
			await Task.Delay(100);
			PresentationSource source = PresentationSource.FromVisual(screenShotWindow);
			if (source == null) return;

			double dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
			double dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;

			var fileName = Helper.ScreenshotDeck(screenShotWindow.ListViewPlayer, dpiX, dpiY, DeckPickerList.SelectedDeck.Name);

			screenShotWindow.Shutdown();
			if (fileName == null)
			{
				await this.ShowMessageAsync("", "Error saving screenshot");
			}
			else
			{
				await ShowSavedFileMessage(fileName, "Screenshots");
			}
		}