public override void Install(IDictionary stateSaver)
        {
            try
            {
                string msg = "Installer Custom Action - Event Log Created During Install";
                EventLogger.LoggingLevel = TraceLevel.Verbose;
                EventLogger.LogMessage(msg, TraceLevel.Info);
                Trace.WriteLine(msg);

            }
            catch (Exception ex)
            {
                EventLogger.LogMessage(ex);
                CustomErrorBox error = new CustomErrorBox("A problem occurred while initiaizing the Event Log for this application. The installation must be aborted. Please contact Optec Inc. Tech Support for assistance." +
                    "If another error message is displayed following this one please copy down its contents as well as the details of this message so that we may better assist you in solving this problem.", "Install Error");
                error.ShowDialog();
            }
            base.Install(stateSaver);
        }
예제 #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                // Set the view menu checked states
                positionAndTemperatureToolStripMenuItem.Checked = Properties.Settings.Default.DisplayPositionAndTemperature;
                relativeFocusAdjustToolStripMenuItem.Checked = Properties.Settings.Default.DisplayRelativeFocusAdjust;
                temperatureCompensationToolStripMenuItem.Checked = Properties.Settings.Default.DisplayTempComp;
                absoluteFocusAdjustToolStripMenuItem.Checked = Properties.Settings.Default.DisplayAbsoluteFocusAdjust;
                relativeFocusOffsetsToolStripMenuItem.Checked = Properties.Settings.Default.DisplayRelativeFocusOffsets;
                absoluteFocusPresetsToolStripMenuItem.Checked = Properties.Settings.Default.DisplayAbsoluteFocusPresets;
                if (Properties.Settings.Default.Focuser2Disabled)
                {
                    //Only Focuser 1 is disabled
                    if (Properties.Settings.Default.SwitchF1F2)
                        Foc1_CHK.Checked = !Properties.Settings.Default.Focuser2Disabled;
                    //Only Focuser 2 is disabled
                    else
                        Foc2_CHK.Checked = !Properties.Settings.Default.Focuser2Disabled;
                }
                //Both are enabled
                else
                {
                    Foc1_CHK.Checked = !Properties.Settings.Default.Focuser2Disabled;
                    Foc2_CHK.Checked = !Properties.Settings.Default.Focuser2Disabled;
                }

                // hook up the view item checked_changed events
                positionAndTemperatureToolStripMenuItem.CheckedChanged += new EventHandler(this.viewItemToolStripMenuItem_CheckStateChanged);
                relativeFocusAdjustToolStripMenuItem.CheckedChanged += new EventHandler(this.viewItemToolStripMenuItem_CheckStateChanged);
                temperatureCompensationToolStripMenuItem.CheckedChanged += new EventHandler(this.viewItemToolStripMenuItem_CheckStateChanged);
                absoluteFocusAdjustToolStripMenuItem.CheckedChanged += new EventHandler(this.viewItemToolStripMenuItem_CheckStateChanged);
                relativeFocusOffsetsToolStripMenuItem.CheckedChanged += new EventHandler(this.viewItemToolStripMenuItem_CheckStateChanged);
                absoluteFocusPresetsToolStripMenuItem.CheckedChanged += new EventHandler(this.viewItemToolStripMenuItem_CheckStateChanged);
                Foc1_CHK.CheckedChanged += new EventHandler(this.viewItemToolStripMenuItem_CheckStateChanged);
                Foc2_CHK.CheckedChanged += new EventHandler(this.viewItemToolStripMenuItem_CheckStateChanged);
                alwaysOnTopToolStripMenuItem.CheckedChanged += new EventHandler(alwaysOnTopToolStripMenuItem_CheckedChanged);
                alwaysOnTopToolStripMenuItem.Checked = Properties.Settings.Default.AlwaysOnTop; // We do this after so the change takes affect now...

                // adjust form height for user preferences
                setFormHeight();

                if (!Properties.Settings.Default.SwitchF1F2)
                {
                    EventLogger.LogMessage("Creating 2 ASCOM driver focuser objects", TraceLevel.Info);
                    myFoc1 = new ASCOM.DriverAccess.Focuser("ASCOM.FocusLynx.Focuser");
                    myFoc2 = new ASCOM.DriverAccess.Focuser("ASCOM.FocusLynx2.Focuser");
                }
                else
                {
                    EventLogger.LogMessage("Creating 2 ASCOM driver focuser objects", TraceLevel.Info);
                    myFoc1 = new ASCOM.DriverAccess.Focuser("ASCOM.FocusLynx2.Focuser");
                    myFoc2 = new ASCOM.DriverAccess.Focuser("ASCOM.FocusLynx.Focuser");
                }

                F1LastConnectedState = !myFoc1.Link;    // Set these to the opposite so that controls are immediatly refreshed.
                F2LastConnectedState = !myFoc2.Link;

            }
            catch (Exception ex)
            {
                EventLogger.LogMessage("An error occurred while creating instances of Focuser Hub ASCOM Driver. " + ex.Message, TraceLevel.Error);
                CustomErrorBox error = new CustomErrorBox("An error occurred while creating the initial instances of the FocusLynx ASCOM Driver." +
                    " The program cannot continue. Please contact technical support.", ex.Message);
                error.ShowDialog();
                Application.Exit();
            }

            LoadFocusOffsets_F1();
            LoadFocusPresets_F1();
            LoadFocusOffsets_F2();
            LoadFocusPresets_F2();

            setFormWidth();
            //setFormHeight(); Automatically occurs.
        }
예제 #3
0
 public void LogAndDisplayException(string extraMessage , Exception exc)
 {
     string friendlyMessage = extraMessage + ": ";
     Exception temp = exc;
     while (temp.InnerException != null)
         temp = temp.InnerException;
     friendlyMessage += temp.Message;
     EventLogger.LogMessage(exc);
     CustomErrorBox error = new CustomErrorBox(friendlyMessage, exc.ToString());
     error.ShowDialog();
 }