Ejemplo n.º 1
0
        static void Main()
        {
            cRWRegistry RWRegistry = new cRWRegistry();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm(RWRegistry));
        }
Ejemplo n.º 2
0
        //============================================================================*
        // cPurchaseKeyForm() - Constructor
        //============================================================================*

        public cPurchaseKeyForm(cRWRegistry RWRegistry)
        {
            InitializeComponent();

            m_RWRegistry = RWRegistry;

            SetClientSizeCore(BuyItNowGroup.Location.X + BuyItNowGroup.Width + 10, BuyItNowGroup.Location.Y + BuyItNowGroup.Height + 20);

            BuyNowButton.Click += OnBuyClicked;
        }
Ejemplo n.º 3
0
        //============================================================================*
        // cMainForm() - Constructor
        //============================================================================*

        public cMainForm(cRWRegistry RWRegistry)
        {
            InitializeComponent();

            m_RWRegistry = RWRegistry;

            //----------------------------------------------------------------------------*
            // Make sure we're not minimized
            //----------------------------------------------------------------------------*

            if (WindowState == FormWindowState.Minimized)
            {
                WindowState = FormWindowState.Normal;
            }

            NativeMethods.SetForegroundWindow(this.Handle);

            //----------------------------------------------------------------------------*
            // Position the buttons
            //----------------------------------------------------------------------------*

            SetClientSizeCore(800, 450);

            int nLeft       = ContinueButton.Location.X;
            int nRight      = ExitButton.Location.X + ExitButton.Size.Width;
            int nWidth      = nRight - nLeft;
            int nCenterLeft = 400 - (nWidth / 2);

            ContinueButton.Location = new Point(nCenterLeft, 384);
            ActivateButton.Location = new Point(400 - (ActivateButton.Width / 2), 384);
            ExitButton.Location     = new Point(400 + (400 - nCenterLeft) - ExitButton.Size.Width, 384);

            SetRegistrationInfo();

            Bitmap WorkShop = Properties.Resources.WorkShop;

            BackgroundImageLayout = ImageLayout.Stretch;
            BackgroundImage       = WorkShop;

            //----------------------------------------------------------------------------*
            // Event Handlers
            //----------------------------------------------------------------------------*

            ActivateButton.Click += OnActivateClicked;
            ContinueButton.Click += OnContinueClicked;
            ExitButton.Click     += OnExitClicked;
        }
Ejemplo n.º 4
0
        //============================================================================*
        // cActivationForm() - Constructor
        //============================================================================*

        public cActivationForm(cRWRegistry RWRegistry)
        {
            InitializeComponent();

            m_RWRegistry = RWRegistry;

            SetClientSizeCore(KeyGroup.Location.X + KeyGroup.Width + 10, PurchaseGroup.Location.Y + PurchaseGroup.Height + 20);

            NameTextBox.TextChanged  += OnDataChanged;
            EmailTextBox.TextChanged += OnDataChanged;
            KeyTextBox.TextChanged   += OnDataChanged;

            OKButton.Click       += OnOKClicked;
            PurchaseButton.Click += OnPurchaseClicked;

            UpdateButtons();
        }
Ejemplo n.º 5
0
        public AboutDialog(cRWRegistry RWRegistry)
        {
            InitializeComponent();

            VersionLabel.Text = ProductName + " - v" + ProductVersion;

            Assembly Assembly = typeof(AboutDialog).Assembly;

            object[] Attribs = Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), true);

            if (Attribs.Length > 0)
            {
                CopyrightLabel.Text = ((AssemblyCopyrightAttribute)Attribs[0]).Copyright;
            }

            if (RWRegistry != null)
            {
                RegistrationLabel.Text = RWRegistry.ActivationStatusString;
            }
        }
Ejemplo n.º 6
0
        //============================================================================*
        // MainForm() - Constructor
        //============================================================================*

        public MainForm(cRWRegistry RWRegistry)
        {
            InitializeComponent();

            m_RWRegistry = RWRegistry;

            NameTextBox.TextChanged    += OnNameChanged;
            EmailTextBox.TextChanged   += OnEmailChanged;
            VersionTextBox.TextChanged += OnVersionChanged;

            GetKeyButton.Click     += OnGetKeyClicked;
            SendButton.Click       += OnSendClicked;
            AddLicenseButton.Click += OnAddClicked;
            CloseButton.Click      += OnCloseClicked;

            VersionTextBox.Value = RWRegistry.Version;
            NameTextBox.Value    = "Cody Beebe";
            EmailTextBox.Value   = "*****@*****.**";

            UpdateButtons();
        }
        static void Main(string[] args)
        {
            //----------------------------------------------------------------------------*
            // Set Application Properties
            //----------------------------------------------------------------------------*

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //----------------------------------------------------------------------------*
            // Get the command line arguments
            //----------------------------------------------------------------------------*

            bool   fDev    = false;
            string strGUID = "";

            foreach (string strArg in args)
            {
                if (strArg.ToUpper() == "/DEV")
                {
                    fDev = true;
                }

                if (strArg.Length > 6 && strArg.ToUpper().Substring(0, 6) == "/GUID=")
                {
                    strGUID = strArg.Substring(6);
                }
            }

            //----------------------------------------------------------------------------*
            // Make sure the correct GUID has been sent
            //----------------------------------------------------------------------------*

            if (strGUID == null || strGUID != "1aa3257d-fa44-4f49-9546-076b2385cd35")
            {
                MessageBox.Show(String.Format("You must use the launcher to start {0}.  You can not execute it directly.", Application.ProductName), "Execution Out of Order", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                return;
            }

            //----------------------------------------------------------------------------*
            // If this is a trial and we're expired, exit
            //----------------------------------------------------------------------------*

            cRWRegistry RWRegistry = new cRWRegistry();

            if ((RWRegistry.Trial && RWRegistry.TrialExpired) || RWRegistry.InvalidRegistry || !RWRegistry.ValidateKey())
            {
                return;
            }

            //----------------------------------------------------------------------------*
            // See if we're already running
            //----------------------------------------------------------------------------*

            bool fCreateNew = true;

            using (Mutex mutex = new Mutex(true, "ReloadersWorkShop", out fCreateNew))
            {
                //----------------------------------------------------------------------------*
                // Not running, continue normally
                //----------------------------------------------------------------------------*

                if (fCreateNew)
                {
                    //----------------------------------------------------------------------------*
                    // Start the Application
                    //----------------------------------------------------------------------------*

                    try
                    {
                        Application.Run(new cMainForm(RWRegistry, fDev));
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message, "Exception in Reloader's Work Shop!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                //----------------------------------------------------------------------------*
                // Already running, bring the currently running version to the foreground
                //----------------------------------------------------------------------------*

                else
                {
                    Process CurrentProcess = Process.GetCurrentProcess();

                    Process[] aProcesses = Process.GetProcessesByName(CurrentProcess.ProcessName);

                    foreach (Process CheckProcess in aProcesses)
                    {
                        if (CheckProcess.Id != CurrentProcess.Id)
                        {
                            NativeMethods.SetForegroundWindow(CheckProcess.MainWindowHandle);

                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            bool fInstall  = false;
            bool fActivate = false;

            string strName    = "";
            string strEmail   = "";
            string strKey     = "";
            string strVersion = "";

            foreach (string strArg in args)
            {
                if (strArg.ToUpper() == "/INSTALL")
                {
                    fInstall = true;
                }

                if (strArg.ToUpper() == "/ACTIVATE")
                {
                    fActivate = true;
                }

                if (strArg.Length > 6 && strArg.Substring(0, 6).ToUpper() == "/NAME=")
                {
                    strName = strArg.Substring(6);
                }

                if (strArg.Length > 7 && strArg.Substring(0, 7).ToUpper() == "/EMAIL=")
                {
                    strEmail = strArg.Substring(7);
                }

                if (strArg.Length > 5 && strArg.Substring(0, 5).ToUpper() == "/KEY=")
                {
                    strKey = strArg.Substring(5);
                }

                if (strArg.Length > 9 && strArg.Substring(0, 9).ToUpper() == "/VERSION=")
                {
                    strVersion = strArg.Substring(9);
                }
            }

            //----------------------------------------------------------------------------*
            // Create the RWRegistry object
            //----------------------------------------------------------------------------*

            cRWRegistry RWRegistry = new cRWRegistry();

            RWRegistry.UpdateVersion();

            //----------------------------------------------------------------------------*
            // If this is just an install operation, setup the registry if needed
            //----------------------------------------------------------------------------*

            if (fInstall || RWRegistry.FreshInstall)
            {
                //----------------------------------------------------------------------------*
                // Setup the initial Registry entries
                //----------------------------------------------------------------------------*

                RWRegistry.SetupRegistry(fInstall);

                //----------------------------------------------------------------------------*
                // Start the launcher and exit
                //----------------------------------------------------------------------------*

                Process.Start("ReloadersWorkShopLauncher.exe");

                return;
            }

            //----------------------------------------------------------------------------*
            // If this is an activate operation, setup the activation entries
            //----------------------------------------------------------------------------*

            if (fActivate)
            {
                //----------------------------------------------------------------------------*
                // Set the registry entries
                //----------------------------------------------------------------------------*

                RWRegistry.Activate(strKey, strName, strEmail, strVersion);

                //----------------------------------------------------------------------------*
                // Start the launcher and exit
                //----------------------------------------------------------------------------*

                Process.Start("ReloadersWorkShopLauncher.exe");

                return;
            }

            //----------------------------------------------------------------------------*
            // Check to see if it's a trial version and if it is, check to see if it's expired
            //----------------------------------------------------------------------------*

/*
 *                      if (RWRegistry.Trial && RWRegistry.TrialExpired)
 *                              {
 *                              Process.Start("ReloadersWorkShopLauncher.exe");
 *
 *                              return;
 *                              }
 */
            //----------------------------------------------------------------------------*
            // Check for updates
            //----------------------------------------------------------------------------*

            cRWUpdater RWUpdater = new cRWUpdater();

            if (!RWUpdater.UpdateFiles())
            {
                Process.Start("ReloadersWorkShopLauncher.exe");
            }

            //----------------------------------------------------------------------------*
            // If updates were successful, show the release notes
            //----------------------------------------------------------------------------*

            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            }
        }
Ejemplo n.º 9
0
        //============================================================================*
        // cBatchTestForm() - Constructor
        //============================================================================*

        public cBatchTestForm(cBatch Batch, cDataFiles DataFiles, cRWRegistry RWRegistry, bool fViewOnly = false)
        {
            InitializeComponent();

            m_DataFiles  = DataFiles;
            m_RWRegistry = RWRegistry;
            m_fViewOnly  = fViewOnly;

            string strTitle = "";

            if (Batch.BatchTest == null)
            {
                m_BatchTest          = new cBatchTest();
                m_BatchTest.Batch    = Batch;
                m_BatchTest.Firearm  = Batch.Firearm;
                m_BatchTest.TestDate = DateTime.Today;

                m_BatchTest.Temperature        = 59;
                m_BatchTest.Altitude           = 0;
                m_BatchTest.BarometricPressure = 29.92;
                m_BatchTest.Humidity           = 0.78;

                strTitle = "Add";

                BatchTestOKButton.Text        = "Add";
                BatchTestDeleteButton.Enabled = false;
            }
            else
            {
                m_BatchTest = new cBatchTest(Batch.BatchTest);

                if (!m_fViewOnly)
                {
                    strTitle = "Edit";

                    BatchTestOKButton.Text = "Update";
                }
                else
                {
                    BatchTestCancelButton.Text    = "Close";
                    BatchTestDeleteButton.Visible = false;
                    BatchTestOKButton.Visible     = false;

                    int nButtonX = (this.Size.Width / 2) - (BatchTestCancelButton.Width / 2);

                    BatchTestCancelButton.Location = new Point(nButtonX, BatchTestCancelButton.Location.Y);

                    strTitle = "View";
                }
            }

            SetClientSizeCore(BatchDataGroupBox.Location.X + BatchDataGroupBox.Width + 10, BatchTestCancelButton.Location.Y + BatchTestCancelButton.Height + 20);

            //----------------------------------------------------------------------------*
            // Set Title
            //----------------------------------------------------------------------------*

            strTitle += " Batch Test";

            Text = strTitle;

            //----------------------------------------------------------------------------*
            // Event Handlers
            //----------------------------------------------------------------------------*

            if (!m_fViewOnly && !m_BatchTest.Batch.Archived)
            {
                TestDatePicker.TextChanged += OnDateChanged;

                FirearmCombo.SelectedIndexChanged += OnFirearmChanged;

                LocationTextBox.TextChanged += OnLocationTextChanged;

                SuppressedCheckBox.Click += OnSuppressedClicked;

                TemperatureTextBox.TextChanged += OnTemperatureChanged;
                AltitudeTextBox.TextChanged    += OnAltitudeChanged;
                PressureTextBox.TextChanged    += OnBarometricPressureChanged;
                HumidityTextBox.TextChanged    += OnHumidityChanged;

                WindSpeedTextBox.TextChanged     += OnWindSpeedChanged;
                WindDirectionTextBox.TextChanged += OnWindDirectionChanged;

                NumShotsTextBox.TextChanged += OnNumShotsTextChanged;

                BestGroupTextBox.TextChanged += OnBestGroupChanged;

                NotesTextBox.TextChanged += OnNotesChanged;

                BestGroupRangeTextBox.TextChanged += OnBestGroupRangeChanged;

                TargetCalculatorButton.Click += OnTargetCalculatorClicked;

                FavoriteLoadRadioButton.Click += OnFavoriteLoadClicked;
                RejectLoadRadioButton.Click   += OnRejectLoadClicked;

                BatchTestOKButton.Click += OnOKClicked;
            }
            else
            {
                NumShotsTextBox.ReadOnly       = true;
                BestGroupTextBox.ReadOnly      = true;
                BestGroupRangeTextBox.ReadOnly = true;

                NotesTextBox.ReadOnly = true;
            }

            EditShotsButton.Click += OnEditShotsClicked;

            //----------------------------------------------------------------------------*
            // Set Decimals
            //----------------------------------------------------------------------------*

            SetInputParameters();

            //----------------------------------------------------------------------------*
            // Populate Form Data
            //----------------------------------------------------------------------------*

            SetStaticToolTips();

            BatchIDLabel.Text = String.Format("{0:G0}", m_BatchTest.Batch.BatchID);

            if (m_BatchTest.Batch.Archived)
            {
                BatchIDLabel.Text += " - Archived";
            }

            DateLoadedLabel.Text = m_BatchTest.Batch.DateLoaded.ToShortDateString();
            CaliberLabel.Text    = m_BatchTest.Batch.Load.Caliber.ToString();
            LoadLabel.Text       = m_BatchTest.Batch.Load.ToShortString();
            ChargeLabel.Text     = String.Format("{0:F1}", m_BatchTest.Batch.PowderWeight);
            NumRoundsLabel.Text  = String.Format("{0:G0}", m_BatchTest.Batch.NumRounds);

            switch (m_BatchTest.Batch.Load.FirearmType)
            {
            case cFirearm.eFireArmType.Handgun:
                FirearmTypeLabel.Text = "Handgun";
                break;

            case cFirearm.eFireArmType.Rifle:
                FirearmTypeLabel.Text = "Rifle";
                break;

            case cFirearm.eFireArmType.Shotgun:
                FirearmTypeLabel.Text = "Shotgun";
                break;
            }

            PopulateBatchTestData();
            PopulateShotList();

            m_fInitialized = true;

            UpdateButtons();
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            bool fUpdate = false;

            foreach (string strArg in args)
            {
                if (strArg.ToUpper() == "/UPDATE")
                {
                    fUpdate = true;
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //----------------------------------------------------------------------------*
            // See if the ReloadersWorkShopLauncher is already running
            //----------------------------------------------------------------------------*

            bool fMutexCreated = true;

            using (Mutex ThisMutex = new Mutex(true, "ReloadersWorkShopLauncher", out fMutexCreated))
            {
                //----------------------------------------------------------------------------*
                // Not running, continue
                //----------------------------------------------------------------------------*

                if (fMutexCreated)
                {
                    //----------------------------------------------------------------------------*
                    // See if ReloadersWorkShop is already running
                    //----------------------------------------------------------------------------*

                    using (Mutex RWMutex = new Mutex(true, "ReloadersWorkShop", out fMutexCreated))
                    {
                        //----------------------------------------------------------------------------*
                        // If it is, bring the current instance to the foreground
                        //----------------------------------------------------------------------------*

                        if (!fMutexCreated)
                        {
                            Process[] aProcesses = Process.GetProcessesByName("ReloadersWorkShop");

                            if (aProcesses.Length > 0)
                            {
                                NativeMethods.SetForegroundWindow(aProcesses[0].MainWindowHandle);
                            }
                        }

                        //----------------------------------------------------------------------------*
                        // Otherwise, it's ok to run the launcher
                        //----------------------------------------------------------------------------*

                        else
                        {
                            //----------------------------------------------------------------------------*
                            // Update ReloadersWorkShopUpdater.exe if needed
                            //----------------------------------------------------------------------------*

                            if (fUpdate)
                            {
                                if (File.Exists("ReloadersWorkShopUpdater.upd"))
                                {
                                    try
                                    {
                                        if (File.Exists("ReloadersWorkShopUpdater.exe"))
                                        {
                                            File.Delete("ReloadersWorkShopUpdater.exe");
                                        }

                                        File.Move("ReloadersWorkShopUpdater.upd", "ReloadersWorkShopUpdater.exe");
                                    }

                                    catch
                                    {
                                    }
                                }
                            }

                            //----------------------------------------------------------------------------*
                            // Check for updates
                            //----------------------------------------------------------------------------*

                            cRWRegistry RWRegistry = new cRWRegistry();

                            bool fUpdating = false;

                            if (!RWRegistry.Trial || !RWRegistry.TrialExpired)
                            {
                                fUpdating = CheckForUpdates();
                            }

                            //----------------------------------------------------------------------------*
                            // If we're not updating, check the registry
                            //----------------------------------------------------------------------------*

                            if (!fUpdating)
                            {
                                //----------------------------------------------------------------------------*
                                // See if this is a fresh install
                                //----------------------------------------------------------------------------*

                                if (RWRegistry.FreshInstall)
                                {
                                    Process.Start("ReloadersWorkShopUpdater.exe", "/INSTALL");

                                    return;
                                }

                                //----------------------------------------------------------------------------*
                                // Make sure the registry has not been tampered with
                                //----------------------------------------------------------------------------*

                                if (RWRegistry.InvalidRegistry)
                                {
                                    MessageBox.Show("The registry entries for Reloader's WorkShop are either corrupted or have been tampered with and needs to be repaired.  You will need to reenter your Activation Key and other info.", "Corrupted Registry", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                                    Process.Start("ReloadersWorkShopUpdater.exe", "/INSTALL");

                                    return;
                                }

                                //----------------------------------------------------------------------------*
                                // See if this is a Trial Version and check the date if it is
                                //----------------------------------------------------------------------------*

                                if (!RWRegistry.Trial && !RWRegistry.ValidateKey())
                                {
                                    MessageBox.Show("Your Activation Key is not valid.  You will need to reenter your Activation Key and other info.", "Invalid Activation Key", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                                    Process.Start("ReloadersWorkShopUpdater.exe", "/INSTALL");

                                    return;
                                }

                                //----------------------------------------------------------------------------*
                                // Check the license info
                                //----------------------------------------------------------------------------*

/*
 *                                                              cRWLicense RWLicense = new cRWLicense();
 *
 *                                                              if (!RWLicense.ValidateLicense())
 *                                                                      return;
 */
                                //----------------------------------------------------------------------------*
                                // If we get to here, everything is good to go, start the Main Form
                                //----------------------------------------------------------------------------*

                                Application.Run(new cMainForm(RWRegistry));
                            }
                        }
                    }
                }

                //----------------------------------------------------------------------------*
                // Launcher already running, bring the currently running window to the foreground
                //----------------------------------------------------------------------------*

                else
                {
                    Process CurrentProcess = Process.GetCurrentProcess();

                    Process[] aProcesses = Process.GetProcessesByName(CurrentProcess.ProcessName);

                    foreach (Process CheckProcess in aProcesses)
                    {
                        if (CheckProcess.Id != CurrentProcess.Id)
                        {
                            NativeMethods.SetForegroundWindow(CheckProcess.MainWindowHandle);

                            break;
                        }
                    }
                }
            }
        }