(NET) NET (2019)

<< Multi Languages Spell Checker for webmaster. Part 7. Other project components. <<


Sorry, no time for more details description, only code.


1.


   1:  Public Class LogForm
   2:      Private Sub LogForm_Load(sender As Object, e As EventArgs) Handles Me.Load
   3:          Try
   4:              RichTextBox1.Text = My.Computer.FileSystem.ReadAllText(IO.Path.Combine(GetTempFolderName, "log.txt"))
   5:          Catch ex As Exception
   6:              MsgBox(ex.Message)
   7:          End Try
   8:   
   9:      End Sub
  10:  End Class

2.


   1:  Public Class FtpSettingForm
   2:      Private Sub FtpSetButton_Click(sender As Object, e As EventArgs) Handles FtpSetButton.Click
   3:          Dim X As New Registry("SpellChecker")
   4:          X.SetValue("FtpHost", FtpIpTextBox.Text)
   5:          X.SetValue("FtpName", FtpLoginTextBox.Text)
   6:          X.SetValue("FtpPass", FtpPassTextBox.Text)
   7:          Me.Close()
   8:      End Sub
   9:  End Class

Простий сервіс реестра для зберігання вводу користувача десктопних прог.

3.

   1:  Imports System
   2:  Imports System.Windows.Forms
   3:  Imports System.Runtime.CompilerServices
   4:   
   5:   
   6:  Module ControlExtensions1
   7:      <Extension()>
   8:      Sub InvokeOnUiThreadIfRequired(ByVal GuiForm As Form, ByVal action As Action)
   9:          If GuiForm.InvokeRequired Then
  10:              GuiForm.BeginInvoke(action)
  11:          Else
  12:              action.Invoke()
  13:          End If
  14:      End Sub
  15:  End Module

4.

   1:  Module TempFiles
   2:      Public Function GetTempFolderName() As String
   3:          Dim LocalTmpPath As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
   4:          Dim TempAppDirectory As String = IO.Path.Combine(LocalTmpPath, Application.ProductName)
   5:          If Not My.Computer.FileSystem.DirectoryExists(TempAppDirectory) Then
   6:              My.Computer.FileSystem.CreateDirectory(TempAppDirectory)
   7:          End If
   8:          Return TempAppDirectory
   9:      End Function
  10:  End Module

5.

   1:  Imports CefSharp
   2:  Imports CefSharp.WinForms
   3:  Imports System
   4:  Imports System.IO
   5:  Imports System.Runtime.InteropServices
   6:  Imports System.Windows.Forms
   7:   
   8:  Public Module Starter
   9:   
  10:      <DllImport("user32.dll")>
  11:      Private Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean
  12:      End Function
  13:   
  14:      <DllImport("Kernel32")>
  15:      Private Function GetConsoleWindow() As IntPtr
  16:      End Function
  17:   
  18:      Const SW_HIDE As Integer = 0
  19:      Const SW_SHOW As Integer = 5
  20:   
  21:      Public MainForm_Instance As MainForm
  22:   
  23:   
  24:      <STAThread>
  25:      Public Sub Main()
  26:   
  27:   
  28:          Dim hwnd As IntPtr
  29:          hwnd = GetConsoleWindow()
  30:          ShowWindow(hwnd, SW_HIDE)
  31:   
  32:          AddHandler Application.ThreadException, New Threading.ThreadExceptionEventHandler(AddressOf Form1_UIThreadException)
  33:          Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException)
  34:          AddHandler AppDomain.CurrentDomain.UnhandledException, New UnhandledExceptionEventHandler(AddressOf CurrentDomain_UnhandledException)
  35:   
  36:          MainForm_Instance = New MainForm
  37:   
  38:          Application.Run(MainForm_Instance)
  39:   
  40:      End Sub
  41:   
  42:   
  43:   
  44:      Private Sub Form1_UIThreadException(ByVal sender As Object, ByVal t As Threading.ThreadExceptionEventArgs)
  45:          Dim result As DialogResult = DialogResult.Cancel
  46:   
  47:          Try
  48:              result = ShowThreadExceptionDialog("Fatal Error", t.Exception)
  49:              If result = DialogResult.Abort Then Application.[Exit]()
  50:          Catch
  51:              Try
  52:                  MessageBox.Show("Fatal Windows Forms Error", "UIThreadException", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.[Stop])
  53:              Finally
  54:                  Application.[Exit]()
  55:              End Try
  56:          End Try
  57:   
  58:      End Sub
  59:   
  60:   
  61:      Private Sub CurrentDomain_UnhandledException(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs)
  62:          Dim errorMsg As String = "Fatal Non-UI Error:" & vbLf & vbLf
  63:          Dim ex As Exception = CType(e.ExceptionObject, Exception)
  64:   
  65:          Try
  66:              Dim myLog As EventLog = New EventLog()
  67:              myLog.Source = "ThreadException"
  68:              myLog.WriteEntry(errorMsg & ex.Message & vbLf & vbLf & "Stack Trace:" & vbLf + ex.StackTrace)
  69:          Catch exc As Exception
  70:   
  71:              Try
  72:                  MessageBox.Show("Could not write the error to the event log. Reason: " & exc.Message, "UnhandledException", MessageBoxButtons.OK, MessageBoxIcon.[Stop])
  73:              Finally
  74:                  Application.[Exit]()
  75:              End Try
  76:          End Try
  77:      End Sub
  78:   
  79:      Public Function ShowThreadExceptionDialog(ByVal title As String, ByVal e As Exception) As DialogResult
  80:          Dim errorMsg As String = "An application error occurred. Please contact the adminstrator " & "with the following information:" & vbLf & vbLf
  81:          errorMsg = errorMsg & e.Message & vbLf & vbLf & "Stack Trace:" & vbLf + e.StackTrace
  82:          Return MessageBox.Show(errorMsg, title, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.[Stop])
  83:      End Function
  84:   
  85:  End Module
  86:   


Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23
Link to this page: //www.vb-net.com/SpellChecker/OtherComponents.htm
<SITEMAP>  <MVC>  <ASP>  <NET>  <DATA>  <KIOSK>  <FLEX>  <SQL>  <NOTES>  <LINUX>  <MONO>  <FREEWARE>  <DOCS>  <ENG>  <CHAT ME>  <ABOUT ME>  < THANKS ME>