Example #1
0
        /// <summary>
        ///     When a program is selected in 'listboxMyPrograms' it loads the selected program information.
        /// </summary>
        /// <param name="selectedIndex">The GlobalVariables.MyPrograms index.</param>
        public void SelectProgram(int selectedIndex)
        {
            // Loads the ByteGuardPrograms using the specified GlobalVariables.MyPrograms index.
            Variables.ByteGuardProgram byteguardProgram = Variables.MyLibrary[selectedIndex];

            // Displays the selected program on the MyProgramsDefault user control.
            DisplayProgram(byteguardProgram);
        }
Example #2
0
        private Variables.ByteGuardProgram ParseProgramNode(XmlNode programNode)
        {
            // Initializes a ByteGuardProgram variable for us to work with.
            Variables.ByteGuardProgram byteguardProgram = new Variables.ByteGuardProgram();

            foreach (XmlNode xmlInformationNode in programNode)
            {
                switch (xmlInformationNode.Name)
                {
                case "id":
                    byteguardProgram.Programid = xmlInformationNode.InnerText;
                    break;

                case "name":
                    byteguardProgram.ProgramName = xmlInformationNode.InnerText;
                    break;

                case "version":
                    byteguardProgram.ProgramVersion = float.Parse(xmlInformationNode.InnerText);
                    break;

                case "description":
                    byteguardProgram.ProgramDescription = xmlInformationNode.InnerText;
                    break;

                case "licenses":
                    byteguardProgram.ProgramLicenses = Convert.ToInt32(xmlInformationNode.InnerText);
                    break;

                case "hasimage":
                    byteguardProgram.ProgramHasImage = Convert.ToInt32(xmlInformationNode.InnerText) == 1;
                    break;

                case "creatorusername":
                    byteguardProgram.CreatorUsername = xmlInformationNode.InnerText;
                    break;

                case "isadmin":
                    byteguardProgram.IsAdmin = Convert.ToInt32(xmlInformationNode.InnerText) == 1;
                    break;

                case "distmodel":
                    byteguardProgram.DistributionModel = Convert.ToInt32(xmlInformationNode.InnerText);
                    break;

                case "mpfeepaid":
                    byteguardProgram.MarketplaceFeePaid = Convert.ToInt32(xmlInformationNode.InnerText) == 1;
                    break;
                }
            }

            return(byteguardProgram);
        }
Example #3
0
        private void ButtonViewLockDetails_Click(object sender, EventArgs e)
        {
            ButtonViewLockDetails.Enabled = false;

            Variables.ByteGuardProgram byteguardProgram =
                Variables.MyLibrary[Variables.Forms.Main.MyLibrarySelectedIndex];

            BlankForm f = new BlankForm(new LockDetails(byteguardProgram), true);

            f.FormClosing += (closedSender, closedE) => ButtonViewLockDetails.Enabled = true;
            f.Show();
        }
Example #4
0
        /// <summary>
        ///     Displays the selected program on the MyProgramsDefault user control.
        /// </summary>
        /// <param name="byteguardProgram">The selected program to display.</param>
        private void DisplayProgram(Variables.ByteGuardProgram byteguardProgram)
        {
            // Sets the program name label.
            LabelProgramName.Text = (byteguardProgram.IsAdmin
                ? String.Format("Program Name ({0}): [ADMIN]", byteguardProgram.Programid)
                : String.Format("Program Name ({0}):", byteguardProgram.Programid));

            // Resets the program description.
            LabelProgramDescription.Text = "Program Description:";

            // Sets the program name textbox.
            TextBoxProgramName.Text = byteguardProgram.ProgramName;

            // Sets the program description textbox.
            TextBoxProgramDescription.Text = byteguardProgram.ProgramDescription.Replace("<br />", Environment.NewLine);

            // Shows how many programs the license has assigned.
            LabelUsedLicenses.Text = String.Format("Licenses: {0}", byteguardProgram.ProgramLicenses);

            // Sets the program version label.
            LabelVersion.Text = String.Format("Version: {0:0.0}", (decimal)byteguardProgram.ProgramVersion);

            // Check if the selected program has a custom image.
            if (byteguardProgram.ProgramHasImage)
            {
                // Gets the path where the program image should be stored/downloaded to. (%APPDATA%/ByteGuard/MyPrograms/{Programid}.png).
                string imagePath = String.Format(@"MyPrograms/{0}/main.png", byteguardProgram.Programid);

                // Check if the program image already exists, if so display it, if not download it.
                if (!File.Exists(imagePath))
                {
                    // Custom file image has not already been downloaded, download it!
                    string[] imageObject = { byteguardProgram.Programid, imagePath };

                    // Downloads the selected programs custom image on a new thread.
                    Thread downloadImageThread = new Thread(DownloadImageThreaded);
                    downloadImageThread.Start(imageObject);
                }
                else
                {
                    // File image has been previously downloaded, display it.
                    PictureBoxProgramImage.ImageLocation = imagePath;
                }
            }
            else
            {
                // If the selected program does not have a custom image, then show the DefaultProgram image.
                PictureBoxProgramImage.Image = Resources.DefaultProgramImage;
            }
        }
Example #5
0
        /// <summary>
        ///     Displays the selected program on the MyProgramsDefault user control.
        /// </summary>
        /// <param name="byteguardProgram">The selected program to display.</param>
        private void DisplayProgram(Variables.ByteGuardProgram byteguardProgram)
        {
            if (InvokeRequired)
            {
                Invoke(new DisplayProgramDelegate(DisplayProgram), byteguardProgram);
            }
            else
            {
                ButtonLaunchApplication.Enabled = false;

                // Sets the program name label.
                LabelProgramName.Text = byteguardProgram.ProgramName;

                // Sets the program description textbox.
                TextBoxProgramDescription.Text = byteguardProgram.ProgramDescription;

                // Sets the program version label.
                TextBoxVersion.Text = String.Format("Version: {0:0.0}", (decimal)byteguardProgram.ProgramVersion);

                // Sets the creator textbox.
                TextBoxCreator.Text = byteguardProgram.CreatorUsername;

                TextBoxExpiration.Text = (byteguardProgram.ExpirationTime == -1
                    ? "Never"
                    : Methods.TimeStampToDate(byteguardProgram.ExpirationTime));

                TextBoxLicenseStatus.Text = (byteguardProgram.IsBanned ? "Locked" : "Unlocked");

                TextBoxLicenseStatus.ForeColor = (byteguardProgram.IsBanned ? Color.DarkRed : Color.DarkGreen);

                ButtonViewLockDetails.Enabled = byteguardProgram.IsBanned;

                ButtonLaunchApplication.Enabled = !byteguardProgram.IsBanned;

                Thread threadSetLaunchButton = new Thread(SetLaunchButton);
                threadSetLaunchButton.Start();

                // Check if the selected program has a custom image.
                if (byteguardProgram.ProgramHasImage)
                {
                    ShowProgramImage(byteguardProgram.Programid);
                }
                else
                {
                    // If the selected program does not have a custom image, then show the DefaultProgram image.
                    PictureBoxProgramImage.Image = Resources.DefaultProgramImage;
                }
            }
        }
Example #6
0
        private Variables.ByteGuardProgram ParseProgramNode(XmlNode programNode)
        {
            // Initializes a ByteGuardProgram variable for us to work with.
            Variables.ByteGuardProgram byteguardProgram = new Variables.ByteGuardProgram();

            foreach (XmlNode xmlInformationNode in programNode)
            {
                switch (xmlInformationNode.Name)
                {
                case "id":
                    byteguardProgram.Programid = xmlInformationNode.InnerText;
                    break;

                case "lid":
                    byteguardProgram.Licenseid = Convert.ToInt32(xmlInformationNode.InnerText);
                    break;

                case "name":
                    byteguardProgram.ProgramName = xmlInformationNode.InnerText;
                    break;

                case "creator":
                    byteguardProgram.CreatorUsername = xmlInformationNode.InnerText;
                    break;

                case "version":
                    byteguardProgram.ProgramVersion = float.Parse(xmlInformationNode.InnerText);
                    break;

                case "description":
                    byteguardProgram.ProgramDescription = xmlInformationNode.InnerText;
                    break;

                case "hasimage":
                    byteguardProgram.ProgramHasImage = Convert.ToInt32(xmlInformationNode.InnerText) == 1;
                    break;

                case "expiration":
                    byteguardProgram.ExpirationTime = Convert.ToInt32(xmlInformationNode.InnerText);
                    break;

                case "banned":
                    byteguardProgram.IsBanned = Convert.ToInt32(xmlInformationNode.InnerText) == 1;
                    break;
                }
            }

            return(byteguardProgram);
        }
Example #7
0
        /// <summary>
        ///     When a program is selected in 'listboxMyPrograms' it loads the selected program information.
        /// </summary>
        /// <param name="selectedIndex">The GlobalVariables.MyPrograms index.</param>
        public void SelectProgram(int selectedIndex)
        {
            // Loads the ByteGuardPrograms using the specified GlobalVariables.MyPrograms index.
            Variables.ByteGuardProgram byteguardProgram = Variables.MyPrograms[selectedIndex];

            // Resets the MyProgramsDefault controls. (In case the user selects another program mid-edit).
            if (ButtonEditProgram.Text != "Edit Program")
            {
                CancelProgramEditing();
            }

            // Displays the selected program on the MyProgramsDefault user control.
            DisplayProgram(byteguardProgram);

            Version = (decimal)byteguardProgram.ProgramVersion;
        }
Example #8
0
        public LockDetails(Variables.ByteGuardProgram byteguardProgram)
        {
            _byteguardProgram = byteguardProgram;

            InitializeComponent();
        }
Example #9
0
        public ProgramDownloader(Variables.ByteGuardProgram programToDownload)
        {
            InitializeComponent();

            _programToDownload = programToDownload;
        }