Beispiel #1
0
        private async void SelectSaveDataPath_Click(object sender, RoutedEventArgs e)
        {
#if (!SQUIRREL)
            var dialog       = new FolderBrowserDialog();
            var dialogResult = dialog.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                var saveInAppData = Config.Instance.SaveDataInAppData.HasValue && Config.Instance.SaveDataInAppData.Value;
                if (!saveInAppData)
                {
                    foreach (var value in new List <bool> {
                        true, false
                    })
                    {
                        Config.Instance.SaveDataInAppData = value;
                        Helper.CopyReplayFiles();
                        DeckStatsList.SetupDeckStatsFile();
                        DeckList.SetupDeckListFile();
                        DefaultDeckStats.SetupDefaultDeckStatsFile();
                        Config.Instance.DataDirPath = dialog.SelectedPath;
                    }
                }
                Config.Instance.DataDirPath = dialog.SelectedPath;
                Config.Save();
                if (!saveInAppData)
                {
                    await MessageDialogs.ShowMessage(Core.MainWindow, "Restart required.", "Click ok to restart HDT");

                    Core.MainWindow.Restart();
                }
            }
#endif
        }
 public void OnPurchaseFailed(Product i, PurchaseFailureReason p)
 {
     MessageDialogs.ShowMessageDialog(
         "Store Error",
         "Failed to purchase product " + i.definition.storeSpecificId + ":\n" + p,
         "OK", null);
 }
 private void OnDisable( )
 {
     if (_instance == this)
     {
         _instance = null;
     }
 }
    public void BuyProductID(string id)
    {
        if (!IsInitialized( ))
        {
            MessageDialogs.ShowMessageDialog(
                "Store Error",
                "Store is not yet initialized.",
                "OK", null);
            return;
        }

        Product product = _storeController.products.WithID(productID);

        if (product == null)
        {
            MessageDialogs.ShowMessageDialog(
                "Store Error",
                "Problem retrieving product.",
                "OK", null);
            return;
        }

        // starting purchase, is async so will need some sort of loading pop-up
        _storeController.InitiatePurchase(product);
    }
Beispiel #5
0
        public async void CreateEdge()
        {
            if ((this.NewEdgeStart == null) ||
                (this.NewEdgeEnd == null))
            {
                return;
            }

            if (this.NewEdgeStart == this.NewEdgeEnd)
            {
                return;
            }

            if (this.NewEdgeEnd is FaultTreeTerminalNode && this.NewEdgeStart is FaultTreeTerminalNode)
            {
                string rateString = await MessageDialogs.ShowRateDialogAsync();

                double rate;
                if (double.TryParse(rateString, out rate) && rate >= 0)
                {
                    this.FaultTree.MarkovChain[(FaultTreeTerminalNode)this.NewEdgeStart, (FaultTreeTerminalNode)this.NewEdgeEnd] = rate;
                }
            }
            else
            {
                this.NewEdgeStart.Childs.Add(this.NewEdgeEnd);
            }

            this.RaisePropertyChanged("FaultTree");
        }
        public static bool AutoImportArena(ArenaImportingBehaviour behaviour, ArenaInfo info = null)
        {
            var deck = info ?? DeckImporter.FromArena();

            if (deck?.Deck.Cards.Sum(x => x.Count) != 30)
            {
                return(false);
            }
            Log.Info($"Found new complete {deck.Deck.Hero} arena deck!");
            var recentArenaDecks =
                DeckList.Instance.Decks.Where(d => d.IsArenaDeck && d.Cards.Sum(x => x.Count) == 30).OrderByDescending(
                    d => d.LastPlayedNewFirst).Take(15);

            if (recentArenaDecks.Any(d => d.Cards.All(c => deck.Deck.Cards.Any(c2 => c.Id == c2.Id && c.Count == c2.Count))))
            {
                Log.Info("...but we already have that one. Discarding.");
            }
            else if (Core.Game.IgnoredArenaDecks.Contains(deck.Deck.Id))
            {
                Log.Info("...but it was already discarded by the user. No automatic action taken.");
            }
            else if (behaviour == ArenaImportingBehaviour.AutoAsk)
            {
                MessageDialogs.ShowNewArenaDeckMessageAsync(Core.MainWindow, deck.Deck);
                return(true);
            }
            else if (behaviour == ArenaImportingBehaviour.AutoImportSave)
            {
                Log.Info("...auto saving new arena deck.");
                Core.MainWindow.ImportArenaDeck(deck.Deck);
                return(true);
            }
            return(false);
        }
Beispiel #7
0
        private static void parseOptionsFile()
        {
            string fileName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Options.txt");

            try
            {
                string[] lines = System.IO.File.ReadAllLines(fileName);
                for (int i = 0; i < lines.Length; ++i)
                {
                    if (lines[i].ToUpper().Contains("JedinstvenProgram".ToUpper()))
                    {
                        Options.Instance.JedinstvenProgram = bool.Parse(lines[i].Split(' ')[1].Trim());
                    }
                    else if (lines[i].ToUpper().Contains("IsProgramZaClanarinu".ToUpper()))
                    {
                        Options.Instance.IsProgramZaClanarinu = bool.Parse(lines[i].Split(' ')[1].Trim());
                    }
                    else if (lines[i].ToUpper().Contains("ClientPath".ToUpper()))
                    {
                        Options.Instance.ClientPath = lines[i].Split(' ')[1].Trim();
                    }
                }
            }
            catch (FileNotFoundException)
            {
                MessageDialogs.showMessage("Ne mogu da pronadjem fajl Options.txt", "Program za clanarinu");
            }
        }
 public void OnInitializeFailed(InitializationFailureReason error)
 {
     MessageDialogs.ShowMessageDialog(
         "Store Error",
         "Problem initializing:\n" + error,
         "OK", null);
 }
Beispiel #9
0
        private async void ButtonHearthstoneLogsDirectory_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new FolderBrowserDialog();

            dialog.SelectedPath = Config.Instance.HearthstoneDirectory;
            var dialogResult = dialog.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                //Logs directory needs to be a child directory in Hearthstone directory
                if (!dialog.SelectedPath.StartsWith(Config.Instance.HearthstoneDirectory + @"\"))
                {
                    await MessageDialogs.ShowMessage(Core.MainWindow, "Invalid argument", "Selected directory not in Hearthstone directory!");

                    return;
                }

                //Check if same path selected (no restart required)
                if (Config.Instance.HearthstoneLogsDirectoryName.Equals(dialog.SelectedPath))
                {
                    return;
                }

                Config.Instance.HearthstoneLogsDirectoryName = dialog.SelectedPath.Remove(0, Config.Instance.HearthstoneDirectory.Length + 1);
                Config.Save();

                await MessageDialogs.ShowMessage(Core.MainWindow, "Restart required.", "Click ok to restart HDT");

                Core.MainWindow.Restart();
            }
        }
        private void ButtonHSReplaynet_Click(object sender, RoutedEventArgs e)
        {
            var url = Helper.BuildHsReplayNetUrl("premium", "updatenotes");

            if (!Helper.TryOpenUrl(url))
            {
                MessageDialogs.ShowMessage(Core.MainWindow, "Could not start your browser", "You can find our premium page at https://hsreplay.net/premium/").Forget();
            }
        }
 private void ComboboxDeckLayout_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!_initialized)
     {
         return;
     }
     Config.Instance.DeckPickerItemLayout = (DeckLayout)ComboBoxDeckLayout.SelectedItem;
     Config.Save();
     MessageDialogs.ShowRestartDialog();
 }
Beispiel #12
0
 private void CheckBoxShowLastPlayedDate_Unchecked(object sender, RoutedEventArgs e)
 {
     if (!_initialized)
     {
         return;
     }
     Config.Instance.ShowLastPlayedDateOnDeck = false;
     Config.Save();
     MessageDialogs.ShowRestartDialog();
 }
 private void ComboboxIconSet_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!_initialized)
     {
         return;
     }
     Config.Instance.ClassIconStyle = (IconStyle)ComboBoxIconSet.SelectedItem;
     Config.Save();
     MessageDialogs.ShowRestartDialog();
 }
Beispiel #14
0
 private void CheckBoxAutoUse_OnUnchecked(object sender, RoutedEventArgs e)
 {
     if (!_initialized)
     {
         return;
     }
     Config.Instance.AutoUseDeck = false;
     Config.Save();
     MessageDialogs.ShowRestartDialog();
 }
 private void ComboBoxDateFormat_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!_initialized)
     {
         return;
     }
     Config.Instance.SelectedDateFormat = (DateFormat)ComboBoxDateFormat.SelectedItem;
     Config.Save();
     MessageDialogs.ShowRestartDialog();
 }
Beispiel #16
0
 private void CheckboxDeckPickerCaps_Unchecked(object sender, RoutedEventArgs e)
 {
     if (!_initialized)
     {
         return;
     }
     Config.Instance.DeckPickerCaps = false;
     Config.Save();
     MessageDialogs.ShowRestartDialog();
 }
Beispiel #17
0
 private void CheckboxTrackerCardToolTips_Unchecked(object sender, RoutedEventArgs e)
 {
     //this is probably somehow possible without restarting
     if (!_initialized)
     {
         return;
     }
     Config.Instance.TrackerCardToolTips = false;
     Config.Save();
     MessageDialogs.ShowRestartDialog();
 }
    // Use this for initialization
    void OnEnable( )
    {
        if ((_instance != null) && (_instance != this))
        {
            Debug.LogError("Attempting to create a second MessageDialogs instance, destroying new one.");
            Destroy(this);
            return;
        }

        _instance = this;
    }
Beispiel #19
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            DialogResult result = MessageDialogs.CloseForm(e);

            if (result == DialogResult.Yes)
            {
                service.CloseQueueFile();
            }

            e.Cancel = (result == DialogResult.No);
        }
 private void ComboBoxDatesOnDecks_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!_initialized)
     {
         return;
     }
     Config.Instance.SelectedDateOnDecks = (DeckDateType)ComboBoxDeckDateType.SelectedItem;
     Config.Instance.ShowDateOnDeck      = (Config.Instance.SelectedDateOnDecks != DeckDateType.None) ? true : false;
     Config.Save();
     MessageDialogs.ShowRestartDialog();
 }
        private async void OnHearthMirroCheckFailed()
        {
            await Stop(true);

            Core.MainWindow.ActivateWindow();
            while (Core.MainWindow.Visibility != Visibility.Visible || Core.MainWindow.WindowState == WindowState.Minimized)
            {
                await Task.Delay(100);
            }
            await MessageDialogs.ShowMessage(Core.MainWindow, "Uneven permissions",
                                             "It appears that Hearthstone (Battle.net) and HDT do not have the same permissions.\n\nPlease run both as administrator or local user.\n\nIf you don't know what any of this means, just run HDT as administrator.");
        }
    public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
    {
        if (string.Equals(e.purchasedProduct.definition.id, productID, StringComparison.Ordinal))
        {
            MessageDialogs.ShowMessageDialog(
                "Purchase Complete",
                "Thanks for your money!",
                "OK", null);
        }

        return(PurchaseProcessingResult.Complete);
    }
        private void DockPanel_Drop(object sender, DragEventArgs e)
        {
            var dir       = PluginManager.PluginDirectory.FullName;
            var prevCount = PluginManager.Instance.Plugins.Count;

            try
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    var plugins      = 0;
                    var droppedFiles = (string[])e.Data.GetData(DataFormats.FileDrop);
                    if (droppedFiles == null)
                    {
                        return;
                    }
                    foreach (var pluginPath in droppedFiles)
                    {
                        if (pluginPath.EndsWith(".dll"))
                        {
                            File.Copy(pluginPath, Path.Combine(dir, Path.GetFileName(pluginPath)), true);
                            plugins++;
                        }
                        else if (pluginPath.EndsWith(".zip"))
                        {
                            var path = Path.Combine(dir, Path.GetFileNameWithoutExtension(pluginPath));
                            ZipFile.ExtractToDirectory(pluginPath, path);
                            if (Directory.GetDirectories(path).Length == 1 && Directory.GetFiles(path).Length == 0)
                            {
                                Directory.Delete(path, true);
                                ZipFile.ExtractToDirectory(pluginPath, dir);
                            }
                            plugins++;
                        }
                    }
                    if (plugins <= 0)
                    {
                        return;
                    }
                    PluginManager.Instance.LoadPlugins(PluginManager.Instance.SyncPlugins());
                    if (prevCount == 0)
                    {
                        ListBoxPlugins.SelectedIndex = 0;
                        GroupBoxDetails.Visibility   = Visibility.Visible;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                MessageDialogs.ShowMessage(Core.MainWindow, "Error Importing Plugin", $"Please import manually to {dir}.").Forget();
            }
        }
Beispiel #24
0
        private void btn_saveConfig_Click(object sender, EventArgs e)
        {
            int rs = saveConfigApp();

            if (rs == 1)
            {
                MessageDialogs.SaveSucess();
            }
            else
            {
                MessageDialogs.Error();
            }
        }
        async void ListViewItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
        {
            MessageDialogs.SendConfirmation("Are you sure you want to delete this contact?", "Confirmation", async(delete) =>
            {
                if (!delete)
                {
                    return;
                }

                await viewModel.DeleteContact(viewModel.Contacts[e.Position]);
                Activity.RunOnUiThread(() => { ((BaseAdapter)listView.Adapter).NotifyDataSetChanged(); });
            });
        }
Beispiel #26
0
        private async void CheckboxDataSaveAppData_Unchecked(object sender, RoutedEventArgs e)
        {
#if (!SQUIRREL)
            if (!_initialized)
            {
                return;
            }
            Config.Instance.SaveDataInAppData = false;
            Config.Save();
            await MessageDialogs.ShowMessage(Core.MainWindow, "Restart required.", "Click ok to restart HDT");

            Core.MainWindow.Restart();
#endif
        }
Beispiel #27
0
        private void ButtonGamePath_OnClick(object sender, RoutedEventArgs e)
        {
            var dialog = new FolderBrowserDialog {
                Description = "Select your Hearthstone Directory", ShowNewFolderButton = false
            };
            var dialogResult = dialog.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                Config.Instance.HearthstoneDirectory = dialog.SelectedPath;
                Config.Save();
                MessageDialogs.ShowMessage(Core.MainWindow, "Restart required.", "Please restart HDT for this setting to take effect.").Forget();
            }
        }
Beispiel #28
0
        private async void CheckboxConfigSaveAppData_Unchecked(object sender, RoutedEventArgs e)
        {
#if (!SQUIRREL)
            if (!_initialized)
            {
                return;
            }
            var path = Config.Instance.ConfigPath;
            Config.Instance.SaveConfigInAppData = false;
            XmlManager <Config> .Save(path, Config.Instance);

            await MessageDialogs.ShowMessage(Core.MainWindow, "Restart required.", "Click ok to restart HDT");

            Core.MainWindow.Restart();
#endif
        }
        private static void ShowDeckSelectionDialog(List <Deck> decks)
        {
            decks.Add(new Deck("Use no deck", "", new List <Card>(), new List <string>(), "", "", DateTime.Now, false, new List <Card>(),
                               SerializableVersion.Default, new List <Deck>(), Guid.Empty));
            if (decks.Count == 1 && DeckList.Instance.ActiveDeck != null)
            {
                decks.Add(new Deck("No match - Keep using active deck", "", new List <Card>(), new List <string>(), "", "", DateTime.Now, false,
                                   new List <Card>(), SerializableVersion.Default, new List <Deck>(), Guid.Empty));
            }
            _waitingForUserInput = true;
            Log.Info("Waiting for user input...");
            var dsDialog = new DeckSelectionDialog(decks);

            dsDialog.ShowDialog();

            var selectedDeck = dsDialog.SelectedDeck;

            if (selectedDeck != null)
            {
                if (selectedDeck.Name == "Use no deck")
                {
                    Log.Info("Auto deck detection disabled.");
                    Core.MainWindow.SelectDeck(null, true);
                    NotFoundCards.Clear();
                }
                else if (selectedDeck.Name == "No match - Keep using active deck")
                {
                    IgnoredDeckId = DeckList.Instance.ActiveDeck?.DeckId ?? Guid.Empty;
                    Log.Info($"Now ignoring {DeckList.Instance.ActiveDeck?.Name}");
                    NotFoundCards.Clear();
                }
                else
                {
                    Log.Info("Selected deck: " + selectedDeck.Name);
                    Core.MainWindow.SelectDeck(selectedDeck, true);
                }
            }
            else
            {
                Log.Info("Auto deck detection disabled.");
                MessageDialogs.ShowMessage(Core.MainWindow, "Auto deck selection disabled.", "This can be re-enabled under 'options (advanced) > tracker > general'.").Forget();
                Config.Instance.AutoDeckDetection = false;
                Config.Save();
                Core.MainWindow.AutoDeckDetection(false);
            }
            _waitingForUserInput = false;
        }
    public void HandleLog(string logString, string stackTrace, LogType type)
    {
        if ((type == LogType.Exception) || (type == LogType.Assert))
        {
            string msg = "There was an error. Please don't modify anything below.\n\n";
            msg += "General Info:\n" + GeneralSupportInfo( ) + "\n\n";
            msg += "Log: " + logString + "\n\n";
            msg += "Stack: " + stackTrace;

            MessageDialogs.ShowConfirmationDialog("There was an error.",
                                                  "Do you wish to send an e-mail with the error data?",
                                                  "Yes", () => {
                Utils.OpenEMailClient(emailAddress, title, msg);
            },
                                                  "No", null);
        }
    }