コード例 #1
0
        private void BtnImportClick(object sender, RoutedEventArgs e)
        {
            var aiw = new ApiImportWindow
            {
                Topmost = true,
                Top     = Top + Height / 10,
                Left    = Left + Width / 10,
            };

            if (aiw.ShowDialog() == true)
            {
                Settings settings = aiw.Settings;
                string   fName    = string.Format("profiles\\{0}.dat", settings.ProfileName);
                if (File.Exists(fName))
                {
                    MessageBoxResult result = MessageBox.Show("Character exists. Update?",
                                                              "Character already exists", MessageBoxButton.YesNo,
                                                              MessageBoxImage.Information);
                    if (result == MessageBoxResult.Yes)
                    {
                        int index = 1;
                        File.Delete(fName);
                        for (int i = 0; i < cbProfiles.Items.Count; i++)
                        {
                            var tmp = (Settings)cbProfiles.Items[i];
                            if (tmp.ProfileName == settings.ProfileName)
                            {
                                index = i;
                                cbProfiles.SelectedIndex = 0;
                                cbProfiles.Items.RemoveAt(i);
                                break;
                            }
                        }
                        cbProfiles.Items.Insert(index, settings);
                        cbProfiles.SelectedItem = settings;
                        tcMain.SelectedIndex    = 1;
                    }
                }
                else
                {
                    cbProfiles.Items.Add(settings);
                    cbProfiles.SelectedItem = settings;
                    tcMain.SelectedIndex    = 1;
                }
            }
        }
コード例 #2
0
        private void btnImportAPI_Click(object sender, RoutedEventArgs e)
        {
            var aiw = new ApiImportWindow()
            {
                Topmost = true,
                Top     = Top,
                Left    = Left,
            };

            if (aiw.ShowDialog() == true)
            {
                Profile settings = aiw.profile;
                string  fName    = string.Format("profiles\\{0}.dat", settings.profileName);

                if (File.Exists(fName))
                {
                    MessageBoxResult result = MessageBox.Show(
                        "This profile already exist. Would you update it ?\nYou can delete the profile and import it back from a new API key if needed.",
                        "Profile already exists",
                        MessageBoxButton.YesNo,
                        MessageBoxImage.Information
                        );

                    if (result == MessageBoxResult.Yes)
                    {
                        mainWindow.btnUpdateClick(null, null);
                    }
                }
                else
                {
                    mainWindow.cbProfiles.Items.Add(settings);
                    mainWindow.cbProfiles.SelectedItem = settings;
                    mainWindow.tcMain.SelectedIndex    = 1;
                }

                Close();
            }
        }
コード例 #3
0
        private void BtnImportClick(object sender, RoutedEventArgs e)
        {
            var aiw = new ApiImportWindow
                          {
                              Topmost = true,
                              Top = Top + Height/10,
                              Left = Left + Width/10,
                          };

            if (aiw.ShowDialog() == true)
            {
                Settings settings = aiw.Settings;
                string fName = string.Format("profiles\\{0}.dat", settings.ProfileName);
                if (File.Exists(fName))
                {
                    MessageBoxResult result = MessageBox.Show("Character exists. Update?",
                                                              "Character already exists", MessageBoxButton.YesNo,
                                                              MessageBoxImage.Information);
                    if (result == MessageBoxResult.Yes)
                    {
                        int index = 1;
                        File.Delete(fName);
                        for (int i = 0; i < cbProfiles.Items.Count; i++)
                        {
                            var tmp = (Settings) cbProfiles.Items[i];
                            if (tmp.ProfileName == settings.ProfileName)
                            {
                                index = i;
                                cbProfiles.SelectedIndex = 0;
                                cbProfiles.Items.RemoveAt(i);
                                break;
                            }
                        }
                        cbProfiles.Items.Insert(index, settings);
                        cbProfiles.SelectedItem = settings;
                        tcMain.SelectedIndex = 1;
                    }
                }
                else
                {
                    cbProfiles.Items.Add(settings);
                    cbProfiles.SelectedItem = settings;
                    tcMain.SelectedIndex = 1;
                }
            }
        }