Imports System.ComponentModel Imports System.Deployment Imports System.Deployment.Application Public Class frmMain Private _dataPath As String = System.IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "Gästeliste.xml") Private _rowIndex As Integer = 0 Private Sub LoadWindowPosition() 'http://christ-offer.blogspot.co.at/2012/02/vbnet-remember-application-window-size.html Dim ptLocation As System.Drawing.Point = My.Settings.WindowLocation If (ptLocation.X = -1) And (ptLocation.Y = -1) Then Return End If Dim bLocationVisible As Boolean = False For Each S As Screen In Screen.AllScreens If S.Bounds.Contains(ptLocation) Then bLocationVisible = True Exit For End If Next If Not bLocationVisible Then Return End If Me.StartPosition = FormStartPosition.Manual Me.Location = ptLocation Me.Size = My.Settings.WindowSize End Sub Private Sub frmMain_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing Me.GästeDataSet.WriteXml(_dataPath) My.Settings.WindowLocation = Me.Location My.Settings.WindowSize = Me.Size End Sub Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load Try Me.GästeDataSet.ReadXml(_dataPath) Catch ex As Exception ' do nothing, that file gets created when we close the application ;) End Try LoadWindowPosition() ' Setting colors of grids to some fancy ones :) Me.DataGridView1.RowsDefaultCellStyle.BackColor = Color.Azure Me.DataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige End Sub Private Sub InfoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles InfoToolStripMenuItem.Click Dim oForm As New frmAbout() oForm.ShowDialog() oForm.Dispose() oForm = Nothing End Sub Private Sub HilfePerEmailAnfordernToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles HilfePerEmailAnfordernToolStripMenuItem.Click If MsgBox("Dies startet dein Emailprogramm, um mir eine Email zu schreiben", vbOKCancel) = vbOK Then Process.Start("mailto:Dominic%20Reich%20?subject=[FEWO%20Gästeliste]%20Bitte%20um%20Hilfe&body=Hallo%20Dominic,%0Aich%20brauche%20Hilfe%20bei%20%0A%0A--%20%0AEmail%20über%20das%20Programm%20'Gästeliste'%20erstellt.") End If End Sub Private Sub FehlerMeldenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FehlerMeldenToolStripMenuItem.Click If MsgBox("Dies öffnet deinen Browser und führt dich zur Github-Issues Seite." + Chr(13) + "Ein Github-Konto ist zwingend erforderlich!", vbOKCancel) = vbOK Then Process.Start("https://github.com/freefallcid/Gaesteliste/issues") End If End Sub Private Sub DataGridView1_CellMouseUp(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseUp If e.Button = MouseButtons.Right Then Me.DataGridView1.Rows(e.RowIndex).Selected = True Me._rowIndex = e.RowIndex Me.DataGridView1.CurrentCell = Me.DataGridView1.Rows(e.RowIndex).Cells(1) Me.mnuContext.Show(Me.DataGridView1, e.Location) mnuContext.Show(Cursor.Position) End If End Sub Private Sub EintragLöschenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles EintragLöschenToolStripMenuItem.Click If Not Me.DataGridView1.Rows(Me._rowIndex).IsNewRow Then Me.DataGridView1.Rows.RemoveAt(Me._rowIndex) End If End Sub Private Sub OnlineHilfeToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles OnlineHilfeToolStripMenuItem.Click Process.Start("http://tmsn.at/?tools&gaesteliste&hilfe") End Sub Private Sub UpdateToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles UpdateToolStripMenuItem.Click Dim Info As UpdateCheckInfo If ApplicationDeployment.IsNetworkDeployed Then Dim AD As ApplicationDeployment = ApplicationDeployment.CurrentDeployment Info = AD.CheckForDetailedUpdate If Info.UpdateAvailable Then If MsgBox("Ein Update ist verfügbar und wird jetzt installiert." + Chr(13) + "Die Anwendung wird danach neu gestartet.", vbOKCancel) = vbOK Then AD.Update() System.Windows.Forms.Application.Restart() End If Else MsgBox("Es ist kein Update verfügbar.") End If End If End Sub End Class