コード例 #1
0
ファイル: MainForm.cs プロジェクト: x893/OBDwiz
        private void displayError(Exception ex)
        {
            if (m_isDisposed)
                return;

            if (ex is LostCommunicationException)
            {
                if (m_prefences.Communications.InterfaceCommunicationType == InterfaceCommunicationType.Wifi
                    && m_reconnectCount < 2
                    )
                {	// Try 2 reconnection for WiFi
                    ++m_reconnectCount;
                    Thread.Sleep(1000);
                    invokeCall((MethodInvoker)(() => m_setupPage.ConnectToScanTool()));
                }
                else
                {
                    if (!m_AskReconnect)
                    {
                        LostCommunicationException commException = (LostCommunicationException)ex;
                        invokeCall((MethodInvoker)(() =>
                        {
                            m_AskReconnect = true;
                            try
                            {
                                using (PopupDialogForm popup = new PopupDialogForm(false))
                                {
                                    popup.StartPosition = FormStartPosition.CenterParent;
                                    popup.Owner = this;
                                    ConnectionErrorDisplay connectionErrorDisplay = new ConnectionErrorDisplay(
                                        ConnectionErrorType.LostCommunications,
                                        commException.Message,
                                        commException.Resolution,
                                        commException.HelpLink
                                        );
                                    popup.SetUserControl(connectionErrorDisplay);
                                    popup.ShowDialog(this);
                                    clearError();

                                    if (connectionErrorDisplay.ConnectionErrorDisplayAction == ConnectionErrorDisplayAction.Reconnect)
                                        m_setupPage.ConnectToScanTool();
                                    else
                                        m_setupPage.DisconnectFromScanTool();
                                }
                            }
                            finally
                            {
                                m_AskReconnect = false;
                            }
                        }));
                    }
                }
            }
            else if (ex is InvalidDataLengthException
                    || ex is TimeoutException
                    || ex is IncorrectResponseException
                    )
            {
                m_diagnostic.WriteToLog(ex.Message);
            }
            else
            {
                if (m_diagnostic != null)
                    m_diagnostic.WriteToLog(ex.Message);

                string message = ex.Message;
                if (!string.IsNullOrEmpty(message))
                    message = message.Replace("\r", string.Empty).Replace("\n", string.Empty);
                statusErrorECU = message;
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: x893/OBDwiz
        protected override void OnClosing(CancelEventArgs e)
        {
            bool disableClose = false;
            if (m_prefences.General.PromptOnExit && !m_ForceClose)
            {
                using (PopupDialogForm popup = new PopupDialogForm(false))
                {
                    ConfirmExitDisplay confirmExitDisplay = new ConfirmExitDisplay();
                    popup.SetUserControl(confirmExitDisplay);
                    if (popup.ShowDialog(this) == DialogResult.No)
                        disableClose = true;
                    m_prefences.General.PromptOnExit = confirmExitDisplay.PromptOnExit;
                }
            }

            if (disableClose)
            {
                e.Cancel = true;
                customListView.SelectItem(m_prefences.Layout.SelectedPageKey);
            }
            else
            {
                base.OnClosing(e);

                m_pidMonitor.PollingPIDs = false;
                m_pidMonitor.Pause();
                m_logs.NotifyClosing();
                m_prefences.Layout.WindowState = WindowState;
                m_prefences.Layout.UseWindowSettings = true;
                m_prefences.Save(getPreferencesPath);
                saveDataDashboard();
                m_pidMonitor.SaveSettings(MainForm.ApplicationDataDirectory);
                pluginUnInitialize();

                try
                {
                    OnApplicationClosing(EventArgs.Empty);
                }
                catch { }

                Visible = false;
                try
                {
                    m_scanTool.Disconnect();
                }
                catch { }
            }
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: x893/OBDwiz
        protected override void OnLoad(EventArgs p0)
        {
            if (m_prefences.General.ConnectOnStartup)
                m_setupPage.ConnectToScanTool();
            if (m_prefences.General.ShowWarningMessage)
            {
                using (PopupDialogForm popup = new PopupDialogForm(false))
                {
                    DisclaimerDisplay disclaimerDisplay = new DisclaimerDisplay();
                    disclaimerDisplay.WarningMessage = OCTech.OBD2.Applications.Properties.Resources.DisclaimerWarningMessage;
                    disclaimerDisplay.ShowDisplayNextTimeCheckBox = true;
                    popup.SetUserControl(disclaimerDisplay);
                    popup.ShowDialog();
                    m_prefences.General.ShowWarningMessage = disclaimerDisplay.DisplayNextTime;
                }
            }

            base.OnLoad(p0);

            if (m_prefences.Layout.UseWindowSettings)
            {
                this.SuspendLayout();
                this.Size = m_prefences.Layout.WindowSize;
                this.Location = m_prefences.Layout.WindowLocation;
                if (m_prefences.Layout.WindowState == FormWindowState.Minimized)
                    this.WindowState = FormWindowState.Normal;
                else
                    this.WindowState = m_prefences.Layout.WindowState;
                this.ResumeLayout();
            }
            else
            {
                m_prefences.Layout.WindowSize = this.Size;
                m_prefences.Layout.WindowLocation = this.Location;
            }
            this.Visible = true;
            m_loading = false;
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: x893/OBDwiz
 private void sensorCalibrationToolStripMenuItem_Click(object p0, EventArgs p1)
 {
     try
     {
         ClearError();
         using (PopupDialogForm popupDialogForm = new PopupDialogForm(DialogButtons.OK))
         {
             popupDialogForm.SetUserControl(sensorCalibration);
             popupDialogForm.ShowDialog(this);
             popupDialogForm.RemoveUserControl();
         }
     }
     catch (Exception ex)
     {
         displayError(ex);
     }
 }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: x893/OBDwiz
 private void userDefinedPIDsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         ClearError();
         using (PopupDialogForm popupDialogForm = new PopupDialogForm(DialogButtons.OK))
         {
             UserDefinedPIDViewer definedPidViewer = new UserDefinedPIDViewer(m_context);
             popupDialogForm.SetUserControl(definedPidViewer);
             popupDialogForm.ShowDialog(this);
         }
     }
     catch (Exception ex)
     {
         displayError(ex);
     }
 }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: x893/OBDwiz
 private void preferencesToolStripMenuItem_Click(object p0, EventArgs p1)
 {
     try
     {
         ClearError();
         using (PopupDialogForm popupDialogForm = new PopupDialogForm(DialogButtons.OKCancel))
         {
             PreferenceEditor preferenceEditor = new PreferenceEditor(m_context);
             popupDialogForm.SetUserControl(preferenceEditor);
             if (popupDialogForm.ShowDialog(this) != DialogResult.OK)
                 return;
             preferenceEditor.ApplyPreferences();
         }
     }
     catch (Exception ex)
     {
         displayError(ex);
     }
 }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: x893/OBDwiz
 private void powerSaveSetupToolStripMenuItem_Click(object p0, EventArgs p1)
 {
     try
     {
         ClearError();
         using (PopupDialogForm popupDialogForm = new PopupDialogForm())
         {
             PowerSaveSetup powerSaveSetup = new PowerSaveSetup();
             popupDialogForm.SetUserControl(powerSaveSetup);
             powerSaveSetup.Initialize(m_context);
             if (popupDialogForm.ShowDialog() != DialogResult.OK)
                 return;
             powerSaveSetup.ApplyPowerSaveSettings();
         }
     }
     catch (Exception ex)
     {
         displayError(ex);
     }
 }
コード例 #8
0
ファイル: MainForm.cs プロジェクト: x893/OBDwiz
 private void pluginManagerToolStripMenuItem_Click(object p0, EventArgs p1)
 {
     try
     {
         ClearError();
         using (PopupDialogForm popupDialogForm = new PopupDialogForm())
         {
             PluginPreferenceEditor preferenceEditor = new PluginPreferenceEditor();
             preferenceEditor.m003fdd(m_context, m_PluginsInfo);
             popupDialogForm.SetUserControl(preferenceEditor);
             if (popupDialogForm.ShowDialog() != DialogResult.OK)
                 return;
             preferenceEditor.ApplyChanges();
         }
     }
     catch (Exception ex)
     {
         displayError(ex);
     }
 }
コード例 #9
0
ファイル: MainForm.cs プロジェクト: x893/OBDwiz
 private void pidInspectorToolStripMenuItem_Click(object p0, EventArgs p1)
 {
     try
     {
         using (PopupDialogForm popupDialogForm = new PopupDialogForm(DialogButtons.OK))
         {
             PIDInspector pidInspector = new PIDInspector();
             pidInspector.m00267f(m_context);
             popupDialogForm.SetUserControl(pidInspector);
             popupDialogForm.ShowDialog(this);
         }
     }
     catch (Exception ex)
     {
         displayError(ex);
     }
 }
コード例 #10
0
ファイル: MainForm.cs プロジェクト: x893/OBDwiz
 private void m_scanTool_SelectECU(object p0, SelectedECUEventArgs p1)
 {
     try
     {
         if (m_prefences.Communications.PromptForECU
             || string.IsNullOrEmpty(m_prefences.Communications.ActiveECU)
             || !p1.SupportedPIDs.ContainsKey(m_prefences.Communications.ActiveECU)
             )
         {
             ThreadHelper.SyncExecuteInvoke(this, (MethodInvoker)(() =>
             {
                 try
                 {
                     PopupDialogForm form = new PopupDialogForm(false);
                     try
                     {
                         ECUSelector selector = new ECUSelector(m_prefences, m_scanTool, p1);
                         form.SetUserControl(selector);
                         form.ShowDialog(this);
                         m_prefences.Communications.ActiveECU = p1.ActiveECU;
                         selector.Cleanup();
                     }
                     finally
                     {
                         if (form != null)
                         {
                             form.Dispose();
                         }
                     }
                 }
                 catch (Exception ex)
                 {
                     displayError(ex);
                 }
             }));
         }
     }
     catch (Exception exception)
     {
         displayError(exception);
     }
 }