示例#1
0
        /// <summary>
        ///     Imports a new profile
        /// </summary>
        /// <param name="filename">The filename to the .pbp file</param>
        /// <returns>True if the profile has been imported and loaded successfully</returns>
        public bool ImportProfile(string filename)
        {
            Pandora.Log.WriteEntry("Importing Profile...");
            _splash.SetStatusText("Importing profile");

            Profile p = null;

            try
            {
                p = ProfileIO.Load(filename);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.ToString());
            }

            if (p == null)
            {
                return(false);
            }
            _profile = p;

            var run = false;

            if (Pandora.ExistingInstance != null)
            {
                // Already running: Close?

                if (MessageBox.Show(
                        null,
                        "Another instance of Pandora's Box is currently running. Would you like to close it and load the profile you have just imported?",
                        "Profile import succesful",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (Pandora.ExistingInstance != null)
                    {
                        Pandora.ExistingInstance.Close();
                    }

                    run = true;
                }
            }
            else
            {
                run = true;
            }

            if (run)
            {
                MessageBox.Show("Profile imported correctly.");
            }

            if (!run)
            {
                _profile = null;
            }

            return(run);
        }
示例#2
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            ProfileIO.LoadProfiles();
            helper.AddOptionsGroup <Options>();

#if DEBUG
            Debug.Log(OptionsWrapper <Options> .Options.profile);
#endif
        }
示例#3
0
        /// <summary>
        /// Exports a Pandora's Box profile
        /// </summary>
        /// <param name="p">The profile to export</param>
        public void ExportProfile()
        {
            System.Windows.Forms.SaveFileDialog dlg = new SaveFileDialog();
            dlg.Filter = "Pandora's Box Profile (*.pbp)|*.pbp";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                ProfileIO pio = new ProfileIO(_profile);
                pio.Save(dlg.FileName);
            }

            dlg.Dispose();
        }
示例#4
0
        /// <summary>
        /// Imports a profile from a PBP file
        /// </summary>
        /// <returns>The Profile object imported</returns>
        public Profile ImportProfile()
        {
            System.Windows.Forms.OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "Pandora's Box Profile (*.pbp)|*.pbp";
            Profile p = null;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                p = ProfileIO.Load(dlg.FileName);
            }

            dlg.Dispose();

            return(p);
        }
示例#5
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            List <dynamic>      objects   = new ProfileIO().Read();
            List <TreeViewItem> treeHeads = new List <TreeViewItem>();
            int    flag        = 0;
            string domainName  = null;
            string profileName = null;

            foreach (dynamic obj in objects)
            {
                domainName  = (string)obj.Domain;
                profileName = (string)obj.CreatedOn;
                if (flag == 0)
                {
                    treeHeads.Add(CreateNewTreeItemView(domainName, profileName));
                    flag = 1;
                }
                else
                {
                    bool innerFlag = true;
                    for (int i = 0; i < treeHeads.Count; i++)
                    {
                        if (treeHeads[i].Header.ToString().Equals(domainName))
                        {
                            treeHeads[i].Items.Add(new TreeViewItem()
                            {
                                Header = profileName
                            });
                            innerFlag = false;
                            break;
                        }
                    }
                    if (innerFlag)
                    {
                        treeHeads.Add(CreateNewTreeItemView(domainName, profileName));
                    }
                }
            }
            foreach (TreeViewItem item in treeHeads)
            {
                domainTree.Items.Add(item);
            }
        }
示例#6
0
        private static void ExportTokenProf(string token, string dir = @"translator\profs")
        {
            try
            {
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                var fileCount = Directory.GetFiles(dir, "plexdl_sv*.prof").Length;
                var fileIdx   = fileCount + 1;
                var fileName  = "plexdl_sv" + fileIdx + ".prof";
                var fqPath    = dir + @"\" + fileName;

                var options = ProfileFromToken(token);

                ProfileIO.ProfileToFile(fqPath, options);
            }
            catch (Exception ex)
            {
                UIMessages.Error(ex.ToString());
            }
        }
示例#7
0
        private static void ExportTokenProf(string token, string dir = @"translator\profs")
        {
            try
            {
                //does the directory for stored profiles exist?
                if (!Directory.Exists(dir))
                {
                    //no, create it
                    Directory.CreateDirectory(dir);
                }

                //how many tokens have we already exported to profiles?
                var fileCount = Directory.GetFiles(dir, "plexdl_sv*.prof").Length;

                //the index of the new profile
                var fileIdx = fileCount + 1;

                //file name for the new profile
                var fileName = $"plexdl_sv{fileIdx}.prof";

                //full path for the profile to be exported
                var fqPath = $@"{dir}\{fileName}";

                //create a new configuration object from the token provided
                var options = ProfileFromToken(token);

                //export the configuration object to a file
                ProfileIO.ProfileToFile(fqPath, options);
            }
            catch (Exception ex)
            {
                //log the error
                LoggingHelpers.RecordException(ex.Message, @"TokenTranslatorExportError");

                //alert the user
                UIMessages.Error(ex.ToString());
            }
        }