Exemplo n.º 1
0
        private void optionsSaveBtn_Click(object sender, EventArgs e)
        {
            LinkedList <SettingsCategory> categories = new LinkedList <SettingsCategory>();

            // Start blisshive save
            BlissHiveSettingsCategory blisshiveCategory = new BlissHiveSettingsCategory();

            foreach (ListViewItem item in this.optionsBlisshiveAllItemsListView.Items)
            {
                blisshiveCategory.itemsList.AddLast(item.Text);
            }
            foreach (ListViewItem item in this.optionsBlisshiveBlackListListView.Items)
            {
                blisshiveCategory.blackListItems.AddLast(item.Text);
            }
            categories.AddLast(blisshiveCategory);
            // End blisshive save

            // Start FTP save
            FTPSettingsCategory ftpCategory = new FTPSettingsCategory();

            ftpCategory.ip         = this.optionsFTPIPTF.Text;
            ftpCategory.port       = this.optionsFTPPortTF.Text;
            ftpCategory.username   = this.optionsFTPUsernameTF.Text;
            ftpCategory.password   = this.optionsFTPPasswordTF.Text;
            ftpCategory.rootFolder = this.optionsFTPRootFolderTF.Text;
            categories.AddLast(ftpCategory);
            // End FTP save


            SettingsController.GetInstance().SaveSettingFile(categories, OptionsForm.SettingsFileLocation);
            this.Close();
        }
Exemplo n.º 2
0
        void OptionsForm_Shown(object sender, EventArgs e)
        {
            this.Location = new Point(this.Owner.Location.X + ownerWindowOffset.X, this.Owner.Location.Y + ownerWindowOffset.Y);

            LinkedList <SettingsCategory> categories =
                SettingsController.GetInstance().LoadSettingsFile(OptionsForm.SettingsFileLocation);

            foreach (SettingsCategory category in categories)
            {
                if (category is BlissHiveSettingsCategory)
                {
                    // Load blisshive settings into the interface
                    BlissHiveSettingsCategory blissCategory = (BlissHiveSettingsCategory)category;
                    foreach (String item in blissCategory.itemsList)
                    {
                        this.optionsBlisshiveAllItemsListView.Items.Add(item);
                    }

                    foreach (String item in blissCategory.blackListItems)
                    {
                        this.optionsBlisshiveBlackListListView.Items.Add(item);
                    }
                }
                else if (category is FTPSettingsCategory)
                {
                    FTPSettingsCategory ftpCategory = (FTPSettingsCategory)category;
                    this.optionsFTPIPTF.Text         = ftpCategory.ip;
                    this.optionsFTPPortTF.Text       = ftpCategory.port;
                    this.optionsFTPUsernameTF.Text   = ftpCategory.username;
                    this.optionsFTPPasswordTF.Text   = ftpCategory.password;
                    this.optionsFTPRootFolderTF.Text = ftpCategory.rootFolder;
                }
            }
        }
Exemplo n.º 3
0
        public override void StartDownload()
        {
            LinkedList <SettingsCategory> categories =
                SettingsController.GetInstance().LoadSettingsFile(OptionsForm.SettingsFileLocation);

            Boolean           foundSettings = false;
            String            IP            = "";
            String            port          = "";
            String            rootFolder    = "";
            NetworkCredential credential    = null;// new NetworkCredential();

            foreach (SettingsCategory category in categories)
            {
                if (category is FTPSettingsCategory)
                {
                    FTPSettingsCategory ftpCategory = (FTPSettingsCategory)category;

                    IP         = ftpCategory.ip;
                    port       = ftpCategory.port;
                    credential = new NetworkCredential(ftpCategory.username, ftpCategory.password);
                    rootFolder = ftpCategory.rootFolder;

                    foundSettings = true;
                }
            }

            if (foundSettings)
            {
                int errors = 0;
                if (IP.Length == 0)
                {
                    MessageBox.Show("IP not set. See Options to set an IP.");
                    errors++;
                }
                int portInt = 0;
                if (port.Length == 0 && !Int32.TryParse(port, out portInt))
                {
                    MessageBox.Show("Port not set or invalid. See Options to set a valid port.");
                    errors++;
                }
                if (credential.UserName.Length == 0)
                {
                    MessageBox.Show("Username not set. See Options to set a username.");
                    errors++;
                }
                if (credential.Password.Length == 0)
                {
                    MessageBox.Show("Password not set. See Options to set a password.");
                    errors++;
                }

                if (errors == 0)
                {
                    // try {
                    FTPController.GetInstance().blissHiveDownloader =
                        new LogFileDownloader(IP, port, credential, rootFolder, LogFileDownloader.LogFile.BlissHive);
                    FTPController.GetInstance().blissHiveDownloader.progressUpdatedListeners += this.OnDownloadProgress;
                    FTPController.GetInstance().blissHiveDownloader.downloadStoppedListeners += this.CancelDownload;
                    FTPController.GetInstance().blissHiveDownloader.downloadFinishedListeners += this.FinishedDownload;
                    FTPController.GetInstance().blissHiveDownloader.downloadFailedListeners += this.FailedDownload;

                    this.dayzLogParserForm.SetStatusText(0, "Downloading blisshive.log..");
                    this.dayzLogParserForm.SetStatusText(1, "");
                    this.dayzLogParserForm.blissHiveDownloadLogBtn.Text = "Stop";
                    this.dayzLogParserForm.blissHivePlayerName.Text     = "Downloading..";

                    /*} catch(WebException e){
                     *
                     * }*/
                }
            }
            else
            {
                MessageBox.Show("No FTP Settings found. Please add them in the Options menu.");
            }
        }